Page 1 of 1

[SOLVED] Return code 127 is out of bound

Posted: Thu Aug 06, 2015 3:28 am
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.

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

Posted: Thu Aug 06, 2015 9:41 am
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

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

Posted: Thu Aug 06, 2015 9:57 am
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 

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

Posted: Thu Aug 06, 2015 11:14 am
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.

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

Posted: Fri Aug 07, 2015 3:39 am
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.

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

Posted: Fri Aug 07, 2015 6:06 am
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
}