blob: a6c250702e63d70b373ee036f8d8e0fa0f161a45 (
plain) (
tree)
|
|
#!/usr/bin/env bash
#
# nagios-notification-switch(1) -- Turn notifications off or on globally.
#
# $ nns on
# $ nns off
#
# Author: Tom Ryder <tom@sanctum.geek.nz>
# Copyright: 2016
#
# Name self
self=nagios-notification-switch
# Usage printing function
usage() {
printf 'USAGE: %s [on|off]\n' "$self"
}
# If no args, exit with usage help
if ! (($#)) ; then
usage >&2
exit 1
fi
# Figure out what to do based on first argument
case $1 in
# Give help in the form of usage information if requested
-h|--help)
usage
;;
# Set notifications on
on)
printf '[%lu] ENABLE_NOTIFICATIONS\n' "$(date +%s)" \
> "${NAGCMD_FILE:-/usr/local/nagios/var/rw/nagios.cmd}"
;;
# Set notifications off
off)
printf '[%lu] DISABLE_NOTIFICATIONS\n' "$(date +%s)" \
> "${NAGCMD_FILE:-/usr/local/nagios/var/rw/nagios.cmd}"
;;
# Didn't understand the argument; say so and dump usage to stderr
*)
printf 'Unknown argument :%s\n' "$1"
usage >&2
exit 1
;;
esac
|