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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

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

Post 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.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

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

Post 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"
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

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

Post by paulol »

Follows the image.
You do not have the required permissions to view the files attached to this post.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

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

Post 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
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

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

Post 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):
You do not have the required permissions to view the files attached to this post.
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

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

Post by jdalrymple »

Can the nagios user execute the ruby binary?

Code: Select all

ll `which ruby`
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

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

Post 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
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post by tgriep »

Can you run the following and post back the results?

Code: Select all

ll /usr/local/nagios/libexec/check_teste.rb
Be sure to check out our Knowledgebase for helpful articles and solutions!
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

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

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post by abrist »

Does the top of the file include the ruby shabang?

Code: Select all

head /usr/local/nagios/libexec/check_teste.rb
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked