user10396478
user10396478

Reputation: 11

Warning: Return code of 127 for check of service was out of bounds. Make sure the plugin you're trying to run actually exists

I'm trying to use the phanton-js plugin for Nagios: https://github.com/hggh/phantomjs-nagios

but despite me double checking the set-up, I'm getting "Return code 127 is out of bounds : Plugin may be missing"

The plugin file exists in the plugins folder:

# stat /usr/lib64/nagios/plugins/check_http_load_time.rb
  File: `/usr/lib64/nagios/plugins/check_http_load_time.rb'
  Size: 9108            Blocks: 24         IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 275201      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

I can execute it when su'd to the nagios user locally:

-bash-4.1$ whoami
nagios
-bash-4.1$ /usr/lib64/nagios/plugins/phantomjs-nagios/check_http_load_time.rb -u https://google.com -w 2 -c 3
OK: https://google.com load time: 0.43

This is how it is defined in the checkcommands.cfg file:

define command {
        command_name    check_web_page_load_time
        command_line    $USER1$/check_http_load_time.rb -u $ARG1$ -w $ARG2$ -c $ARG3$
        }

and this is the service definition

define service {
  use                   generic-service
  host_name             test_host
  service_description   https://google.com web load time
  check_command         check_web_page_load_time!https://google.com!2!3
  contact_groups        support-emails
}

I've restarted nagios and confirmed that the config check passes.

Am I missing something obvious?

edit:

plugin file is located in 2 folders:

/usr/lib64/nagios/plugins/check_http_load_time.rb

and

/usr/lib64/nagios/plugins/phantomjs-nagios/check_http_load_time.rb

both files are identical, both can be executed by the nagios user successfully and neither location works with command definition. I tried calling it with full path and with the $USR1$ variable, which points to the standard location where all the other plugins are located

/usr/lib64/nagios/plugins/

Upvotes: 0

Views: 3759

Answers (1)

user10396478
user10396478

Reputation: 11

Manged to eventually solve it. The error message was not very helpful, as problem was with the environment variables of the nagios user. The original script had the following shebang:

#!/usr/bin/env ruby

After changing it to the actual location of ruby binary the script works:

#!/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby

Still surprised that it worked when su'd to the Nagios user.

Upvotes: 1

Related Questions