-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcheck_pacemaker_config.sh
73 lines (65 loc) · 1.42 KB
/
check_pacemaker_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
#!/bin/sh
# Exit codes for crm_verify:
# 0 - Config is ok
# 1 - Config had Errors
# 2 - Parse errors in XML
# 3 - Could not connect to Live CIB
check_ok() {
MSG="${MSG} OK:"
NUM_WARN=`echo $OUTPUT | fgrep -c "WARN"`
NUM_ERROR=`echo $OUTPUT | fgrep -c "ERROR"`
if [ $NUM_WARN -ne 0 ]; then
MSG="${MSG} running configuration warnings: ${NUM_WARN}"
fi
if [ $NUM_ERROR -ne 0 ]; then
MSG="${MSG} running configuration errors(non-fatal): ${NUM_ERROR}"
fi
if [ $NUM_WARNING -eq 0 -a $NUM_ERROR -eq 0 ]; then
MSG="${MSG} no warnings or errors"
fi
echo "${MSG}"
exit 0
}
check_not_ok() {
MSG="${MSG} CRITICAL:"
if [ $OUTPUT = "sudo: /usr/sbin/crm_verify: command not found" ]; then
MSG="${MSG} pacemaker is not installed"
fi
NUM_ERROR=`echo $OUTPUT | fgrep -c "ERR"`
NUM_WARN=`echo "$OUTPUT" | fgrep -c "WARN"`
if [ $NUM_ERROR -ne 0 ]; then
MSG="${MSG} running configuration errors: ${NUM_ERROR}"
fi
if [ $NUM_WARN -ne 0 ]; then
MSG="${MSG} running configuration warnings: ${NUM_WARN}"
fi
echo "${MSG}"
exit 1
}
check_unknown() {
MSG="${MSG} WARNING: Unknown status of config"
echo "${MSG}"
exit 2
}
check_could_not_complete() {
MSG="${MSG} CRITICAL: could not connect to live CIB"
echo "${MSG}"
exit 1
}
MSG="PACEMAKER"
IFS=
OUTPUT="`sudo /usr/sbin/crm_verify -L -V 2>&1`"
case $? in
0)
check_ok
;;
1)
check_not_ok
;;
3)
check_could_not_complete
;;
*)
check_unknown
;;
esac