Page 1 of 2

NOOB: (Return code of 127 is out of bounds - plugin may be

Posted: Sun Apr 10, 2016 2:06 am
by McHenry
I am a new user and have some basic monitoring working. I am interested in getting the following printer plugin working:
https://exchange.nagios.org/directory/P ... ck/details

The response I received for both services is:
"(Return code of 127 is out of bounds - plugin may be missing)"


I have checked the $USER1$ variable to confirm the plugin path:

root@apollo:~# grep "USER1" /etc/nagios3/resource.cfg
# Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$)
# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/lib/nagios/plugins


The plugin is located in the correct location:

root@apollo:~# ls -l /usr/lib/nagios/plugins/check_snmp_printer.sh
-rwxr-xr-x 1 root root 32658 Mar 28 12:50 /usr/lib/nagios/plugins/check_snmp_printer.sh


in /etc/nagios3/command.cfg I have the following:

define command{
command_name check_snmp_printer
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS -C $ARG1$ -x $ARG2 -w $ARG3$ -c $ARG4$
}


In /etc/nagios3/objects/printers.cfg I have the following two services defined:

define service{
use generic-service
hostgroups hp-printers ; The name of the host the service is associated with
service_description Toner Supply
check_command check_snmp_printer!public!"CONSUM Toners"!20!10
}

define service{
use generic-service
hostgroups hp-printers ; The name of the host the service is associated with
service_description Paper Supply
check_command check_snmp_printer!public!"TRAY ALL"!25%!0%
}


Any help would be greatly appreciated. Thanks in advance...

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 12:16 am
by rhassing
Do you have selinux enabled?

Code: Select all

getenforce
You should disable it

Code: Select all

setenforce 0

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 6:45 am
by McHenry
Thanks Rob. SELinux was already disabled.

root@apollo:~# getenforce
Disabled
root@apollo:~#

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 9:55 am
by rhassing
What happens if you run the command from the command line?

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 10:19 am
by rkennedy

Code: Select all

root@apollo:~# ls -l /usr/lib/nagios/plugins/check_snmp_printer.sh
-rwxr-xr-x 1 root root 32658 Mar 28 12:50 /usr/lib/nagios/plugins/check_snmp_printer.sh
You'll want to adjust the permissions accordingly, as having this file owned by root can lead to issues. Take a look at what everything else is set to in that folder.

If you run the check over the CLI, does it work fine?

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 2:03 pm
by McHenry
Hi Rob and thanks once again. The file permissions are the same as the others in the folder:

root@apollo:/usr/lib/nagios/plugins# ls -l check_s*
-rwxr-xr-x 1 root root 1453 Mar 13 2014 check_sensors
lrwxrwxrwx 1 root root 9 Mar 13 2014 check_simap -> check_tcp
-rwxr-xr-x 1 root root 64216 Mar 13 2014 check_smtp
-rwxr-xr-x 1 root root 72936 Mar 13 2014 check_snmp
-rwxr-xr-x 1 root root 32658 Mar 28 12:50 check_snmp_printer.sh
lrwxrwxrwx 1 root root 9 Mar 13 2014 check_spop -> check_tcp
-rwxr-xr-x 1 root root 43384 Mar 13 2014 check_ssh
lrwxrwxrwx 1 root root 9 Mar 13 2014 check_ssmtp -> check_tcp
-rwxr-xr-x 1 root root 43240 Mar 13 2014 check_swap


From the CLI it appears to run fine.

root@apollo:/usr/lib/nagios/plugins# ./check_snmp_printer.sh -V
check_snmp_printer.sh - version 3.14159
root@apollo:/usr/lib/nagios/plugins# ./check_snmp_printer.sh -H 192.1.1.152 -C public -x MODEL
"Canon LBP6300 1.01", Serial #

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 3:21 pm
by McHenry
I did find an error in the command definition whereby it was missing two "$" I have now updated it from:

define command{
command_name check_snmp_printer
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS -C $ARG1$ -x $ARG2 -w $ARG3$ -c $ARG4$
}

to

define command{
command_name check_printers
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2$ -w $ARG3$ -c $ARG4$
}

I have also updated my service checks to use the new command name "check_printers":

define service{
use generic-service
hostgroups hp-printers ; The name of the host the service is associated with
service_description Paper Supply
check_command check_printers!public!"TRAY ALL"!25%!0%
}

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 3:51 pm
by hsmith
Is this working correctly after you made those changes?

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 3:58 pm
by McHenry
Unfortunately not.

I have restarted the server however the error remains.

Re: NOOB: (Return code of 127 is out of bounds - plugin may

Posted: Mon Apr 11, 2016 4:01 pm
by rkennedy
The permissions should not be root:root, they should be set to the user / group you're going to execute them as. For reference, did you follow some sort of guide when installing your plugins?