aboutsummaryrefslogtreecommitdiff
path: root/nagios-unhandled-list
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-06-20 13:08:15 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-06-20 13:08:15 +1200
commitcdc34fa78b326bd241aae7399190c739e25bf025 (patch)
tree2d12fdf161b74dcde13baf33bb46f0137f443952 /nagios-unhandled-list
parentRemove silly symlinks (diff)
downloadnagscripts-mk-livestatus.tar.gz
nagscripts-mk-livestatus.zip
Update to latest version with MKLivestatusmk-livestatus
No longer using NDOUtils at work, these are much nicer and more likely to work with any given Nagios installation now anyway. Added nagios-data-search, nagios-downtstream-list, nagios-exists, nagios-problem-list, and nagios-unhandled-list.
Diffstat (limited to 'nagios-unhandled-list')
-rwxr-xr-xnagios-unhandled-list65
1 files changed, 65 insertions, 0 deletions
diff --git a/nagios-unhandled-list b/nagios-unhandled-list
new file mode 100755
index 0000000..d5d97fd
--- /dev/null
+++ b/nagios-unhandled-list
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+
+#
+# nagios-unhandled-list(1) -- List all unhandled hosts and services in a
+# problem state.
+#
+# $ npl
+#
+# Author: Tom Ryder <tom@sanctum.geek.nz>
+# Copyright: 2016
+#
+
+# Name self
+self=nagios-unhandled-list
+
+# Usage printing function
+usage() {
+ printf 'USAGE: %s [-h]\n' "$self"
+}
+
+# By default we search hosts, not services
+services=0
+
+# Handle options, just -h help at the moment
+OPTIND=1
+while getopts 'h' opt ; do
+ case "$opt" in
+ h)
+ usage
+ exit 0
+ ;;
+ '?')
+ usage >&2
+ exit 1
+ ;;
+ esac
+done
+shift "$((OPTIND-1))"
+
+# Any arguments after that are abuse
+if (($#)) ; then
+ usage >&2
+ exit 1
+fi
+
+# Define the path to the Livestatus socket
+socket=${MK_LIVESTATUS_SOCKET:-/usr/local/nagios/var/rw/live}
+
+unixcat "$socket" <<EOF | sort -V
+GET hosts
+Columns: host_name
+Filter: state != 0
+Filter: state != 3
+Filter: acknowledged = 0
+Filter: scheduled_downtime_depth = 0
+EOF
+unixcat "$socket" <<EOF | sort -V
+GET services
+Separators: 10 47 44 124
+Columns: host_name description
+Filter: state != 0
+Filter: state != 4
+Filter: acknowledged = 0
+Filter: scheduled_downtime_depth = 0
+EOF