-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest3par.sh
executable file
·364 lines (328 loc) · 12.9 KB
/
test3par.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#!/bin/bash
# 3PAR Nagios check script v0.2
# Last update 2010/05/14 [email protected]
# Last update 2011/03/03 [email protected]
#
# This script is provided "as is" without warranty of any kind and 3PAR specifically disclaims all implied warranties of merchantability,
# non-infringement and fitness for a particular purpose. In no event shall 3PAR have any liability arising out of or related to
# customer's 'use of the script including lost data, lost profits, or any direct or indirect, incidental, special, or
# consequential damages arising there from.
# In addition, 3PAR reserves the right not to perform fixes or updates to this script
#
#
# Usage : check_3par InServ Username Command
#
# Supported commands
# check_pd : Check status of physical disks
# Degraded -> Warning
# Failed -> Critical
#
# check_node : Check status of controller nodes
# Degraded -> Warning
# Failed -> Critical
#
# check_ld : Check status of logical disks
# Degraded -> Warning
# Failed -> Critical
#
# check_vv : Check status of virtual volumes
# Degraded -> Warning
# Failed -> Critical
#
# check_port_fc : Check status of virtual volumes
# loss_sync -> Warning
# config_wait -> Warning
# login_wait -> Warning
# non_participate -> Warning
# error -> Critical
#
# check_cap_fc : Check used FC capacity
# >= $PCWARNINGFC -> Warning
# >= $PCCRITICALFC -> Critical
#
# check_cap_nl : Check used NL capacity
# >= $PCWARNINGNL -> Warning
# >= $PCCRITICALNL -> Critical
#
# check_ps : Check Power Supply Node and Cage
# Degraded -> Warning
# Failed -> Critical
#
# check_ps_cage : Check Power Supply Node and Cage
# Degraded -> Warning
# Failed -> Critical
#
#if [ "$1" == "" ] || [ $2 == "" ] || [ $3 == "" ]
#then
# echo Invalid usage : check_3par InServ Username/passwordfile Command
# exit 3
#fi
INSERV=$1
USERNAME="3paruser" #Put in the user name of 3PAR here
COMMAND=$2
TMPDIR=/tmp/3par
PCCRITICALFC=90
PCWARNINGFC=80
PCCRITICALNL=90
PCWARNINGNL=80
# To connect using the 3PAR CLI, uncomment the following line
#CONNECTCOMMAND="/opt/3PAR/inform_cli_2.3.1/bin/cli -sys $INSERV -pwf $USERNAME"
# Note : connecting using the CLI requires creating password files (.pwf)
# To connect using SSH. uncomment the following line
CONNECTCOMMAND="ssh $USERNAME@$INSERV"
# Note : connecting using SSH requires setting public key authentication
#echo $INSERV $USERNAME $COMMAND >> $TMPDIR/3par_check_log.out
if [ $COMMAND == "check_pd" ]
then
$CONNECTCOMMAND showpd -showcols Id,State -nohdtot > $TMPDIR/3par_$COMMAND.$INSERV.out 2>>$TMPDIR/log.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
if [ `grep -c failed $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo CRITICAL! The following PDs have abnormal status : `grep -v normal $TMPDIR/3par_$COMMAND.$INSERV.out | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ `grep -c degraded $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo WARNING! The following PDs have abnormal status : `grep -v normal $TMPDIR/3par_$COMMAND.$INSERV.out | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : All PDs have normal status
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi
if [ $COMMAND == "check_node" ]
then
$CONNECTCOMMAND shownode -s -nohdtot > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
if [ `grep -c -i failed $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo CRITICAL! The following nodes have abnormal status : `grep -i failed $TMPDIR/3par_$COMMAND.$INSERV.out | tr -s " " | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ `grep -c -i degraded $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo WARNING! The following nodes have abnormal status : `grep -i degraded $TMPDIR/3par_$COMMAND.$INSERV.out | tr -s " " | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : All nodes have normal status
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi
if [ $COMMAND == "check_ps" ]
then
$CONNECTCOMMAND shownode -ps -nohdtot > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
RC=3
fi
if [ `grep -c -i failed $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo CRITICAL! The following nodes have abnormal status : `grep -i failed $TMPDIR/3par_$COMMAND.$INSERV.out | tr -s " " | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
RC=2
else
if [ `grep -c -i degraded $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo WARNING! The following nodes have abnormal status : `grep -i degraded $TMPDIR/3par_$COMMAND.$INSERV.out | tr -s " " | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
RC=1
else
echo OK : All nodes have normal status
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
RC=0
fi
fi
fi
if [ $COMMAND == "check_ps_cage" ]
then
$CONNECTCOMMAND showcage -d > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
RC=3
fi
if [ `awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Failed") print cage" "$0}' $TMPDIR/3par_$COMMAND.$INSERV.out|wc -l` -gt 0 ]
then
echo CRITICAL! The following cages have abnormal status : `awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Failed") print cage" "$0}' $TMPDIR/3par_$COMMAND.$INSERV.out | tr -s " " | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
RC=2
else
if [ `awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Degraded") print cage" "$0}' $TMPDIR/3par_$COMMAND.$INSERV.out|wc -l` -gt 0 ]
then
echo WARNING! The following cages have abnormal status : `awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Degraded") print cage" "$0}' $TMPDIR/3par_$COMMAND.$INSERV.out | tr -s " " | tr -d '\n'`
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
RC=1
else
echo OK : All nodes have normal status
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
RC=0
fi
fi
fi
if [ $COMMAND == "check_vv" ]
then
$CONNECTCOMMAND showvv -showcols Name,State -notree -nohdtot > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
if [ `grep -c -i failed $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo CRITICAL! There are failed VVs. Contact 3PAR support
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ `grep -c -i degraded $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo WARNING! There are degraded VVs. Contact 3PAR support
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : All VVs are normal
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi
if [ $COMMAND == "check_ld" ]
then
$CONNECTCOMMAND showld -state -nohdtot > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
if [ `grep -c -i failed $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo CRITICAL! There are failed LDs. Contact 3PAR support
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ `grep -c -i degraded $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo WARNING! There are degraded LDs. Contact 3PAR support
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : All LDs have normal status
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi
if [ $COMMAND == "check_port_fc" ]
then
$CONNECTCOMMAND showport -nohdtot > $TMPDIR/3par_$COMMAND.$INSERV.out1
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
grep -v -i iscsi $TMPDIR/3par_$COMMAND.$INSERV.out1 | grep -v -i rcip > $TMPDIR/3par_$COMMAND.$INSERV.out
#rm -f $TMPDIR/3par_$COMMAND.$INSERV.out1
if [ `grep -c -i error $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo CRITICAL! Some ports are in the error state
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ `grep -c -i loss_sync $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ] || [ `grep -c -i config_wait $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ] || [ `grep -c -i login_wait $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ] || [ `grep -c -i non_participate $TMPDIR/3par_$COMMAND.$INSERV.out` -gt 0 ]
then
echo WARNING! Some ports are in an abnormal state \(loss_sync, config_wait, login_wait or non_participate\)
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : All FC ports have normal status \(ready or offline\)
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi
if [ $COMMAND == "check_cap_fc" ]
then
$CONNECTCOMMAND showpd -p -devtype FC -showcols Size_MB,Free_MB -csvtable > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
if [ `tail -1 $TMPDIR/3par_$COMMAND.$INSERV.out` = "No PDs listed" ]
then
echo No FC disks
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
TOTCAPFC=`cat ${TMPDIR}/3par_${COMMAND}.${INSERV}.out | tail -1 | cut -d, -f1`
FREECAPFC=`cat ${TMPDIR}/3par_${COMMAND}.${INSERV}.out | tail -1 | cut -d, -f2`
USEDCAPPCFC=`expr 100 \- \( \( $FREECAPFC \* 100 \) \/ $TOTCAPFC \)`
if [ $USEDCAPPCFC -ge $PCCRITICALFC ]
then
echo CRITICAL! Used FC capacity = $USEDCAPPCFC\% \( \> $PCCRITICALFC\% \)
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ $USEDCAPPCFC -ge $PCWARNINGFC ]
then
echo WARNING! Used FC capacity = $USEDCAPPCFC\% \( \> $PCWARNINGFC\% \)
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : Used FC capacity = $USEDCAPPCFC\%
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi
if [ $COMMAND == "check_cap_nl" ]
then
$CONNECTCOMMAND showpd -p -devtype NL -showcols Size_MB,Free_MB -csvtable > $TMPDIR/3par_$COMMAND.$INSERV.out
if [ $? -gt 0 ]
then
echo Could not connect to InServ $INSERV
exit 3
fi
if [ `tail -1 $TMPDIR/3par_$COMMAND.$INSERV.out` = "No PDs listed" ]
then
echo No NL disks
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
TOTCAPNL=`cat ${TMPDIR}/3par_${COMMAND}.${INSERV}.out | tail -1 | cut -d, -f1`
FREECAPNL=`cat ${TMPDIR}/3par_${COMMAND}.${INSERV}.out | tail -1 | cut -d, -f2`
USEDCAPPCNL=`expr 100 \- \( \( $FREECAPNL \* 100 \) \/ $TOTCAPNL \)`
if [ $USEDCAPPCNL -ge $PCCRITICALNL ]
then
echo CRITICAL! Used NL capacity = $USEDCAPPCNL\% \( \> $PCCRITICALNL\% \)
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 2
else
if [ $USEDCAPPCNL -ge $PCWARNINGNL ]
then
echo WARNING! Used NL capacity = $USEDCAPPCNL\% \( \> $PCWARNINGNL\% \)
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 1
else
echo OK : Used NL capacity = $USEDCAPPCNL\%
# rm -f $TMPDIR/3par_$COMMAND.$INSERV.out
exit 0
fi
fi
fi