您好,登錄后才能下訂單哦!
注意:兩端nrpe的版本要一致,不然無法相連接
NRPE總共由兩部分組成:
check_nrpe插件,運行在監控主機上。
NRPE daemon,運行在遠程的linux主機上(通常就是被監控機)
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 #默認自動添加了openssl
#因為傳送過程要加密,如果后面make報錯,加如下參數
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/(當然前提要有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既被監控的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個是默認的監控服務,如需自定義服務可在這里添加自定義服務可參考:http://saplingidea.javaeye.com/blog/514013
如有必要則需更改check閾值,在被監控端的/usr/local/nagios/etc/nrpe.cfg,下面會提到
|
chkconfig --add nagios #配置機器啟動時自動啟動Nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #檢查Nagios配置文件
vi /etc/selinux/config #關閉SELinux
SELINUX=disabled
service iptables stop #關閉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 (會自動加載SSL)
#如果后面make報錯,加如下參數
./configure --enable-ssl --with-ssl-lib=/usr/lib/(當然前提要有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
#上面這一步在本機上可以運行,如通過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
#服務端測試
/usr/local/nagios/libexec/check_nrpe -H l92.168.1.203
NRPE v2.8.1
#常見錯誤
/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進程再重啟就OK了
2./usr/local/nagios/libexec/check_nrpe -H 127.0.0.1
Connection refused by host
Nrpe進程沒有啟動
|
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閾值,如需更改,加減后面的數值即可 |
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。