0

I have written a custom nagios plugin which is returning a command not defined error. I have not yet placed the command in nrpe.cfg or defined the service, etc as this is controlled by puppet and any failure sends an sms to all the tech staff every 5 minutes.

I think I should be able to test it from the command line before doing so. Here is output from terminal on ubuntu 14.04 which illustrates my problem.

nagios@myserver:/usr/lib/nagios/plugins$ ./check_nrpe -H localhost -c check_users
USERS OK - 2 users currently logged in |users=2;5;5;0

nagios@myserver:/usr/lib/nagios/plugins$ ./check_nrpe -H localhost -c disk_usage.rb
NRPE: Command 'disk_usage.rb' not defined

nagios@myserver:/usr/lib/nagios/plugins$ ./disk_usage.rb
OK - '/backups' 84% of disk space used | '/'=37% '/tmp'=1% '/srv'=62% '/backups'=84% 
2

For any custom NRPE command to work, you need to add an additional command definition for it in your local NRPE config (usually /etc/nagios/nrpe_local.cfg), like:

command[disk_usage]=/usr/lib/nagios/plugins/disk_usage.rb

Then restart NRPE and try again with:

check_nrpe -H localhost -c disk_usage
  • Thanks - do I need to add a service description and hostgroup for this as well? I want to add only the minimum to be able to test it from the command line without nagios applying the command. – markhorrocks Feb 5 '16 at 16:20
  • As long as you don't add the check to any host, Nagios won't check it anywhere. But this still allows you to run the script manually using check_nrpe. – Oldskool Feb 5 '16 at 16:36
  • I still get command disk_usage.rb not defined. If I add the -n option I get CHECK_NRPE: Error receiving data from daemon. – markhorrocks Feb 5 '16 at 21:06
  • My terminal call was using the file name not the command name – markhorrocks Feb 5 '16 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.