-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_pcs
134 lines (119 loc) · 2.86 KB
/
check_pcs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
CRM="sudo /usr/sbin/crm_mon -1 -r -f"
GREP="/bin/grep"
PROGNAME=`/usr/bin/basename $0`
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
REVISION="0.1"
. $PROGPATH/utils.sh
print_usage() {
echo "Usage : $PROGNAME [action]"
echo "Actions:"
echo " maintenance: Checks if maintenance property is set to true"
echo " move : Checks if there are manually moved resources"
echo " failed : Checks if there are failed actions"
echo " stop : Checks if there are stopped resources"
echo ""
echo "Usage : $PROGNAME --help"
echo "Usage : $PROGNAME --version"
}
print_help() {
print_revision $PROGNAME $REVISION
echo ""
print_usage
echo ""
echo "pacemaker/corosync status reporter for nagios"
echo ""
support
}
check_maintenance() {
if $CRM configure show | $GREP 'maintenance-mode="true"' > /dev/null; then
echo "WARNING: Maintenance Mode is active..."
exit $STATE_WARNING
else
echo "OK: Maintenance Mode is inactive..."
exit $STATE_OK
fi
}
check_move() {
if $CRM configure show | $GREP 'location cli-prefer' > /dev/null; then
echo "WARNING: Manual move is active..."
exit $STATE_WARNING
else
echo "OK: Manual move is inactive..."
exit $STATE_OK
fi
}
check_failed() {
if $CRM status | awk '/Failed Actions/ {seen = 1} seen {print}' | $GREP -v 'Failed actions:' > /dev/null; then
echo "WARNING: Failed actions present..."
exit $STATE_WARNING
else
echo "OK: No failed actions present..."
exit $STATE_OK
fi
}
check_stop() {
if $CRM configure show | grep Stop > /dev/null; then
echo "CRITICAL: Stopped resources present..."
exit $STATE_CRITICAL
else
echo "OK: No stopped resources present..."
exit $STATE_OK
fi
}
check_connection() {
if ! $CRM configure show > /dev/null; then
echo "CRITICAL: could not connect to CRM..."
exit $STATE_CRITICAL
fi
}
# Make sure the correct number of command line
# arguments have been supplied
if [ $# -lt 1 ]; then
print_usage
exit $STATE_UNKNOWN
fi
exitstatus=$STATE_UNKNOWN #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
;;
maintenance)
check_connection
check_maintenance
;;
move)
check_connection
check_move
;;
failed)
check_connection
check_failed
;;
stop)
check_connection
check_stop
;;
*)
echo "Unknown argument: $1"
print_usage
exit $STATE_UNKNOWN
;;
esac
shift
done
exit $exitstatus