http://www.scdlt.com/?p=32
創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的三江侗網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
被監(jiān)控機(jī)安裝nrpe
準(zhǔn)備工作:
sudo apt-get install openssl
sudo apt-get install libcurl3-openssl-dev
添加用戶和組(nagios)
useradd nagios -s /sbin/nologin
groupadd nagios
1.下載與安裝NRPE:
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar -zxf nrpe-2.13.tar.gz
cd nrpe-2.13
開始安裝:
./configure --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu(可能64位和32位有所不同)
make all
make install-plugin
make install-daemon
make install-daemon-config
2.下載與安裝nagios-plugins
wget http://assets.nagios.com/downloads/nagiosplugins/nagios-plugins-1.5.tar.gz
tar -zxvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure --prefix=/usr/local/nagios
make install
3.下載與安裝openmanage
http://folk.uio.no/trondham/software/check_openmanage.html#download
wget http://folk.uio.no/trondham/software/files/check_openmanage-3.7.11.tar.gz
tar -zxvf check_openmanage-3.7.11.tar.gz
cd check_openmanage-3.7.11
cp check_openmanage /usr/local/nagios/libexec/
編輯nrpe: /usr/local/nagios/etc/nrpe.cfg
添加與修改如下內(nèi)容:
allowed_hosts=127.0.0.1,222.247.*.*,222.247.*.* 加入允許連接的主機(jī),多主機(jī)用逗號(hào)分開
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 10% -c 5% -p /
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_boot]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /boot
command[check_sensors]=/usr/local/nagios/libexec/check_sensors
command[check_cputemp]=/usr/local/nagios/libexec/check_cputemp -m sensors -w 70 -c 85
command[check_hardware]=/usr/local/nagios/libexec/check_openmanage -e -t 200 --only critical
command[check_storage]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only storage -b ctrl_fw=0
command[check_power]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only power
command[check_memory]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only memory
command[check_fans]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only fans
command[check_temp]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only temp
command[check_cpu]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only cpu
command[check_voltage]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only voltage
command[check_batteries]=/usr/local/nagios/libexec/check_openmanage -s -t 200 --only batteries
啟動(dòng)nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
查看是否啟動(dòng)成功
ps -ef |grep nrpe
nagios 2638 1 0 12:45 ? 00:00:00 /usr/local/nagios/bin/nrpe -c
然后iptables開放端口:5666
vi /etc/iptables
-A INPUT -s 222.247.*.* -p tcp -m tcp --dport 5666 -j ACCEPT
或
#iptables -A INPUT -s 222.247.*.* -p tcp -m tcp --dport 5666 -j ACCEPT
#iptables-restore -c /etc/iptables.rules 即時(shí)生效。(不需要安裝iptables)
#iptables -L -n 查看規(guī)則
重啟nrpe,需要先kill進(jìn)程,然后再啟動(dòng)
如:
ps -ef |grep nrpe
nagios 2638 1 0 12:45 ? 00:00:00 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
kill -9 2638
然后再啟動(dòng):
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
也可以將腳本加入:/etc/rc.local 文件隨機(jī)啟動(dòng) :
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
測(cè)試nrpe是否工作
/usr/local/nagios/libexec/check_nrpe -H localhost
服務(wù)器配置:
同樣安裝nrpe.
檢查命令行是否可查到被監(jiān)控主機(jī)nrpe信息:
/usr/local/nagios/libexec/check_nrpe -H 被監(jiān)控IP -c check_disk
日志文件
tail -f /var/log/syslog