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.
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 »

I have some suggestions for you as I came across a similar problem a while ago.

My biggest tip is to perform ALL of your tests running as the nagios user, as this is how the monitoring engine is going to do it.

Code: Select all

su nagios
then do your tests

NOTE:
su - nagios
This is NOT how the monitoring engine executes the plugin.

Also, some programs detect that you are not running in a terminal session and require a special parameter to overcome this.
For example top requires the -b argument to run in batch mode:

Code: Select all

top -n 1 -b
Also, you might be missing some output if it is being redirected to STDERR instead of STDOUT.

You can append your command with 2>&1 to redirect STDERR to STDOUT.

Code: Select all

top -n 1 -b 2>&1
Finally, try breaking your code up and echoing the value of just one component. Trying it all in one line can lead to lots of frustration. Start with the first command along with the 2>&1 redirection and see what error you get. If that works add your pipe and next bit of code and test again.

Sorry I don't have a direct answer but these tips should help you pinpoint the problem.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
hafthanhf
Posts: 10
Joined: Sun Jun 22, 2014 10:42 am
Location: Hanoi
Contact:

Re: Different result in web interface and command line

Post by hafthanhf »

Thanks you all,
I've fixxed the problem.
I when I investigated the promblem come from expect plugin. U know, when I run expect plugin as nagios user, It gave me the wrong promblem, so I remove some "|" part in the show command that is spawn to destination routers. And it work.
Here is what I changed in expect script:
the old script:

Code: Select all

send "show bgp summary | find AS | except inet | no-more | except AS\n"
After editted:

Code: Select all

send "show bgp summary | no-more\n"
I don't know how the monitoring engine do when I added many "|" part in expect script but It gives wrong result.
Btw, I want to update this plugin to nagios exchange, but don't know how to remove the old plugin II posted before, plz tell me how :P
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Different result in web interface and command line

Post by lmiltchev »

If you are the original poster, you *should* be able to edit your post on the Nagios Exchange. Can you provide us with a link to the plugin? If you are not able to modify the listing, we can probably do it for you. Let me know if you need help with that.
Be sure to check out our Knowledgebase for helpful articles and solutions!
hafthanhf
Posts: 10
Joined: Sun Jun 22, 2014 10:42 am
Location: Hanoi
Contact:

Re: Different result in web interface and command line

Post by hafthanhf »

lmiltchev wrote:If you are the original poster, you *should* be able to edit your post on the Nagios Exchange. Can you provide us with a link to the plugin? If you are not able to modify the listing, we can probably do it for you. Let me know if you need help with that.
Thanks lmiltchev, I'll edit it myself , but, could you please remove the duplicate post of it, below is the link:
http://exchange.nagios.org/directory/Pl ... er/details
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Different result in web interface and command line

Post by lmiltchev »

Thanks lmiltchev, I'll edit it myself , but, could you please remove the duplicate post of it, below is the link:
http://exchange.nagios.org/directory/Pl ... er/details
Done.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked