Is this possible: Debugging Nagios -- logging commands and their exit codes.

Deborah Martin Deborah.Martin at Kognitio.com
Tue Apr 25 13:40:01 CEST 2006


Have you tried manually running the plugin on the command-line ? 

'No output' usually means Nagios doesn't get a result back that it
understands. 

A manual test of the plugin may tell you why... 

-----Original Message-----
From: Jan Bessels [mailto:j.bessels at degelderseroos.nl]
Sent: 25 April 2006 12:16
To: nagios-users at lists.sourceforge.net
Subject: [Nagios-users] Is this possible: Debugging Nagios -- logging
commands and their exit codes.


Using Nagios 2.1. When adding things to the .cfg files sometimes things
go wrong. The output of a plugin is then for example  'No output'. This
is NOT very usefull at all. It would be usefull to see which cmd is
really being executed. Am I missing here something or.....

Older msgs on the mailinglist (don't know for which versiion) suggest
trying to log things usings commands like 'ps -efU<nagios PID> or top
and putting things in a logfile. Doesn't workl that well for me.

The only thing I can come up with is the following. Hopefully you can
provide me with a better solution.....

Extending the command_line option for a command.

define command {
     command_name check_ping
     command_line  <command_to_exec>
}

When I change  it to the following I get things logged in a logfile

define command {
     command_name check_ping
   command_line  /bin/echo "<command_to_exec> " >> /tmp/ping.log
}

Of course this is NOT a very good solution. Though  the commands you
want to log is added to the logfile but the command is NOT executed. 
UNFORTUNATELY the following is NOT possible.

command_line  <command_to_exec> ; echo "<command_to_exec> " >>
/tmp/ping.log

Everything after the ; is removed be Nagios (checked objects.cache). 

The only thing I can imagine which hopefully  wil do the trick is the
followig.

define command {
     command_name check_ping
     command_line /user/home/jbessels/log_and_exec_cmd.sh
"<command_to_exec> " 
}

The log_and_exec_cmd.sh script should do the following:

Parse the commandline args  supplied to  log_and_exec_cmd.sh  to get
the cmd to execute (will be called $cmd)
echo "$cmd" >> /tmp/logfile
execute $cmd and store contents in pluginoutput variable
store exit code of cmd run in returncode variable
echo $pluginoutput variable >> /tmp/logfile

echo $pluginout 
exit $returncode

The last two lines are crucial I think. Because command_line has to
return an ascii string and and exitcode.

Does perhaps anyone have created such a script. If so I would be VERY
happy if you could supply me with it. Haven't that much time to figure
it all out......

If what I do is nonsense and can be accomplished in a better way I
would like to know also.....

PS.  I had hoped Nagios would have had support for this kind of things
out of the box, but maybe I didn't RTFM thoroughly enough.....

Grtz,
Jan Bessels






-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

************************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. Any unauthorised distribution or copying is strictly 
prohibited.

Whilst Kognitio Limited takes steps to prevent the transmission of 
viruses via e-mail, we can not guarantee that any email or 
attachment is free from computer viruses and you are strongly
advised to undertake your own anti-virus precautions.

Kognitio grants no warranties regarding performance,
use or quality of any e-mail or attachment and undertakes no 
liability for loss or damage, howsoever caused.
***********************************************************************



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list