注意:兩端nrpe的版本要一致,不然無法相連接
創(chuàng)新互聯(lián)是專業(yè)的臺(tái)前網(wǎng)站建設(shè)公司,臺(tái)前接單;提供網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行臺(tái)前網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!
NRPE總共由兩部分組成:
check_nrpe插件,運(yùn)行在監(jiān)控主機(jī)上。
NRPE daemon,運(yùn)行在遠(yuǎn)程的linux主機(jī)上(通常就是被監(jiān)控機(jī))
cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround make make install |
#yum install openssl-devel(安裝 openssl包) cd nagios-nrpe_2.8.1 ./configure #默認(rèn)自動(dòng)添加了openssl #因?yàn)閭魉瓦^程要加密,如果后面make報(bào)錯(cuò),加如下參數(shù) rpm -qa| grep ssl openssl-devel-0.9.7a-43.17.el4_6.1 rpm -ql openssl-devel-0.9.7a-43.17.el4_6.1 | more ./configure --enable-ssl --with-ssl-lib=/lib/(當(dāng)然前提要有openssl) make all make install-plugin |
vi /usr/local/nagios/etc/objects/commands.cfg #添加 #check nrpe define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } |
vi /usr/local/nagios/etc/nagios.cfg #中間添加 cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg |
vi /usr/local/nagios/etc/objects/mylinux.cfg define host{ use linux-server host_name mylinux alias mylinux address 192.168.1.203(客戶端IP既被監(jiān)控的IP) } define service{ use generic-service host_name mylinux service_description check-swap check_command check_nrpe!check_swap } define service{ use generic-service host_name mylinux service_description check-load check_command check_nrpe!check_load } define service{ use generic-service host_name mylinux service_description check-disk check_command check_nrpe!check_had1 } define service{ use generic-service host_name mylinux service_description check-users check_command check_nrpe!check_users } define service{ use generic-service host_name mylinux service_description otal_procs check_command check_nrpe!check_total_procs } #這5個(gè)是默認(rèn)的監(jiān)控服務(wù),如需自定義服務(wù)可在這里添加自定義服務(wù)可參考:http://saplingidea.javaeye.com/blog/514013 如有必要?jiǎng)t需更改check閾值,在被監(jiān)控端的/usr/local/nagios/etc/nrpe.cfg,下面會(huì)提到 |
chkconfig --add nagios #配置機(jī)器啟動(dòng)時(shí)自動(dòng)啟動(dòng)Nagios chkconfig nagios on /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #檢查Nagios配置文件 vi /etc/selinux/config #關(guān)閉SELinux SELINUX=disabled service iptables stop #關(guān)閉SELinux,或打開80,5666端口 service nagios start |
useradd nagios passwd nagios tar -zxvf nagios-plugins-1.4.15.tar.gz cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround Make make install |
chown –R nagios.nagios /usr/local/nagios [root@client nagios]# ll drwxr-xr-x 2 nagios nagios 4096 Jun 1 00:07 libexec drwxr-xr-x 3 nagios nagios 4096 Jun 1 00:07 share |
yum install openssl-devel(安裝 openssl包) tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz cd nagios-nrpe_2.8.1 ./configure (會(huì)自動(dòng)加載SSL) #如果后面make報(bào)錯(cuò),加如下參數(shù) ./configure --enable-ssl --with-ssl-lib=/usr/lib/(當(dāng)然前提要有openssl) make all make install-plugin make install-daemon make install-daemon-config |
vi /usr/local/nagios/etc/nrpe.cfg allowed_hosts=127.0.0.1,192.168.1.202 |
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d #上面這一步在本機(jī)上可以運(yùn)行,如通過ssh連接,則需用:/usr/local/nagios/bin/nrpe -d vi /etc/rc.d/rc.local /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d |
netstat -an | grep 5666 tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 NRPE v2.8.1 #服務(wù)端測試 /usr/local/nagios/libexec/check_nrpe -H l92.168.1.203 NRPE v2.8.1 #常見錯(cuò)誤 /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 CHECK_NRPE: Error - Could not complete SSL handshake. 配置allowed_hosts=127.0.0.1,192.168.1.202然后kill進(jìn)程再重啟就OK了 2./usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 Connection refused by host Nrpe進(jìn)程沒有啟動(dòng) |
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 command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10% #這里就是上面提到的check閾值,如需更改,加減后面的數(shù)值即可 |