Re: Different result in web interface and command line
Posted: Wed Sep 17, 2014 2:12 pm
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.
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:
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.
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.
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
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
You can append your command with 2>&1 to redirect STDERR to STDOUT.
Code: Select all
top -n 1 -b 2>&1
Sorry I don't have a direct answer but these tips should help you pinpoint the problem.