aboutsummaryrefslogtreecommitdiff
path: root/nagios-notification-switch
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-09-04 13:31:05 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-09-04 13:38:22 +1200
commite7b180da0f0e4eab3b7c2b08ba405654baf82588 (patch)
treec5349e668f9f8329c5a636889d05c979f7c77619 /nagios-notification-switch
parentRequire at least one host (diff)
downloadnagscripts-e7b180da0f0e4eab3b7c2b08ba405654baf82588.tar.gz
nagscripts-e7b180da0f0e4eab3b7c2b08ba405654baf82588.zip
Upgrading to latest version
These are sanitized from the versions we use at work, so maintaining them is becoming a bit of a pain. I may have to work out some reasonable submodule system.
Diffstat (limited to 'nagios-notification-switch')
-rwxr-xr-xnagios-notification-switch53
1 files changed, 53 insertions, 0 deletions
diff --git a/nagios-notification-switch b/nagios-notification-switch
new file mode 100755
index 0000000..a6c2507
--- /dev/null
+++ b/nagios-notification-switch
@@ -0,0 +1,53 @@
+#!/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