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

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

Post by paulol »

Yes

#!/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
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 »

I presume the exit codes are correct:

Code: Select all

/usr/local/nagios/libexec/check_teste.rb
echo $?
Note: We may want to move to a remote to continue to troubleshoot this.
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.
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]$ /usr/local/nagios/libexec/check_teste.rb
OK - 15% of disk space used.
[nagios@DOUAI libexec]$ echo $?
0
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 »

I did a quick lab and got good results. I wonder if maybe we shouldn't have you delete your existing command and service so that we can eliminate the possibility of any funky whitespaces or special characters we can't see?

Code: Select all

Nagios XI Installation Complete!

You can access the Nagios XI web interface by visiting:
    http://localhost/nagiosxi/

[jdalrymple@localhost nagiosxi]$ cd /usr/local/nagios/libexec
[jdalrymple@localhost libexec]$ sudo vi ruby.sh
[sudo] password for jdalrymple:
[jdalrymple@localhost libexec]$ sudo yum -y install ruby
<--snip-->
[jdalrymple@localhost libexec]$ cat ruby.sh
#!/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
[jdalrymple@localhost libexec]$ sudo chmod +x ./ruby.sh
[jdalrymple@localhost libexec]$ ./ruby.sh
OK -
/ of disk space used.
[jdalrymple@localhost libexec]$ echo $?
0
Also, is there any reason you're opting to use a custom script instead of the builtin check_disk plugin? I'm happy to troubleshoot the problem as it stands, however the check_disk plugin is quite robust and reliable.
You do not have the required permissions to view the files attached to this post.
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 »

jdalrymple,

I figured out, i installed ruby 2.1.5 via source. Nagios xi does not have integration with ruby 2.1.5 yet?

It works because i installed via "yum install ruby" same like you. But now the version is 1.8.7.

[root@DOUAI install]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

paulol wrote:jdalrymple,
Nagios xi does not have integration with ruby 2.1.5 yet?
Nagios XI doesn't pre-install ruby of any proportion, however you can install it and then use Ruby plugins.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
cmerchant
Posts: 546
Joined: Wed Sep 24, 2014 11:19 am

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

Post by cmerchant »

I'm not sure if the problem was with the source install, but a similar problem existed with another forum post that had same return code 127.

http://support.nagios.com/forum/viewtop ... 802#p90193 and their solution was also to install via yum. Must set up the library paths differently.

It would have been interesting to look at if the dynamic paths available with the source install of Ruby.

Code: Select all

ldd /usr/local/bin/ruby
which for /usr/bin/ruby looked like this:

Code: Select all

ldd /usr/bin/ruby
	linux-vdso.so.1 =>  (0x00007fffb2f6d000)
	libruby.so.1.8 => /usr/lib64/libruby.so.1.8 (0x00007f307dc39000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f307da1c000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f307d813000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f307d60f000)
	libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f307d3d8000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f307d153000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f307cdbf000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f307cba9000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f307df49000)
	libfreebl3.so => /lib64/libfreebl3.so (0x00007f307c9a5000)
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 »

Now it works!!!

I installed ruby version 2.1.5.
Solution: Make a simbolic link from dir /usr/local/bin/ruby to /usr/bin/ruby .

Thks all.
Locked