2011年10月5日 星期三

nagios linux nrpe設定(3)使用nagios-plugins

參考
http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf
http://www.debianhelp.co.uk/nagiospluins.htm

比較:
nagios server端:192.168.1.2 ,已在web server根目錄放 index.html 的 nagios server端
client 端:192.168.1.133,web server根目錄沒東西,check_http 正常會回應 403 Forbidden

兩者在 nrpe.cfg 都沒定義  check_http ,但 command-plugins.cfg 有command[check_http]



nagios server端:
nagiosserver~]# /usr/lib64/nagios/plugins/check_http -H 192.168.1.2
HTTP OK: HTTP/1.1 200 OK - 45327 bytes in 0.011 second response time |time=0.010650s;;;0.000000 size=45327B;;;0
nagiosserver~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.133 -c check_http
NRPE: Command 'check_http' not defined
nagiosserver~]# /usr/lib64/nagios/plugins/check_http -H 192.168.1.133
HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.067 second response time |time=0.067473s;;;0.000000 size=5240B;;;0



若從 client端跑 check_http
[root@CentOS5 ~]# /usr/lib64/nagios/plugins/check_http -H 192.168.1.133
HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.008 second response time |time=0.008368s;;;0.000000 size=5240B;;;0
[root@CentOS5 ~]# /usr/lib64/nagios/plugins/check_http -H 192.168.1.2
HTTP OK: HTTP/1.1 200 OK - 45327 bytes in 0.015 second response time |time=0.014984s;;;0.000000 size=45327B;;;0


若從 client端跑 check_nrpe ...沒安裝
[root@CentOS5 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.2 check_http
-bash: /usr/lib64/nagios/plugins/check_nrpe: No such file or directory
[root@CentOS5 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.75.133 check_http
-bash: /usr/lib64/nagios/plugins/check_nrpe: No such file or directory

======================================================================
*使用 plugins 裡的 check_disk

在 client 端的 /etc/nagios/nrpe.cfg 裡加上
command[check_sda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
command[check_sda2]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda2

nagios server端:
[root@nagiosserver nagios]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.2 check_sda1
Connection refused by host
[root@nagiosserver nagios]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.133 check_sda1
NRPE v2.12
[root@nagiosserver nagios]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.1.133 -c check_sda1
DISK OK - free space: /boot 81 MB (86% inode=99%);| /boot=12MB;78;88;0;98


在 servier 端的 /etc/nagios/objects/linux-client.cfg 裡加上(記得 restart nagios)
define service{
        use      generic-service
        host_name               CentOS5.5-1
        service_description     Check checksda1
        check_command check_nrpe!check_sda1
        }

define service{
        use      generic-service
        host_name               CentOS5.5-1
        service_description     Check checksda2
        check_command check_nrpe!check_sda2


======================================================================
*使用 plugins 裡的 check_ssh
在 client 端的 /etc/nagios/nrpe.cfg 裡加上(記得 restart nrpe)
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh 127.0.0.1


在 servier 端的 /etc/nagios/objects/linux-client.cfg 裡加上(記得 restart nagios)

define service{
        use                     generic-service
        host_name               CentOS5.5-1
        service_description     Check SSH
        check_command           check_nrpe!check_ssh
        }


沒有留言:

張貼留言

BloggerAds