Betr.: Re: Is this possible: Debugging Nagios -- logging commands and their exit codes.
Jan Bessels
j.bessels at degelderseroos.nl
Wed Apr 26 09:32:31 CEST 2006
Thanks everybody for the responses. Turns out what I want isn't standard
in Nagios. Have no time to build a debugging wrapper myself. Last night
I again checked the NagiosExchange site AND
http://www.nagiosexchange.org/Utilities.16.0.html?&tx_netnagext_pi1[p_view]=273
!!. Exactlly what I need, goin to implement this. Turns out I overlooked
this GEM last few times I visited the site. One could do worse then
really look carefully at the content of this site...
Jan Bessels
>>> Kurt Yoder <ktynagios at richard-group.com> 25-4-2006 15:53:41 >>>
Also ensure you are running the command using the same environment
that nagios is using. For instance, if your nagios process runs as
user "nagios", you should `su - nagios` before running the command.
That will allow you to exactly replicate what is happening when
nagios attempts to run the command.
For things like check_by_ssh this can be especially crucial, since
the ssh command is using authentication keys, etc from the local
user. If you have set up ssh with trusted keys from your standard
account but not from nagios, you may be able to run the command
perfectly well with your own account, but the nagios user will not be
able to.
I do like the idea of a "debugging wrapper" for executing nagios
commands though. If you find out more about such a thing or write one
yourself, please follow up to the list and/or post it to
nagiosexchange, etc.
On Apr 25, 2006, at 7:40 AM, Deborah Martin wrote:
> 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
-------------------------------------------------------
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