Different result in web interface and command line

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
dfox
Posts: 3
Joined: Wed Jul 02, 2014 11:12 am

Different result in web interface and command line

Post 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!
Last edited by tmcdonald on Mon Jul 07, 2014 10:09 am, edited 2 times in total.
Reason: I split the post. Just because the symptoms are similar, the cause could be completely different. Lets keep your issues and our trouble shooting seperate from the other OP.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Different result in web interface and command line

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
dfox
Posts: 3
Joined: Wed Jul 02, 2014 11:12 am

Re: Different result in web interface and command line

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Different result in web interface and command line

Post 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$
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.
dfox
Posts: 3
Joined: Wed Jul 02, 2014 11:12 am

Re: Different result in web interface and command line

Post by dfox »

Everyone,

Thanks for your questions and suggestions. We got Nagios running the script! (There was a typo in a lib path :oops: )
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Different result in web interface and command line

Post by tmcdonald »

Closing thread.
Former Nagios employee
Locked