-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_IBM_DS_health.sh
executable file
·131 lines (118 loc) · 3.76 KB
/
check_IBM_DS_health.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
#########################################################
#
# Check state of IBM DS4x00 / 5x00 Health Status
#
# uses IBM SMclient package, tested with version 10.70 & 10.83
#
# created by Martin Moebius
#
# 05.10.2011 - 1.0 * initial version
#
# 28.11.2011 - 1.1 * added Status "Warning" instead of "Critical" in case of Preferred Path error
# * changed filtering of SMcli output to string based sed instead of position based awk
# * moved filtering of SMcli output to remove redundant code
# * more comments on code
#
# 06.02.2012 - 1.2 * added patch from user "cseres", better SMcli output parsing
#
# 03.09.2012 - 1.3 * filter controller clock sync warning from output
#
# 13.11.2012 - 1.4 * changed result parsing to fix "Unreadable sector" messages from DS3300/3400 not getting reported correctly
#
# 08.01.2012 - 1.5 * changed result parsing to fix "Battery Expiration" messages not getting reported correctly
# * added another wildcard entry in the nested "case"-statement to get at least a UNKNOWN response for any possible message
#
#########################################################
#SMcli location
COMMAND=/opt/IBM_DS/client/SMcli
# Define Nagios return codes
#
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
#Help output
#
print_help() {
echo ""
echo "IBM DS4x00/5x00 Health Check"
echo "the script requires IP of at least one DS4x00/5x00 Controller, second is optional"
echo ""
echo "Usage check_IBM_health.sh -a X.X.X.X -b X.X.X.X"
echo ""
echo " -h Show this page"
echo " -a IP of Controller A"
echo " -b IP of Controller B"
echo ""
exit 0
}
# Make sure the correct number of command line arguments have been supplied
#
if [ $# -lt 1 ]; then
echo "At least one argument must be specified"
print_help
exit $STATE_UNKNOWN
fi
# Grab the command line arguments
#
while [ $# -gt 0 ]; do
case "$1" in
-h | --help)
print_help
exit $STATE_OK
;;
-a | --ctrla)
shift
CTRLA_IP=$1
;;
-b | --ctrlb)
shift
CTRLB_IP=$1
;;
*)
echo "Unknown argument: $1"
print_help
exit $STATE_UNKNOWN
;;
esac
shift
done
# Check the health status via SMcli
#
##execute SMcli
RESULT=$($COMMAND $CTRLA_IP $CTRLB_IP -c "show storageSubsystem healthStatus;" -quick)
##filter unnecessary SMcli output
RESULT=$(echo $RESULT |sed 's/Performing syntax check...//g' | sed 's/Syntax check complete.//g' | sed 's/Executing script...//g' | sed 's/Script execution complete.//g'| sed 's/SMcli completed successfully.//g' | sed 's/The controller clocks in the storage subsystem are out of synchronization with the storage management station.//g' | sed 's/ Controller in Slot [AB]://g' | sed 's/Storage Management Station://g' | sed 's/\<[A-Za-z]\{3\}\>\s\<[A-Za-z]\{3\}\>\s[0-9]\{2\}\s[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\s\(CEST\|CET\)\s[0-9]\{4\}//g')
##check SMcli output to identfy error and report back to Nagios
case "$RESULT" in
*optimal*)
echo $RESULT
echo "OK"
exit $STATE_OK
;;
*failure*)
case "$RESULT" in
*failed*|*Failed*|*Unreadable*)
echo $RESULT
echo "CRITICAL"
exit $STATE_CRITICAL
;;
*preferred*|*Preferred*|*Expiration*)
echo $RESULT
echo "WARNING"
exit $STATE_WARNING
;;
*)
echo "Unkown response from SMcli: \" $RESULT \""
echo "UNKNOWN"
exit $STATE_UNKNOWN
;;
esac
;;
*)
echo "Unkown response from SMcli: \" $RESULT \""
echo "UNKNOWN"
exit $STATE_UNKNOWN
;;
esac