3 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
5 # This file is free software; Holger Weiss gives unlimited permission to copy
6 # and/or distribute it, with or without modifications, as long as this notice is
9 # This program is distributed in the hope that it will be useful, but WITHOUT
10 # ANY WARRANTY, to the extent permitted by law; without even the implied
11 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # Note that this script uses non-standard date(1) extensions which aren't
14 # available on all systems. GNU date(1) provides them:
16 # http://www.gnu.org/software/coreutils/
21 send_nsca_args
=${SEND_NSCA_ARGS:+$SEND_NSCA_ARGS}
31 die
"Usage: $0 [-C <comment>] [-c <config-file>] [-H <host>] [-S <service>]"
34 date -d 'now' '+%s' 2>&1 |
grep '^[[:digit:]]*$' >/dev
/null \
35 || die
"$0: GNU date(1) or BSD date(1) is required"
37 while getopts C
:c
:e
:H
:hS
:s
: option
44 send_nsca_args
="${send_nsca_args:+$send_nsca_args }-c $OPTARG"
64 shift `expr $OPTIND - 1`
65 test $# -eq 0 || usage
67 host=${host:-`hostname -s`}
68 service
=${service:+$service}
69 start
=`date -d ${start:-'now'} '+%s'`
70 end
=`date -d ${end:-'+2 hours'} '+%s'`
71 author
=`getent passwd "$USER" | cut -d: -f5`
72 comment
=${comment:-"Submitted by send_nsca@`hostname -s`"}
76 printf '%b' "SCHEDULE_HOST_DOWNTIME;$host;$start;$end;1;0;0;$author;$comment\n" \
77 | send_nsca
-C $send_nsca_args
79 printf '%b' "SCHEDULE_SVC_DOWNTIME;$host;$service;$start;$end;1;0;0;$author;$comment\n" \
80 | send_nsca
-C $send_nsca_args
83 # vim:set joinspaces noexpandtab textwidth=80: