首页 > 代码库 > 实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机
实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机
本次实验在上次实验的环境下进行:实战Nagios网络监控(1)——监控本机运行状态和Mysq主机
需要的包:nagios-plugins-2.1.1.tar.gz
nrpe-2.15.tar.gz
服务器端:server1.example.com 172.25.254.1
新监控端:server2.example.com 172.25.254.2
实验前提:
/etc/init.d/httpd start
/etc/init.d/nagios start
/etc/init.d/mysqld start ##如果启不开的化,cd /var/lib/mysql/,然后,rm -rf mysql.sock再启动
chkconfig httpd on
chkconfig mysqld on
浏览器登陆 172.25.38.6/nagios 查看服务状态
1.新监控端配置(server2)
1.1 .tar zxf nrpe-2.15.tar.gz
tar zxf nagios-plugins-2.1.1.tar.gz #nagios 插件安装
cd nagios-plugins-2.1.1
yum install gcc -y openssl-devel mysql-devel
useradd -M -d /usr/local/nagios nagios ##id号不规定一定是要900,因为服务器上设置的是900,所以认为统一比较好
1.2 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
1.3 chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
yum install xinetd
1.4 cd nrpe-2.15
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
cd /etc/xinetd.d/
1.5 vim nrpe
#nrpe 服务监听端口
1.6 vim /etc/services
加入
1.7 cd ../etc/
vim nrpe.cfg
#根分区监测
/etc/init.d/xinetd start
1.8 cd /usr/local/nagios/libexec/
scp check_nrpe root@172.25.254.1:/usr/local/nagios/libexec/
2.服务器端配置(server1)
2.1 [root@server1 libexec]# ll check_nrpe
-rwxr-xr-x 1 root root 76769 Jul 23 10:02 check_nrpe
[root@server1 libexec]# chown nagios:nagios check_nrpe ##更改脚本权限为nagios所有
[root@server1 libexec]# ll check_nrpe
-rwxr-xr-x 1 nagios nagios 76769 Jul 23 10:02 check_nrpe
2.2 [root@server1 libexec]# ./check_nrpe -H 172.25.254.2 -c check_disk ##执行脚本
DISK OK - free space: / 5333 MB (83% inode=92%);| /=1086MB;5410;6086;0;6763
[root@server1 libexec]# ./check_nrpe -H 172.25.254.2 -c check_load ##执行脚本
OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0;
2.3 cd /usr/local/nagios/etc/objects/
vim commands.cfg
*****************************************************************************************
218 #‘check_nrpe‘ command definition
219 define command{
220 command_name check_nrpe
221 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
222
}
****************************************************************************************
vim services.cfg
*****************************************************************************************************
117 ###########check_nrpe############################
118 define service{
119 use local-service
120 host_name server2.example.com
121 service_description 根分区
122 check_command check_nrpe!check_disk
123 }
124
125
126 define service{
127 use local-service
128 host_name server2.example.com
129 service_description 登录用户数
130 check_command check_nrpe!check_users
131 }
*******************************************************************************************************
2.4 /etc/init.d/nagios reload
本文出自 “技术人生,简单不简单” 博客,请务必保留此出处http://willis.blog.51cto.com/11907152/1866092
实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机