[SOLVED] Return code 127 is out of bound

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mc.dfb
Posts: 4
Joined: Wed Aug 05, 2015 4:37 am

[SOLVED] Return code 127 is out of bound

Post by mc.dfb »

Hi all,

Firstly, I apologize for my english, I know it's terrible.

As part of an IT project, I worked with Nagios.
In order to get the value of a temperature sensor, I create a python plugin that will read the value in a database, and print in on screen.

The problem is that when I want to monitor the service based on this plugin, it is displayed as "CRITICAL" in the web interface with error « (Return code 127 is out of bounds) plugin may be missing ».

Here is a summary of my installations :
  • I create a python plugin "cigne_plugin.py" that will read the value in a database, and print in on screen.
  • Added file "cigne_python.py" in /usr/local/nagios/libexec
    In file /usr/local/nagios/etc/resource.cfg, $USER1$ macro is define on /usr/local/nagios/libexec
  • In /usr/local/nagios/etc/checkcommands.cfg, I added these lines :

Code: Select all

define command{
		command_name		arduino_temp_sensor
		command_line		$USER1$/cigne_plugin.py
}
  • In /usr/local/nagios/etc/objects/commands.cfg, I added these line:

Code: Select all

define command{
		command_name		arduino_temp_sensor
		command_line		$USER1$/cigne_plugin.py
}
  • In /usr/local/nagios/etc/objects/localhost.cfg :

Code: Select all

define service{
		use				local-service
		host_name			localhost
		service_description		Arduino Temp
		check_command		        arduino_temp_sensor
		notification_enabled		0
		}
    • Add command "arduino_temp_sensor" in the Web Interface (Configuration -> Commands)
    • Add service "Arduino Temp" in the Web Interface (Configuration -> Services)
    • Check the files rights
    • Check that the script can be execute
    • Check the files owners
    • Check users and groups
    In/usr/local/nagios/etc/services.cfg, my service is create for "localhost"

    I tried with a plugin version commenting all the code, and that only do a « sys.exit(2) », problem is not from the code.

    Thank you for any help, have a nice day.
Last edited by mc.dfb on Fri Aug 07, 2015 6:07 am, edited 1 time in total.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Return code 127 is out of bound : Plugin may be missing

Post by tgriep »

Can you run the following and post back the results?

Code: Select all

ll /usr/local/nagios/libexec
su nagios
/usr/local/nagios/libexec/cigne_plugin.py
Be sure to check out our Knowledgebase for helpful articles and solutions!
mc.dfb
Posts: 4
Joined: Wed Aug 05, 2015 4:37 am

Re: Return code 127 is out of bound : Plugin may be missing

Post by mc.dfb »

Code: Select all

defab@nagios:/usr/local/nagios/libexec$ ll /usr/local/nagios/libexec/
bash: ll: command not found
defab@nagios:/usr/local/nagios/libexec$ su nagios 
Password: 
nagios@nagios:/usr/local/nagios/libexec$ /usr/local/nagios/libexec/cigne_plugin.py
bash: /usr/local/nagios/libexec/cigne_plugin.py: /usr/bin/python^M: bad interpreter: No such file or directory 
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Return code 127 is out of bound : Plugin may be missing

Post by jdalrymple »

Make sure that the interpreter (/usr/bin/python it would appear) listed in the #! line of /usr/local/nagios/libexec/cigne_plugin.py exists and is executable by user nagios. If python isn't there, adjust the #! line as needed:

Code: Select all

which python
should locate python for you.
mc.dfb
Posts: 4
Joined: Wed Aug 05, 2015 4:37 am

Re: Return code 127 is out of bound : Plugin may be missing

Post by mc.dfb »

Code: Select all

defab@nagios:/usr/local/nagios/libexec$ which python
/usr/bin/python
This is what i've already put in my file.
mc.dfb
Posts: 4
Joined: Wed Aug 05, 2015 4:37 am

Re: Return code 127 is out of bound : Plugin may be missing

Post by mc.dfb »

EDIT : I just solved the problem :
The command did'nt know where was python interpretor,
so I had modify my command definition in file "/usr/local/nagios/etc/commands.cfg", as in the command definition in the Web interface :

Code: Select all

define command{
		command_name		arduino_temp_sensor
		command_line		/usr/bin/python $USER1$/cigne_plugin.py
}
Locked