沒寫下來,下次要弄一定又要忘記,重新開始。
Linux使用的distribution: CENTOS 6
公司使用的Linux distribution最好統一,指令相同,可互為備援。今後公司要用Linux,都使用CENTOS。
要使用Nagios NRPE監控遠端 Linux 伺服器,需要先下載兩個檔案:
http://www.nagios.org/download/download.php
nagios-plugins-1.4.x.tar.gz
nrpe-2.1x.tar.gz
這兩個檔案都要安裝在需要monitor的遠端Linux 伺服器。
# tar xzf nagios-plugins-1.4.15.tar.gz
# cd nagios-plugins-1.4.15
需要安裝 openssl-devel
# yum -y install openssl-devel
如果centos 6是安裝minimal的話,make & gcc都要另外裝,要不然make不過。
# yum install make
# yum install gcc
安裝 nagios plugin
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
# make
# make install
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec
NRPE需要xinetd來啟動,所以需要裝。
# yum install xinetd
# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
# tar -xzf nrpe-2.13.tar.gz
# cd nrpe-2.13
# ./configure
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# make install-xinetd
編輯xinetd的nrpe檔
# vi /etc/xinetd.d/nrpe
only_from = 192.168.10.111 <nagios監控主機的ip address>
# vi /etc/services
nrpe 5666/tcp # NRPE
[root@orix init.d]# chkconfig xinetd on
[root@orix init.d]# service xinetd restart
看 nrpe有沒有起來。
[root@orix init.d]# netstat -at | grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
Open Port 5666 on Firewall
#vi /etc/sysconfig/iptables
#service iptables restart
-A INPUT -m state –state NEW -m tcp -p tcp –dport 5666 -j ACCEPT
從nagios server 測試遠端監控的Linux伺服器
# /usr/local/nagios/libexec/check_nrpe -H 192.168.10.53
NRPE v2.13