<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Anthony Montibello wrote:
<blockquote
 cite="mid:c4515bfd0905151953y6f3bcac4j93a25bd4554f96df@mail.gmail.com"
 type="cite">
  <div>I always use a daily cron script/s to setup Downtime schedual to
handle that issue.</div>
  <div>the flexable downtime, may be better if the hosts always recover
within X min while Fixed is better if you know the host will go down at
X and e back up at Y </div>
  <div> </div>
  <div><a moz-do-not-send="true"
 href="http://nagios.sourceforge.net/docs/3_0/downtime.html">http://nagios.sourceforge.net/docs/3_0/downtime.html</a></div>
  <div> </div>
</blockquote>
Here is a script that I use that schedules downtime for a host/service<br>
You could run it out of your backup pre-script<br>
Modify it for your needs<br>
<br>
#!/bin/bash<br>
#<br>
# This script is used to submit downtime to Nagios<br>
# see the usage function for info on how to use it<br>
<br>
. /opt/maj/standard<br>
<br>
#================================ CONFIG
=====================================<br>
# location of nagios config file<br>
nagios_cfg=/etc/nagios/nagios.cfg<br>
echocmd="/bin/echo"<br>
<br>
# get the current date/time in seconds since UNIX epoch<br>
datetime=`date +%s`<br>
<br>
author="$0"<br>
<br>
#--------------------------------- AUTO CONFIG
-------------------------------<br>
# you should not need to change this<br>
# get the name of the nagios command file<br>
nagios_cmd=`awk -F= '/^command_file/ {print $2}' $nagios_cfg`<br>
if [ ! -p "$nagios_cmd" ]; then<br>
   echo "Got Nagios CMD file as \"$nagios_cmd\" and it is not a valid
command file"<br>
   exit 1<br>
fi<br>
<br>
#================================ FUNCTIONS
=====================================<br>
#--------------------------------------------------------------------------------<br>
usage ()<br>
{<br>
cat << EOT<br>
Usage: $0 -h HOST -s SERVICENAME -c COMMENT -a "STARTTIME" -b "ENDTIME"<br>
<br>
where<br>
HOST        is the name of the host that this downtime is for<br>
SERVICENAME is the name of the service that this downtime is for<br>
            This is optional. If excluded we schedule downtime for the
host<br>
COMMENT     is the comment associated with the downtime<br>
STARTTIME   format is the same as accepted by the date --date=STRING
command<br>
            eg "now", "+30 minutes", "6 months 15 day", "2007-09-01
16:00:00"<br>
ENDTIME     as for STARTTIME<br>
<br>
EOT<br>
exit 1<br>
}<br>
#--------------------------------------------------------------------------------<br>
write_to_cmd_file () {<br>
# create the command line to add to the command file<br>
# sample format:<br>
#
SCHEDULE_SVC_DOWNTIME;mail.optusnet.com.au;SMTP;1188879530;1188880130;1;0;7200;Matthew
Jurgens;COMMENT<br>
<br>
# if $servicename is set it will supply its own ;<br>
cmdline="\[$datetime\]
$downtime_cmd;$host;$servicename$starttime_sec;$endtime_sec;1;0;$duration;$author;$comment"<br>
 <br>
# append the command to the end of the command file<br>
`$echocmd $cmdline >> $nagios_cmd`<br>
}<br>
#--------------------------------------------------------------------------------<br>
#--------------------------------------------------------------------------------<br>
#--------------------------------------------------------------------------------<br>
#--------------------------------------------------------------------------------<br>
#================================ MAIN
=====================================<br>
<br>
# ---------- GET Options<br>
[ $# -ge 1 ] || usage<br>
<br>
# Check for options<br>
while getopts h:s:c:a:b: OPT<br>
do<br>
   case $OPT in<br>
   h)<br>
      host=$OPTARG<br>
      ;;<br>
   s)<br>
      servicename=$OPTARG<br>
      ;;<br>
   c)<br>
      comment=$OPTARG<br>
      ;;<br>
   a)<br>
      starttime=$OPTARG<br>
      ;;<br>
   b)<br>
      endtime=$OPTARG<br>
      ;;<br>
   *)<br>
      usage<br>
      ;;<br>
   esac<br>
done<br>
shift `expr $OPTIND - 1`<br>
<br>
if [ -z "$host" -o -z "$comment" -o -z "$starttime" -o -z "$endtime" ];
then<br>
   usage<br>
fi<br>
<br>
if [ -z "$servicename" ]; then<br>
   # we schedule downtime for the host<br>
   downtime_cmd="SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME"<br>
else <br>
   # we schedule downtime for the service<br>
   downtime_cmd="SCHEDULE_SVC_DOWNTIME"<br>
   <br>
   # add a ; to the end of the servicename so that it fits the correct
syntax<br>
   servicename="$servicename;"<br>
fi<br>
<br>
<br>
# convert starttime and endtime to seconds<br>
starttime_sec=`date --date="$starttime" +'%s'`<br>
endtime_sec=`date --date="$endtime" +'%s'`<br>
<br>
if [ "$starttime_sec" -a "$endtime_sec" ]; then<br>
<br>
   # work out the duration<br>
   let duration=endtime_sec-starttime_sec<br>
<br>
   write_to_cmd_file<br>
else <br>
   echo "ERROR:Starttime or Endtime date format not correct"<br>
fi<br>
<br>
<br>
<div class="moz-signature">-- <br>
<font size="2"><font face="Verdana">
<a href="http://www.smartmon.com.au">Smartmon System Monitoring</a><br>
<a class="moz-txt-link-abbreviated" href="http://www.smartmon.com.au">www.smartmon.com.au</a>
</font></font></div>
</body>
</html>