Server端安装
# 更新yum库
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -ivh rpmforge-release-0.5.2-2.el5.rf.i386.rpm
#安装nagios
yum -y install nagios nagios-nrpe nagios-plugins nagios-plugins-nrpe check_logfiles
#添加nagios到系统自动运行
chkconfig --add nagios
chkconfig nagios on
nagios相关路径:
/etc/nagios #配置文件目录:
/etc/nagios/objects #模板相关配置
/usr/bin/nagios # nagios程序
配置Apache密码访问
# nagiosadmin为用户名,配置这个用户名为省很多事
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
启动并测试
service nagios start
service httpd start
#打开浏览器,输入密码,在host里面应该有“localhost”这台机器
http://{your_ip_address}/nagios
添加被监控设备
安装(client端)
# 更新yum库
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
#安装nagios
yum -y install nagios-nrpe nagios-plugins nagios-plugins-nrpe
配置(client端)
vi /etc/nagios/nrpe.cfg
# 下列配置表示允许127.0.0.1, 192.168.121.55(Server)这两台机器访问当前机器的信息
allowed_hosts=127.0.0.1,192.168.121.55
测试(client端)
#启动nrpe (Nagios Remote Plugin Executor)
service nrpe start
chkconfig --add nrpe
chkconfig nrpe on
#查看端口是否启动
netstat -an | grep 5666
#本机测试服务是否正常
/usr/lib/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_load
/usr/lib64/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_load # 64 bit 命令
#服务器端测试访问是否正常。**在Server上执行**
/usr/lib/nagios/plugins/check_nrpe -H {client_ip} -c check_load
#64bit /usr/lib64/nagios/plugins/check_nrpe -H {client_ip} -c check_load
配置(Server端)
# 创建client配置(192.168.121.4为client ip)
vi /etc/nagios/objects/192.168.121.4.cfg
define host{
use linux-server
host_name client-1
alias client-1
address
192.168.121.4
}
define service{
use generic-service
host_name client-1
service_description Current Load
check_command check_nrpe!check_load
}
# 将上面配置加到系统
vi /etc/nagios/nagios.cfg
cfg_file=/etc/nagios/objects/192.168.121.4.cfg
运行和测试(Server端)
/usr/bin/nagios -v /etc/nagios/nagios.cfg #Server端验证配置
service nagios start
FAQ:
Q: HTTP WARNING: HTTP/1.1 403Forbidden
A: nagios找不到监控文件,执行 "touch /var/www/html/index.html"
Q: 64bit下错误“Service check command 'check_nrpe' specified in service”
A: 发现commands.cfg里面居然没有“check_nrpe”这个命令定义,加上后OK
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
附录
Nagios的发音:[ˈnædʒiɔs]
参考:
CentOS下nagios报警飞信部署四步走
http://www.elain.org/?tag=nagios
Nagios/监控linux客户端
http://xiwi.org/index.php/Nagios/%E7%9B%91%E6%8E%A7linux%E5%AE%A2%E6%88%B7%E7%AB%AF
nagios详细配置
http://lilinqing.blog.51cto.com/1122687/483604
ganglia和nagios监控企业集群
http://www.ibm.com/developerworks/cn/linux/l-ganglia-nagios-1/
http://www.ibm.com/developerworks/cn/linux/l-ganglia-nagios-2/
-- end --