aboutsummaryrefslogtreecommitdiff
path: root/nagios-unhandled-list
blob: 92909cc367a751f6e46e228bfb8d8e11627319b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash

#
# nagios-unhandled-list(1) -- List all the hosts and services in a problem state,
# handled or not
#
#   $ 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