forked from jantman/nagios-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_icinga_config.sh
executable file
·112 lines (101 loc) · 2.68 KB
/
check_icinga_config.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /bin/bash
#
# Icinga check to check icinga configuration
#
# Useful when generating configs through Puppet, to warn
# if config is in a bad state that prevents reload/restart
#
###################################################################################
#
# The latest version of this script lives at:
# <https://github.com/jantman/nagios-scripts/blob/master/check_icinga_config.sh>
#
# Please file bug/feature requests and submit patches through
# the above GitHub repository. Feedback and patches are greatly
# appreciated; patches are preferred as GitHub pull requests, but
# emailed patches are also accepted.
#
# Copyright 2014 Jason Antman <[email protected]> all rights reserved.
# See the above git repository's LICENSE file for license terms (GPLv3).
###################################################################################
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
PROGNAME=`basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION="1.0.0"
. $PROGPATH/utils.sh
ICINGA_BIN='/usr/bin/icinga'
ICINGA_CONF='/etc/icinga/icinga.cfg'
VERBOSE=0
DEBUG=0
print_usage() {
echo "Usage: $PROGNAME [-c /path/to/icinga.cfg] [--icinga-bin /path/to/icinga]" [--ignore-fault]
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "This plugin checks hardware status using the lm_sensors package."
echo ""
support
exit $STATE_OK
}
exitstatus=$STATE_WARNING #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
--version)
print_revision $PROGNAME $REVISION
exit $STATE_OK
;;
-V)
print_revision $PROGNAME $REVISION
exit $STATE_OK
;;
-c)
ICINGA_CONF=$2
shift
;;
-b)
ICINGA_BIN=$2
shift
;;
-v)
VERBOSE=1
shift
;;
-vv)
VERBOSE=1
DEBUG=1
shift
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
cmd="$ICINGA_BIN -v $ICINGA_CONF"
output=$($cmd 2>&1)
retval=$?
if [ $VERBOSE -eq 1 ]; then
echo "'$cmd' returned $retval"
fi
if [ $DEBUG -eq 1 ]; then
echo "Output:\n$output"
fi
if [ $retval -eq 0 ]; then
echo "OK: Icinga configuration test of $ICINGA_CONF passed"
exit $STATE_OK
fi
echo "CRITICAL: Icinga configuration test of $ICINGA_CONF failed - daemon will not reload/restart"
exit $STATE_CRITICAL