Betr.: Re: [Nagios-users] Is this possible: Debugging Nagios -- logging commands and their exit codes.
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 [EMAIL PROTECTED] 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:[EMAIL PROTECTED] Sent: 25 April 2006 12:16 To: nagios-users@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 -efUnagios 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=lnkkid=120709bid=263057dat=121642 ___ Nagios-users mailing list Nagios-users@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
RE: [Nagios-users] Is this possible: Debugging Nagios -- logging commands and their exit codes.
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:[EMAIL PROTECTED] Sent: 25 April 2006 12:16 To: nagios-users@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 -efUnagios 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=lnkkid=120709bid=263057dat=121642 ___ Nagios-users mailing list Nagios-users@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=lnkkid=120709bid=263057dat=121642 ___ Nagios-users mailing list Nagios-users@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
RE: [Nagios-users] Is this possible: Debugging Nagios -- logging commands and their exit codes.
Deborah Martin [EMAIL PROTECTED] 25-4-2006 13:49:58 As an example, if you run the following command-line from wherever you have the plugins installed :- ./check_ping -H localhost -w 3000.0,80% -c 5000.0,100% -p 1 you would get the following output which Nagios can understand :- PING OK - Packet loss = 0%, RTA = 0.16 ms You'd need to amend the -H, -w, -c and -p options to your requirements of course. Thanks for the info. As you also suggested I always start with the commandline. If that works (and only then) I put the commands in the .cfg files. Sometimes things go wrong and then it would be great to see what Nagios is actually executing. Hence logging what exacalty is executed and their exit status seems a good idea to start the debugging proces and figure out whats gooing on. --- 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=lnkkid=120709bid=263057dat=121642 ___ Nagios-users mailing list Nagios-users@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
Re: [Nagios-users] Is this possible: Debugging Nagios -- logging commands and their exit codes.
hi if you want to see exactly whats going on compile / configure your nagios with --enable-DEBUGALL Moshe Sharon On 4/25/06, Jan Bessels [EMAIL PROTECTED] wrote: Deborah Martin [EMAIL PROTECTED] 25-4-2006 13:49:58As an example, if you run the following command-line from wherever youhavethe plugins installed :-./check_ping -H localhost -w 3000.0,80% -c 5000.0 ,100% -p 1you would get the following output which Nagios can understand :-PING OK - Packet loss = 0%, RTA = 0.16 msYou'd need to amend the -H, -w, -c and -p options to your requirements of course.Thanks for the info. As you also suggested I always start with thecommandline. If that works (and only then)I put the commands in the.cfg files. Sometimes things go wrong and then it would be great to see what Nagios is actually executing. Hence logging what exacalty isexecuted and their exit status seems a good idea to start the debuggingproces and figure out whats gooing on.--- 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 easierDownload IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___ Nagios-users mailing listNagios-users@lists.sourceforge.nethttps://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
Re: [Nagios-users] Is this possible: Debugging Nagios -- logging commands and their exit codes.
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:[EMAIL PROTECTED] Sent: 25 April 2006 12:16 To: nagios-users@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 -efUnagios 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=lnkkid=120709bid=263057dat=121642 ___ Nagios-users mailing list Nagios-users@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