<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>I just realized I don't have to use NSCA to do this at all. 
I rewrote my script to simply push the information it gets from Nagios back to 
Nagios. In case anyone needs to configure something similar, below is my 
setup:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>SCRIPT</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>---------------------------------------------</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>#!/bin/bash</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>########################################################################################<BR>#Script 
requires 2 parameters to function with a 2 optional ones. From the 
information<BR>#parameters, only STATUS and OUTPUT are necessary to function. 
HOST/SERVICE are for 
logs<BR>########################################################################################</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>#Log info variables<BR>SCRIPTNAME=$0</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>LOGDIR=<BR>LOGFILE=${LOGDIR}/${SCRIPTNAME}/${SCRIPTNAME}_`date 
'+%m%d%Y'`.log"<BR>SCRIPTDIR=</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>#Information 
parameters<BR>HOST=$1<BR>SERVICE=$2<BR>STATUS=$3<BR>OUTPUT=$4</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>#Check if log file exists. If it doesn't, create it and 
give everyone permissions<BR>#the last part is necessary so other users calling 
this script can log commands also<BR>if [ ! -e $LOGFILE ]; 
then</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2> echo 
"###########################################################################################" 
>> $LOGFILE<BR> echo "# script (${SCRIPTDIR}) log file for `date 
'+%m/%d/%Y'`" >> $LOGFILE<BR> echo -e 
"###########################################################################################\n\n" 
>> $LOGFILE<BR> chmod a+w $LOGFILE</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>fi</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>#Log the values passed for parameters<BR>echo $(date) 
>> $LOGFILE<BR>echo -e "$HOST\t$SERVICE\t$STATUS\t$OUTPUT\n" >> 
$LOGFILE</FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>#Send the output back to Nagios via echo command and exit 
with the specified STATUS<BR>echo "$OUTPUT"<BR>exit 
$STATUS<BR>--------------------------------------------------</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>COMMAND DEFINITION</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>--------------------------------------------------</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2># run this for EOD checks that need to reset 
state<BR>define command{<BR>        
command_name    
reset_state<BR>        
command_line    /app/edeliver/nagiosTEST/libexec/reset_state 
$HOSTNAME$ $SERVICEDESC$ -1 
"Reset...`date`"<BR>        
}</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>--------------------------------------------------</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>SERVICE DEFINITION</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>--------------------------------------------------</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>I then have the service template with a check_period set to 
a specific timeperiod. That period is set to run (in my case) Monday to Friday 
between 11:54-11:59PM (enough time for all my checks to go through). Just 
so a service wouldn't run it's command twice, I set the check_intervals to 5 
minutes which would pass the alloted timeperiod for this check command to 
run.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff 
size=2>--------------------------------------------------</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=156344417-06062007><FONT face=Arial 
color=#0000ff size=2>So basically the command runs and returns the status/output 
specified by that service check command back to that 
service.</FONT></SPAN></DIV>
<DIV dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr align=left><FONT face=Tahoma size=2><B>From:</B> 
nagios-users-bounces@lists.sourceforge.net 
[mailto:nagios-users-bounces@lists.sourceforge.net] <B>On Behalf Of </B>Sapon, 
Dimitry<BR><B>Sent:</B> Wednesday, June 06, 2007 9:56 AM<BR><B>To:</B> 
nagios-users@lists.sourceforge.net<BR><B>Subject:</B> [Nagios-users] Scheduled 
service state resets<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial size=2>Hi 
there,</FONT></SPAN></DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial size=2>I have an 
interesting requirement to fulfill. I have about 100 passive only service checks 
that need to be reset (currently to Unknown state) at a specified time of day 
(currently midnight). The reason they need this done is to be able to easily 
tell if the passive checks have occured on that day (because they return either 
one of the three other possible states).</FONT></SPAN></DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial size=2>I came up with two 
possibilities of doing this: crontab or enable active service checks 5 minute 
before midnight for those services, and use a command that sends a 
notification to the service using send_nsca. </FONT></SPAN><SPAN 
class=243042513-06062007><FONT face=Arial size=2>Here are the ups and downs of 
each approach:</FONT></SPAN></DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial 
size=2><U>Crontab</U></FONT></SPAN></DIV>
<DIV><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Pros</FONT></SPAN></DIV>
<UL>
  <LI dir=ltr style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT 
  face=Arial size=2>Simple to setup scheduling</FONT></SPAN> 
  <LI dir=ltr style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT 
  face=Arial size=2>Can run multiple scripts easily</FONT></SPAN> 
  <LI dir=ltr style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT 
  face=Arial size=2>Control over the entire reset state process (once crond gets 
  the script going)</FONT></SPAN></LI></UL>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Cons</FONT></SPAN></DIV>
<UL>
  <LI style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
  size=2>Cumbersome to configure which services need to be notified (need to 
  implement my own config file separate from Nagios, create logic in bash to 
  read it, update it everytime there is a change 
etc.)</FONT></SPAN></LI></UL>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2><U>Nagios Command through active checks</U></FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Pros</FONT></SPAN></DIV>
<UL>
  <LI style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
  size=2>Simple to setup scheduling</FONT></SPAN> 
  <LI style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
  size=2>Logic for which services to reset is easily configurable through 
  service template definitions used for those services. Changes in the future 
  are easily made and done in one place as opposed to two with the crontab 
  version.</FONT></SPAN></LI></UL>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Cons</FONT></SPAN></DIV>
<UL>
  <LI style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
  size=2>By having Nagios send out parameters to a script that runs a send_nsca 
  command via an "active check" method, Nagios expects the check to return 
  information back to it. The "active check" basically returns an OK (Hard) 
  state with the output being the commands I passed to my script. A few seconds 
  later, Nagios processes the send_nsca command and changes to the new state 
  (Unknown in this case). So as you see, Nagios goes through 2 hard state 
  changes and two possible notifications. Now I will disable notifications on 
  unknown but I do have it setup to notify on recovery as people need to get 
  emails when a passive check returns an OK state. So with this method they'll 
  get a notification at midnight for every service setup like 
  that basically because it's been reset. Even if I could get away with not 
  having to send any notifications other than the two other hard non-OK states, 
  it still doesn't make sense to bombard Nagios with an extra state change for 
  every service setup. Just spells bad news if this ever needs to be scaled 
  imo.</FONT></SPAN></LI></UL>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2><U>Conclusion</U></FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>I was very happy with setup 2 until I discovered that major con. That's 
the rason I stated that with the crontab I have full control over the entire 
process (other than what's handled by the other daemons necessary for crontab to 
work). I really don't feel like setting up a separate process, script, and 
config files, causing multiple locations to be updated to handling 
something so simple. I'm hoping I overlooked some easier solution that you 
guys can recommend.</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Waiting to hear back from you...</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2></FONT></SPAN> </DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Regards,</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=243042513-06062007><FONT face=Arial 
size=2>Dimitry</FONT></SPAN></DIV><PRE>_______________________________________________________________________

This email is intended only for the use of the individual(s) to whom it is addressed and may be privileged and confidential.
Unauthorised use or disclosure is prohibited. If you receive This e-mail in error, please advise immediately and delete the original message. 
This message may have been altered without your or our knowledge and the sender does not accept any liability for any errors or omissions in the message.

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. 
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courriel par erreur, veuillez m'en aviser immédiatement, par retour de courriel ou par un autre moyen.</PRE><pre>_______________________________________________________________________

This email is intended only for the use of the individual(s) to whom it is addressed and may be privileged and confidential.
Unauthorised use or disclosure is prohibited. If you receive This e-mail in error, please advise immediately and delete the original message. 
This message may have been altered without your or our knowledge and the sender does not accept any liability for any errors or omissions in the message.

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. 
Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite.
Si vous recevez ce courriel par erreur, veuillez m'en aviser immédiatement, par retour de courriel ou par un autre moyen.</pre></BODY></HTML>