Page 1 of 2

Return code of 127 is out of bounds - plugin may be missing

Posted: Tue Mar 03, 2015 8:40 am
by paulol
hi everyone,

I have tested the following script in ruby in command line:

Code: Select all

#!/usr/bin/env ruby

used_space=`df -h / | grep -v "Filesystem" | awk '{print $5}'`
 case used_space.chomp <=> "85%"
 when -1
   puts "OK - #{used_space.chomp!} of disk space used."
   exit 0
 when 0
   puts "WARNING - #{used_space.chomp!} of disk space used."
   exit 1
 when 1
   puts "CRITICAL - #{used_space.chomp!} of disk space used."
   exit 2
 else
   puts "UNKNOWN - #{used_space.chomp!} of disk space used."
   exit 3
end
And it works:

Code: Select all

[root@teste libexec]# ./check_teste.rb 
OK - 15% of disk space used.
but when i add this service on nagios xi, i receive the following error:

(Return code of 127 is out of bounds - plugin may be missing)

nagios.log

Code: Select all

[1425389629] Warning: Return code of 127 for check of service 'teste' on host 'DOUAI' was out of bounds. Make sure the plugin you're trying to run actually exists.
file permission

Code: Select all

[root@teste libexec]# ls -la check_teste.rb
-rwxr-xr-x 1 root nagios 432 Mar  3 10:36 check_teste.rb

[root@teste libexec]# pwd
/usr/local/nagios/libexec
Obs: I looked other threads, but i didnt found any solution.

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 9:52 am
by jdalrymple
Can we see the Common Settings tab from the service definition for teste --> CCM, Services, teste

also your associated command definition (in the Check command field) from that service? --> CCM, Commands, "check_something"

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 10:02 am
by paulol
Follows the image.

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 10:24 am
by jolson
What happens when you test the plugin as the nagios user at the CLI?

I like to make sure that selinux is not meddling with things:

Code: Select all

sestatus

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 10:39 am
by paulol

Code: Select all

[root@DOUAI ~]# sestatus
SELinux status:                 disabled
Script executed using nagios user on linux cli.

Code: Select all

[nagios@DOUAI libexec]$ ./check_teste.rb 
OK - 15% of disk space used.
Follows image executed on nagios xi (nothing happens):

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 11:05 am
by jdalrymple
Can the nagios user execute the ruby binary?

Code: Select all

ll `which ruby`

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 11:21 am
by paulol

Code: Select all

[nagios@DOUAI libexec]$ ll `which ruby`
-rwxr-xr-x 1 root root 19174942 Mar  3 09:15 /usr/local/bin/ruby
Yes

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 12:08 pm
by tgriep
Can you run the following and post back the results?

Code: Select all

ll /usr/local/nagios/libexec/check_teste.rb

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 12:20 pm
by paulol

Code: Select all

[nagios@DOUAI libexec]$ ll /usr/local/nagios/libexec/check_teste.rb
-rwxr-xr-x 1 root nagios 432 Mar  3 10:36 /usr/local/nagios/libexec/check_teste.rb

Re: Return code of 127 is out of bounds - plugin may be miss

Posted: Tue Mar 03, 2015 12:31 pm
by abrist
Does the top of the file include the ruby shabang?

Code: Select all

head /usr/local/nagios/libexec/check_teste.rb