#!/bin/bash
#
# Script to define a downtime in NagiosXI for all monitored items (hosts and services)
#
# Requirements:
#
# This script is using a PHP programm "nagios_down.php" this programm should be placed under /usr/local/nagios/bin
# Additional the PHP is using a named pipe (nagios.cmd) which resides under /usr/local/nagios/var/rw
#
# Variable definitions
#
NAGIOS_BASE=/usr/local/nagios
NAGIOS_BIN=$NAGIOS_BASE/bin
NAGIOS_CONF=$NAGIOS_BASE/etc
NAGIOS_HOSTS=$NAGIOS_CONF/hosts
SCRIPTS=/root/scripts/servicewindow
COUNT=0
grep host_name $NAGIOS_HOSTS/*.cfg > $SCRIPTS/hostlist.tmp
for HOST in `awk '/host_name/ {print $3}' $SCRIPTS/hostlist.tmp`
do
echo -n "Defining downtime for all services ......"
$NAGIOS_BIN/nagios_down.php -h $HOST -s all -a nagiosadmin -c "Maintenance Window" -f -b "08/25/12 06:00" -e "08/26/12 18:00" > /dev/nul
l 2>&1
echo " on host: $HOST"
$NAGIOS_BIN/nagios_down.php -h $HOST -a nagiosadmin -c "Maintenance Window" -f -b "08/25/12 06:00" -e "08/26/12 18:00" > /dev/null 2>&1
let COUNT++
done
echo "Defined downtime for all services on $COUNT hosts"
Now if someone entered by accident the wrong date and time, is there a way to remove such worng downtime definitions?