Nagios: check_snmp monitor script

monitoringnagiossnmp

I'm trying to monitor a specific script that runs on my box with snmp. The script runs multiple times with multiple paramaters like so

/usr/bin/perl /opt/data/script.pl -m test

or

/usr/bin/perl /opt/data/script.pl -d

I've tried utlizing the –string paramater with check_snmp but I haven't had any luck.

./check_snmp -H server01 -C public --string="/usr/bin/perl /opt/data/script.pl -m test"

This is what the script looks like when I do a snmpwalk:

HOST-RESOURCES-MIB::hrSWRunParameters.675 = STRING: "/opt/data/script.pl -m test"

Obviously I can't monitor the OID since it's specific to the PID. So basically -o HOST-RESOURCES-MIB::hrSWRunParameters.675 = PID of 675

Best Answer

We use check_snmp_process.pl, which does the job nicely for us.

define command {
        command_name    check_at_least_one_proc
        command_line    $USER1$/check_snmp_process.pl -H $HOSTADDRESS$ -C your-community-here -n $ARG1$ -c 0
}
define command {
        command_name    check_only_one_proc
        command_line    $USER1$/check_snmp_process.pl -H $HOSTADDRESS$ -C your-community-here -n $ARG1$ -c 0,2
}
define command {
        command_name    check_proc_range
        command_line    $USER1$/check_snmp_process.pl -H $HOSTADDRESS$ -C your-community-here -n $ARG1$ -c $ARG2$,$ARG3 -w $ARG2$,$ARG3$
}

define service {
        use                             generic-service
        hostgroup_name                  snmpenabled
        service_description             NTP
        check_command                   check_at_least_one_proc!ntpd
}