Nagios监控主机笔记(一)
参考资料
nagios 监控目的
即时了解服务器运行情况,服务运行状况,经过mail、手机短信、声音报警通知管理员,以便处理问题
。
1、nagios 监控分为二个部份:
1)、nagios服务器端(如下简称server端)
server端所需软件包:
Apache、nagios-3.0.六、nrpe-2.8.一、nagios-plugins-1.4.1三、sendmail、nagios-mysql-plugins、nagios-mysql-plugins-0.3.tar.gz、perl等
2)、监控服务器端(如下简称client端)
client端所需软件包:
nrpe-2.8.一、nagios-plugins-1.4.13等
NRPE
是
nagios
的一个扩展,它被用于被监控的服务器上,向
nagios
监控平台提供该服务器的一些本地的状况。例如,
cpu
负载、内存使用、硬盘使用等等。
nagios-plugins是nagios监控服务器的插件
nagios-mysql-plugins、nagios-mysql-plugins 是监控mysql服务器的插件
2、nagios服务器的安装
1
)、nagios安装
mkdir /usr/local/nagios
tar zxvf nagios-3.0.6
cd nagios
./configure –prefix=/usr/local/nagios ----with-nagios-user=nag ios --with-nagios-group=nagios
make all
make install
make install-commandmode
make install-config
2)、Apache安装与配置
tar zxvf httpd-2.2.8.tar.gz
cd httpd-2.2.8
./configure --prefix=/usr/local/apache
make
make install
配置nagios以下
在apache的配置httpd.conf中加入
include conf/nagios.conf
nagios.conf内容以下
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DirectoryIndex index.html index.php
Alias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AddHandler cgi-script cgi pl
AllowOverride None
Order allow,deny
Allow from all
# AuthName "Nagios Access"
# AuthUserFile /usr/local/nagios/etc/htpasswd
# Require valid-user
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
# AuthName "nagios Access"
# AuthUserFile /usr/local/nagios/etc/htpasswd
# Require valid-user
</Directory>
</VirtualHost>
建立http验证用户htpasswd文件,用户名为test,密码能够随便设置
root@nagios#htpasswd -c /usr/local/nagios/etc/htpasswd test
New password:
Re-type new password:
Adding password for user test
3)、nagios-plugins安装
tar zxvf nagios-plugins-1.4.13
cd nagios-plugins
./configure --prefix=/usr/local/nagios
#安装目录选择/usr/local/nagios,由于该目录下的libexec目录下的插件是nagios监控所须要的
make && make install
4)、检查远程服务器nrpe 链接,可显示版本号。若是能正确显示版本号,说明nrpe 服务能正常链接.
/usr/local/nrpe/libexec/check_nrpe -H 192.168.1.22
NRPE v2.12
3、client服务端的安装与配置
1)、nagios-plugins安装
tar zxvf nagios-plugins-1.4.13
cd nagios-plugins
./configure --prefix=/usr/local/nagios
make && make install
2)、nrpe安装
root@client#mkdir /usr/local/nrpe
tar zxvf nrpe-2.8.1
cd nagios
./configure --prefix=/usr/local/nrpe
make && make install
3)、windows客户端的安装nsclient