Page 2 of 2
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 12:34 pm
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
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 12:42 pm
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.
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 12:52 pm
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
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 1:05 pm
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.
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 2:03 pm
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]
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 2:08 pm
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.
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 2:14 pm
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.
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)
Re: Return code of 127 is out of bounds - plugin may be miss
Posted: Tue Mar 03, 2015 2:38 pm
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.