<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Balloon Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
span.BalloonTextChar
{mso-style-name:"Balloon Text Char";
mso-style-priority:99;
mso-style-link:"Balloon Text";
font-family:"Tahoma","sans-serif";}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle21
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle23
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:#1F497D;}
span.EmailStyle24
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>In terminal logged in as nagios, check executed successfully but problem arise when I reschedule the service and it gets to OK state.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Is there any problem in executing custom checks using GUI.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>How can I execute custom checks from GUI.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Looking forward to your reply.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Regards<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Muhammad Haseeb<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Martin Hugo [mailto:Martin_Hugo@hboe.org] <br><b>Sent:</b> Friday, August 26, 2011 6:56 PM<br><b>To:</b> 'Nagios Users List'<br><b>Subject:</b> Re: [Nagios-users] Problem Executing Passive Checks<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='color:#1F497D'>Try the check from terminal as the same user as GUI and see what happens.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Marty<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Muhammad Haseeb <a href="mailto:[mailto:haseeb@carepvtltd.com]">[mailto:haseeb@carepvtltd.com]</a> <br><b>Sent:</b> Friday, August 26, 2011 9:11 AM<br><b>To:</b> Nagios Users List<br><b>Subject:</b> Re: [Nagios-users] Problem Executing Passive Checks<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='color:#1F497D'>Yes, I used terminal as root user and from GUI script executed logged in nagios.log file.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Martin Hugo <a href="mailto:[mailto:Martin_Hugo@hboe.org]">[mailto:Martin_Hugo@hboe.org]</a> <br><b>Sent:</b> Friday, August 26, 2011 5:52 PM<br><b>To:</b> 'Nagios Users List'<br><b>Subject:</b> Re: [Nagios-users] Problem Executing Passive Checks<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='color:#1F497D'>A GUI instigated check may run under a different username than that used in a terminal script. Were you root in terminal?<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Marty<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Muhammad Haseeb <a href="mailto:[mailto:haseeb@carepvtltd.com]">[mailto:haseeb@carepvtltd.com]</a> <br><b>Sent:</b> Friday, August 26, 2011 8:05 AM<br><b>To:</b> Nagios Users List<br><b>Subject:</b> Re: [Nagios-users] Problem Executing Passive Checks<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='color:#1F497D'>Can anyone solve my problem. I am waiting for reply.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Muhammad Haseeb <a href="mailto:[mailto:haseeb@carepvtltd.com]">[mailto:haseeb@carepvtltd.com]</a> <br><b>Sent:</b> Thursday, August 25, 2011 2:37 PM<br><b>To:</b> <a href="mailto:nagios-users@lists.sourceforge.net">nagios-users@lists.sourceforge.net</a><br><b>Subject:</b> [Nagios-users] Problem Executing Passive Checks<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I want to get information for hosts and services when user needs it using Service Command - Re-schedule the next check of this service in Nagios GUI. I write submit command in commands.cfg and in services.cfg I define passive service which is used that command as check command. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I used the sample script provided by Nagios for sending commands to Nagios. Script successfully execute in terminal but when I initiate from Nagios GUI using Reschedule Service Command, it gets executed and after that it gets to OK state with (null) plugin output every time as shown in below nagios logs.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I used the nagios 3.2.2, nagios pugins 1.4.15 and Fedora 12 32bit.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Following is the configuration, nagios log file and sample scripts.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b>Commands.cfg<o:p></o:p></b></p><p class=MsoNormal><b><o:p> </o:p></b></p><p class=MsoNormal>define command{<o:p></o:p></p><p class=MsoNormal> command_name passive_check<o:p></o:p></p><p class=MsoNormal> command_line /$USER1$/submit_check_result $HOSTNAME$ "$SERVICEDESC$" $ARG1$<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b>Services.cfg<o:p></o:p></b></p><p class=MsoNormal><b><o:p> </o:p></b></p><p class=MsoNormal>define service {<o:p></o:p></p><p class=MsoNormal> use generic-service ; your template<o:p></o:p></p><p class=MsoNormal> host_name anjum<o:p></o:p></p><p class=MsoNormal> service_description passive_test<o:p></o:p></p><p class=MsoNormal> is_volatile 1 ; every change is logged ...<o:p></o:p></p><p class=MsoNormal> max_check_attempts 1 ; a change is after only 1 try ...<o:p></o:p></p><p class=MsoNormal> active_checks_enabled 0 ; unset template's default ...<o:p></o:p></p><p class=MsoNormal> passive_checks_enabled 1 ; ditto ...<o:p></o:p></p><p class=MsoNormal> check_freshness 0<o:p></o:p></p><p class=MsoNormal> freshness_threshold 300<o:p></o:p></p><p class=MsoNormal> notification_options n ; no notifications ...<o:p></o:p></p><p class=MsoNormal> check_command passive_check <o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b>Sample Script<o:p></o:p></b></p><p class=MsoNormal><b><o:p> </o:p></b></p><p class=MsoNormal>echocmd="/bin/echo"<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>CommandFile="/usr/local/nagios/var/rw/nagios.cmd"<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal># get the current date/time in seconds since UNIX epoch<o:p></o:p></p><p class=MsoNormal>datetime=`date +%s`<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal># create the command line to add to the command file<o:p></o:p></p><p class=MsoNormal>cmdline="[$datetime] PROCESS_SERVICE_CHECK_RESULT;$1;$2;$3;$4"<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal># append the command to the end of the command file<o:p></o:p></p><p class=MsoNormal>`$echocmd $cmdline >> $CommandFile`<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><b>Log file<o:p></o:p></b></p><p class=MsoNormal><b><o:p> </o:p></b></p><p class=MsoNormal>[1314265019] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;anjum;passive_test;1314265018<o:p></o:p></p><p class=MsoNormal>[1314265019] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;anjum;passive_test;1;haseeb<o:p></o:p></p><p class=MsoNormal>[1314265029] PASSIVE SERVICE CHECK: anjum;passive_test;1;haseeb<o:p></o:p></p><p class=MsoNormal>[1314265029] SERVICE ALERT: anjum;passive_test;WARNING;HARD;1;haseeb<o:p></o:p></p><p class=MsoNormal>[1314265029] SERVICE ALERT: anjum;passive_test;OK;HARD;1;(null)<o:p></o:p></p><p class=MsoNormal>[1314265236] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;anjum;passive_test;1314265235<o:p></o:p></p><p class=MsoNormal>[1314265236] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;anjum;passive_test;1;haseeb<o:p></o:p></p><p class=MsoNormal>[1314265239] PASSIVE SERVICE CHECK: anjum;passive_test;1;haseeb<o:p></o:p></p><p class=MsoNormal>[1314265239] SERVICE ALERT: anjum;passive_test;WARNING;HARD;1;haseeb<o:p></o:p></p><p class=MsoNormal>[1314265239] SERVICE ALERT: anjum;passive_test;OK;HARD;1;(null)<o:p></o:p></p><p class=MsoNormal><b><o:p> </o:p></b></p><p class=MsoNormal>As mention in above log, after executing my passive check, service alert is raised and suddenly another service alert with OK state and (null) plugin output is raised and visible in Nagios GUI.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Looking forward for quick response.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Regards<o:p></o:p></p><p class=MsoNormal>Muhammad Haseeb<o:p></o:p></p><p class=MsoNormal>Software Engineer<o:p></o:p></p></div></body></html>