Plugin works via commandline, but not in Nagios


I found a plugin to check various SNMP stats for IBM Bladecenters. The script works perfectly via command line, but once it gets inside the Nagios config it returns “CRITICAL: (null)”. Any ideas? I’ve tried various different ideas in the commands.cfg file, with no luck. More details below (of course, SNMP community information and IP addresses have been redacted…)

commands.cfg entries:

[code]define command{
command_name check_bladecenter
command_line $USER1$/ -H $HOSTADDRESS$ -C $ARG1$ -t $ARG2$

define command{
command_name check_bc_amb_temp
command_line /usr/local/nagios/libexec/ -H $HOSTADDRESS$ -C $ARG1$ -w $ARG2$ -c $ARG3$ -t System-Temp-Ambient

Windows.cfg file:

[code]define service{
use stat-service
host_name bladecenter
service_description System State
check_command check_bladecenter!!!System-State
normal_check_interval 5
retry_check_interval 1
servicegroups stats

define service{
use stat-service
host_name bladecenter
service_description Ambient Temperature
check_command check_bc_amb_temp!!!2000!3000
normal_check_interval 5
retry_check_interval 1
servicegroups temperature
icon_image proctemp.png

Results when run via commandline:

[[email protected] libexec]$ ./ -H XXX.XXX.XXX.XXX -C ?????? -t System-State OK System-State (255) Normal [[email protected] libexec]$ ./ -H XXX.XXX.XXX.XXX -C ?????? -w 2000 -c 3000 -t System-Temp-Ambient OK System-Temp-Ambient (1850) 18.50 Centigrade


Just realized you guys might want the proper syntax from the actual command:

[code]$ ./ -h v$Revision: 1.0 $ (nagios-plugins 1.4.14)
The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
copies of the plugins under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
Copyright © 2006 Eric Schultz [email protected]

SNMP IBM Bladecenter plugin for Nagios

Usage: -H -C <snmp_community> -t <test_name> -n ] -w ,] -c ,] -o ]
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host’s SNMP agent
-w, --warning=INTEGER
percent of disk used to generate WARNING state (Default: 99)
-c, --critical=INTEGER
percent of disk used to generate CRITICAL state (Default: 100)
-T, --test-help=TEST NAME
print Test Specific help for A Specific Test
-t, --test=TEST NAME
test to run
-n, --ele-number=ELEMEMNT NUM
Number of blade/blower/power module


    Blower-Speed <1|2>






i’d try something like this.

make a script which calls your plugin with the -v switch (verbose) send the output to a file like /tmp/myoutput, have the script called from crontab and keep all consoles closed while the file is run.

check the output, probably there’s some user configuration missing… using -v might show what it is :slight_smile:


I tried running it from my script before I added the cronjob, but I got an error. Just for fun, I tried running the script from another folder, and it got the same error–I’m thinking this is what the issue is.
If I run the program from its containing folder, it works perfectly. Ex:

In ~/Desktop:

$ /usr/local/nagios/libexec/ -H -C nagios -t System-State -v Can't locate in @INC (@INC contains: /opt/nagios/libexec /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at /usr/local/nagios/libexec/ line 13. BEGIN failed--compilation aborted at /usr/local/nagios/libexec/ line 13.
In /usr/local/nagios/libexec:

$ ./ -H -C nagios -t System-State -v OK System-State (255) Normal


See if this helps:

in particualr: Add use lib ‘.’ or use lib ‘/path/to’ at the top of your script.



That fixed it, thanks!
This is probably why I almost failed my Perl class…:slight_smile:


Happy it worked. :slight_smile: