首页 > 代码库 > check_snmp插件

check_snmp插件



nagios-snmp插件:

http://cpan.metacpan.org/authors/id/D/DT/DTOWN/Net-SNMP-v6.0.1.tar.gz

http://nagios-snmp.cvs.sourceforge.net/viewvc/nagios-snmp/plugins

check_snmp_load.pl
check_snmp_mem.pl
check_snmp_process.pl
check_snmp_storage.pl



被监控端:

$ sudo apt-get install snmpd

$ sudo vi /etc/snmp/snmpd.conf  (在Access Control下写,它上面部分全删除,除下面内容外Access Control其余部分也删除)

按a或i进入编辑模式

com2sec readuser default   public     (注意此处community为public,可改)

group  readgroup v1   readuser
group  readgroup v2c   readuser

view    systemview  included  .1.3.6.1.2.1.1
view    systemview  included  .1.3.6.1.2.1.25.1
view    all       included   .1

access   readgroup ""   any    noauth  exact  all none  none

按ESC退出编辑模式

:wq (保存并退出)

$ sudo servcie snmpd restart



监控端:


$ tar zxfv Net-SNMP-v6.0.1.tar.gz

$ cd Net-SNMP-v6.0.1

$ perl Makefile.PL

$ sudo make

$ sudo make install

$ sudo rsync -av --progress chech_snmp_* /usr/local/nagios/libexec/

$ cd /usr/local/nagios/libexec/

$ sudo vi check_snmp_mem.pl +469

$resultat = (Net::SNMP->VERSION gt 4) ?  (默认为$resultat = (Net::SNMP->VERSION < 4) ? )

:wq

$ ./check_snmp_mem.pl -H ming  -C public -w 70,80 -w 70,90  (内存、swap)

$ sudo vi check_snmp_load.pl +681

my $resultat = (Net::SNMP->VERSION gt 4) ?  (默认为my $resultat = (Net::SNMP->VERSION < 4) ? )

:wq

$ ./check_snmp_load.pl -H ming -C public  -w 70 -c 90  

$ sudo vi /usr/local/nagios/libexec/check_snmp_process.pl +410

$resultat = (Net::SNMP->VERSION gt 4) ?  (默认为$resultat = (Net::SNMP->VERSION < 4) ? )

:wq

$ sudo vi /usr/local/nagios/libexec/check_snmp_process.pl +554

$resultat = (Net::SNMP->VERSION gt 4) ?  (默认为$resultat = (Net::SNMP->VERSION < 4) ? )

:wq


$ ./check_snmp_process.pl -H ming -C public -n java -c 0  (-n后面跟进程名,小于等于0 critical,我这里省掉了-w)


$ sudo vi /usr/local/nagios/libexec/check_snmp_storage.pl +420

if (Net::SNMP->VERSION gt 4) { (默认为if (Net::SNMP->VERSION < 4) { )

:wq

$ sudo vi /usr/local/nagios/libexec/check_snmp_storage.pl +494

if (Net::SNMP->VERSION gt 4) { (默认为if (Net::SNMP->VERSION < 4) { )

:wq





$ sudo vi /usr/local/nagios/etc/objects/commands.cfg


define command{
         command_name   check_snmp_mem
         command_line   $USER1$/check_snmp_mem.pl -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$
         }


define command{
         command_name   check_snmp_load
         command_line   $USER1$/check_snmp_load.pl -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$
         }

define command{
         command_name   check_snmp_storage
         command_line   $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C $ARG1$ -m $ARG2$ -w $ARG3$ -c $ARG4$
         }

define command{
         command_name   check_snmp_process
         command_line   $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$ -c $ARG3$
         }


:wq

$ sudo vi /usr/local/nagios/etc/objects/ming.cfg


define service{
        use          local-service
        host_name    ming
        service_description   check_snmp_mem
        check_command         check_snmp_mem!public!70,80!70,90
        }


define service{
        use          local-service
        host_name    ming
        service_description   check_snmp_load
        check_command         check_snmp_load!public!70!90
        }

define service{
        use          local-service
        host_name    ming
        service_description   check_snmp_storage
        check_command         check_snmp_storage!public!/home!90!95
        }

define service{
        use          local-service
        host_name    ming
        service_description   check_snmp_process
        check_command         check_snmp_process!public!java!0
        }

:wq


$ sudo service nagios restart

本文出自 “linux” 博客,谢绝转载!