使用Nagios監(jiān)控Linux客戶端-Nagios監(jiān)控服務器的配置
使用Nagios監(jiān)控Linux 客戶端Nagios監(jiān)控的方式:
本文介紹的是:使用Nagios監(jiān)控Linux客戶端
(一)Nagios監(jiān)控服務器的配置
1.安裝nrpe
- [root@UnixHot src]# tar zxvf nrpe-2.12.tar.gz
 - [root@UnixHot nrpe-2.12]# ./configure && make all
 - [root@UnixHot nrpe-2.12]# make install-plugin
 - [root@UnixHot nrpe-2.12]# make install-daemon
 - [root@UnixHot nrpe-2.12]# make install-daemon-config
 - [root@UnixHot nrpe-2.12]# make install-xinetd
 
2.配置nrep
- [root@UnixHot nrpe-2.12]# vi /etc/xinetd.d/nrpe
 - service nrpe
 - {
 - flags = REUSE
 - socket_type = stream
 - port = 5666
 - wait = no
 - user = nagios
 - group = nagios
 - server = /usr/local/nagios/bin/nrpe
 - server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
 - log_on_failure += USERID
 - disable = no
 - only_from = 127.0.0.1 192.168.0.206 192.168.0.155 192.168.0.157
 
在only_from 添加要監(jiān)控的主機的IP地址,中間以空格隔開。
3.添加端口
- [root@UnixHot nrpe-2.12]# vi /etc/services 在最后添加
 - nrpe 5666/tcp #nrpe
 
4.重新啟動Xinetd服務
- [root@UnixHot nrpe-2.12]# /etc/init.d/xinetd restart
 - [root@UnixHot nrpe-2.12]# netstat -na | grep 5666
 - tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
 
以上的1-4的步驟要在客戶端上做。
5.修改配置文件commands.cfg加入對nrpe的支持
- [root@UnixHot ~]# vi /usr/local/nagios/etc/objects/commands.cfg
 - #nrpe set
 - define command{
 - command_name check_nrpe
 - command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
 - }
 
6.有哪些nrpe檢測命令可以用,它們在哪里呢?
- [root@UnixHot ~]# vi /usr/local/nagios/etc/nrpe.cfg
 
(默認有下面四個命令)
- command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
 - command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
 - command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
 - command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
 - command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
 
7.怎么使用這些命令監(jiān)控客戶端呢?
其實很簡單,就是在services.cfg里面添加服務即可,格式就和上篇文檔講的一樣,只是命令不同罷了。
- [root@UnixHot ~]# vi /usr/local/nagios/etc/objects/services.cfg
 
加入:
- define service {
 - host_name Nagios-Server
 - service_description check-users
 - check_period 24x7
 - max_check_attempts 4
 - normal_check_interval 3
 - retry_check_interval 2
 - contact_groups sagroup
 - notification_interval 10
 - notification_period 24x7
 - notification_options w,u,c,r
 - check_command check_nrpe!check_users
 - }
 - define service {
 - host_name Nagios-Server
 - service_description check-load
 - check_period 24x7
 - max_check_attempts 4
 - normal_check_interval 3
 - retry_check_interval 2
 - contact_groups sagroup
 - notification_interval 10
 - notification_period 24x7
 - notification_options w,u,c,r
 - check_command check_nrpe!check_load
 - }
 - define service {
 - host_name Nagios-Server
 - service_description check-total-procs
 - check_period 24x7
 - max_check_attempts 4
 - normal_check_interval 3
 - retry_check_interval 2
 - contact_groups sagroup
 - notification_interval 10
 - notification_period 24x7
 - notification_options w,u,c,r
 - check_command check_total_procs
 - }
 
在這里僅列出了一個客戶端的配置,其它的客戶端,只需修改host_name 即可。
【編輯推薦】















 
 
 
 
 
 
 