Page 1 of 1

Different result in web interface and command line

Posted: Wed Jul 02, 2014 12:05 pm
by dfox
I too am getting different results from the command line than from within Nagios for my perl plugin.

From CLI I get a line of text output and an exit value of 0 when I expect to; or a different line of text output and a value of 1 when I expect to; but when I go through commands.cfg and the Nagios web interface, it always returns with exit value of 2 [critical].

My CLI is the perl script with 4 arguments:

Code: Select all

./check-crawl.pl FQDN Port# Collection status
And I have set up a service command in ../nagios/etc/objects/commands.cfg to pass the same:

Code: Select all

 define command {
command_name crawl_status
command_line $USER1$/check_crawl.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$
}
With the command-line in the server's CFG file as:

Code: Select all

check_command crawler_status!FQDN!80!Collection!status
Any suggestions as to what I may have wrong in this set-up?

Thanks!

Re: Different result in web interface and command line

Posted: Wed Jul 02, 2014 4:33 pm
by Box293
When you test from the CLI, are performing this as the user nagios?

Code: Select all

su nagios
./check-crawl.pl FQDN Port# Collection status
This is the account the monitoring engine uses when it executes checks.

Re: Different result in web interface and command line

Posted: Thu Jul 03, 2014 7:59 am
by dfox
Thanks for replying. Yes, it runs successfully from the CLI using the nagios user.
I added some logging to my script and have discovered that the Nagios app is not even running my script (no logs generated). Have I missed a step in getting it added to command.cfg or somewhere else?

Re: Different result in web interface and command line

Posted: Thu Jul 03, 2014 2:23 pm
by abrist
The perl interpreter was removed from core 4. You may have to prefix the command with a full path to the perl bin:

Code: Select all

command_line /usr/bin/perl $USER1$/check_crawl.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$

Re: Different result in web interface and command line

Posted: Mon Jul 07, 2014 9:31 am
by dfox
Everyone,

Thanks for your questions and suggestions. We got Nagios running the script! (There was a typo in a lib path :oops: )

Re: Different result in web interface and command line

Posted: Mon Jul 07, 2014 10:09 am
by tmcdonald
Closing thread.