forked from qaxi/nagios-check_3par
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_3par
More file actions
executable file
·750 lines (643 loc) · 24.7 KB
/
check_3par
File metadata and controls
executable file
·750 lines (643 loc) · 24.7 KB
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
#!/bin/bash
# 3PAR Nagios check script
# Last update 2010/05/14 fredl@3par.com
# Last update 2011/03/03 ddu@antemeta.fr
# Last update 2015/01/26 by "emil" via https://exchange.nagios.org 3PAR-check-script
# Last update 2015/07/29 pashol
# Last update 2015/09/17 qaxi@seznam.cz
# Last update 2016/12/16 yves.vaccarezza@corsedusud.fr
# Last update 2017/04/12 peterhanraets https://github.com/peterhanraets/nagios-check_3par
# Last update 2017/10/09 gg@grexaut.net https://github.com/GrexAut
# Last update 2017/11/09 qaxi@seznam.cz https://github.com/qaxi/nagios-check_3par
#
#
# 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
#
VERSION="1.2.2"
CAPWARN=80 # warning at 80% of used disc capacity
CAPCRIT=90 # warnint at 90% of user disc capacity
# Strict variable checking
set -u # stop on use of unset var
#set -e ; set -E # stop on unexpected error
# Debugging help
#export PS4='+${LINENO}:${FUNCNAME[0]-}: ' # better -x output
#trap 'set +x ; echo -e "Unexpected ERROR \n[$BASH_SOURCE:$LINENO:${FUNCNAME[0]- =>}] "; nl -b a -s : "$BASH_SOURCE" | grep -A 3 "^ *${LINENO}:"' ERR
PRGNAME=$(basename "$0")
DBG="n"
function dbg() { [ "${DBG}" = "y" ] && echo "DBG: $*" >&2 ; }
OPTS=':hH:i:u:k:p:w:c:vd-:' # first : and lsast - is mandatory
function usage() {
[ -n "$*" ] && {
exec 1>&2 # redirect STDOUT to STDERR for rest of script
echo "${PRGNAME} ERROR: $*"
echo ""
}
help
exit 128
}
function help() {
echo "${PRGNAME} v${VERSION} (https://github.com/qaxi/nagios-check_3par)
Copyright (c) 2010-2017 various developers - look in source code
This plugin contains tests 3PAR disc array statuses.
Usage: ${PRGNAME} -h | -H <3PAR> [-d] (-u <username> [-k <PRIVATE_KEY_FILE>] | -i <inform_cli> [-p <password_file>]) [-w <warning>] [-c <critical>] COMMAND [ arg [arg ...]]
Options:
-h, --help
Print detailed help screen
-H, --hostname=ADDRESS
3PAR controler
-i, --inform-bin=PATH
Path to 3PAR Inform CLI. Default connection method is SSH.
-u, --username=USER
3PAR username
-k, --ssh-key=PRIVATE_KEY_FILE
For ssh login, use this file as a key, instead of default identity
file (usually \${HOME}/.ssh/identity)
-p, --password-file=PATH
Password file for 3PAR Inform CLI
-w, --warning=TRESHOLD (default: 80)
Warning treshold
-c, --critical=TRESHOLD (default: 90)
Critical treshold
-d, --debug
Turn on debugging
-v, --verbose
increment verbosity if supported (multiple use allowed)
COMMAND use --help to get details
"
}
function helplong () {
help
echo "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 FC ports
loss_sync -> Warning
config_wait -> Warning
login_wait -> Warning
non_participate -> Warning
error -> Critical
check_cap_ssd : Check used SSD capacity
>= ${CAPWARN} -> Warning
>= ${CAPCRIT} -> Critical
check_cap_fc : Check used FC capacity
>= ${CAPWARN} -> Warning
>= ${CAPCRIT} -> Critical
check_cap_nl : Check used NL capacity
>= ${CAPWARN} -> Warning
>= ${CAPCRIT} -> Critical
check_ps_node : Check Power Supply Node
Degraded -> Warning
Failed -> Critical
check_ps_cage : Check Power Supply Cage
Degraded -> Warning
Failed -> Critical
check_volume <VOLUMENAME> : Check status of volume
Degraded -> Warning
Failed -> Critical
check_qw <QWIP> : Check status of quorum witness
loss_sync -> Critical
error -> Critical
check_health : Check overall state of the system
check_alerts : Check status of system alerts
"
exit 128
}
[ "$#" = 0 ] && usage "Too few arguments."
while getopts "${OPTS}" OPTION ; do
dbg "option ${OPTION} optind ${OPTIND} optarg ${OPTARG:-}"
case "${OPTION}" in
d ) DBG="y";;
v ) usage "Not implemented yet" ;;
h ) usage ;;
H ) INSERV="${OPTARG}" ;;
i ) INFORMBIN="${OPTARG}" ;;
u ) USERNAME="${OPTARG}" ;;
k ) KEYFILE="${OPTARG}" ;;
p ) PASSFILE="${OPTARG}" ;;
w ) CAPWARN="${OPTARG}" ;;
c ) CAPCRIT="${OPTARG}" ;;
- ) [ ${OPTIND} -ge 1 ] && optind=$(expr ${OPTIND} - 1 ) || optind=${OPTIND}
eval OPTION="\$$optind"
OPTARG=$(echo ${OPTION} | cut -d'=' -f2)
OPTION=$(echo ${OPTION} | cut -d'=' -f1)
dbg "- option ${OPTION} optind ${OPTIND} optarg ${OPTARG}"
case ${OPTION} in
--debug ) DBG="y" ;;
--verbose) usage "Not implemented yet" ;;
--help ) helplong ;;
--hostname ) INSERV="${OPTARG}" ;;
--inform-bin ) INFORMBIN="${OPTARG}" ;;
--username ) USERNAME="${OPTARG}" ;;
--ssh-key ) KEYFILE="${OPTARG}" ;;
--password-file ) USERNAME="${OPTARG}" ;;
--warning ) CAPWARN="${OPTARG}" ;;
--critical ) CAPCRIT="${OPTARG}" ;;
? ) usage "Invalid option '${OPTARG}'" ;;
* ) usage "parsing options failed";;
esac
#OPTIND=1
#shift
;;
? ) usage "Invalid option '${OPTARG}'" ;;
* ) usage "parsing options failed";;
esac
done
shift $((OPTIND-1))
dbg "3PAR command: $*"
dbg "OPTION: ${OPTION} OPTIND: ${OPTIND} OPTARG: ${OPTARG:-}"
# 0 OK The plugin was able to check the service and it appeared to be functioning properly
# 1 Warning The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly
# 2 Critical The plugin detected that either the service was not running or it was above some "critical" threshold
# 3 Unknown Invalid command line arguments were supplied to the plugin or low-level failures
RETOK=0
RETWARN=1
RETCRIT=2
RETUNKN=3
# -v
# 0 Single line, minimal output. Summary
# 1 Single line, additional information (eg list processes that fail)
# 2 Multi line, configuration debug output (eg ps command used)
# 3 Lots of detail for plugin problem diagnosis
# Output Nagios compatible string and exit
function output () {
STATUS="$1"
shift
OUTPUT="$@"
case "${STATUS}" in
OK ) RET=${RETOK} ; OUT="OK: ${OUTPUT}" ;;
WARN | WARNING ) RET=${RETWARN} ; OUT="Warning: ${OUTPUT}" ;;
CRIT | CRITICAL ) RET=${RETCRIT} ; OUT="Critical: ${OUTPUT}" ;;
UNKN | UNKNOWN ) RET=${RETUNKN} ; OUT="Unknown: ${OUTPUT}" ;;
* ) RET=${RETUNKN} ; OUT="Unknown: bad parameter STATUS for output()" ;;
esac
echo "${OUT}"
exit ${RET}
}
COMMAND="${1:-}"
[ -z "${COMMAND}" ] && usage "COMMAND is not set"
CMDARG1="${2:-}"
VERBOSE="${VERBOSE-0}"
TMPOUT=""
PCCRITICALFC="${CAPCRIT}"
PCWARNINGFC="${CAPWARN}"
PCCRITICALNL="${CAPCRIT}"
PCWARNINGNL="${CAPWARN}"
PCCRITICALSSD="${CAPCRIT}"
PCWARNINGSSD="${CAPWARN}"
CRITICAL="${CAPCRIT}"
WARNING="${CAPWARN}"
# CLI or SSH
if [ -n "${INFORMBIN:-}" ]
then
# To connect using the 3PAR CLI, use option -i and -p to setup the command
CONNECTCOMMAND="${INFORMBIN} -sys ${INSERV} -pwf ${PASSFILE}"
# Note : connecting using the CLI requires creating password files (.pwf)
else
# To connect using SSH use -u option to set username
# Note : connecting using SSH requires setting public key authentication
if [ -n "${USERNAME:-}" ]
then
if [ -n "${KEYFILE:-}" ]
then
CONNECTCOMMAND="ssh ${USERNAME}@${INSERV} -i ${KEYFILE} "
else
CONNECTCOMMAND="ssh ${USERNAME}@${INSERV} "
fi
else
usage "Use either -u <username> or -i <inform_bin>"
fi
fi
if [ "${COMMAND}" == "check_pd" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showpd -showcols Id,State -nohdtot 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
if [ $( echo "${TMPOUT}" | grep -c failed ) -gt 0 ]
then
echo "CRITICAL! The following PDs have abnormal status : " \
"$( echo "${TMPOUT}" | grep -v normal | tr -d '\n' )"
exit 2
else
if [ $( echo "${TMPOUT}" | grep -c failed ) -gt 0 ]
then
echo "WARNING! The following PDs have abnormal status : " \
"$( echo "${TMPOUT}" | grep -v normal | tr -d '\n' )"
exit 1
else
echo "OK : All PDs have normal status "
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_node" ]
then
TMPOUT=$( ${CONNECTCOMMAND} shownode -s -nohdtot 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
if [ $( echo "${TMPOUT}" | grep -c -i failed ) -gt 0 ]
then
echo "CRITICAL! The following nodes have abnormal status : " \
"$( echo "${TMPOUT}" | grep -i failed | tr -s " " | tr -d '\n' )"
exit 2
else
if [ $( echo "${TMPOUT}" | grep -c -i degraded ) -gt 0 ]
then
echo "WARNING! The following nodes have abnormal status : " \
"$( echo "${TMPOUT}" | grep -i degraded | tr -s " " | tr -d '\n' )"
exit 1
else
echo "OK : All nodes have normal status"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_ps_node" ] || [ "${COMMAND}" == "check_ps" ]
then
TMPOUT=$( ${CONNECTCOMMAND} shownode -ps 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
RC=3
fi
if [ $( echo "${TMPOUT}" | grep -c -i failed ) -gt 0 ]
then
echo "CRITICAL! The following nodes have abnormal status : " \
"$( echo "${TMPOUT}" | grep -i failed | tr -s " " | tr -d '\n' )"
RC=2
else
if [ $( echo "${TMPOUT}" | grep -c -i degraded ) -gt 0 ]
then
echo "WARNING! The following nodes have abnormal status : " \
"$( echo "${TMPOUT}" | grep -i degraded | tr -s " " | tr -d '\n' )"
RC=1
else
echo "OK : All nodes have normal status"
RC=0
fi
fi
exit ${RC}
fi
if [ "${COMMAND}" == "check_ps_cage" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showcage -d 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
RC=3
fi
if [ $( echo "${TMPOUT}" | awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Failed") print cage" "$0}' | wc -l ) -gt 0 ]
then
echo "CRITICAL! The following cages have abnormal status : " \
"$( echo "${TMPOUT}" | awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Failed") print cage" "$0}' | tr -s " " | tr -d '\n' )"
RC=2
else
if [ $( echo "${TMPOUT}" | awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Degraded") print cage" "$0}' | wc -l ) -gt 0 ]
then
echo "WARNING! The following cages have abnormal status : " \
"$( echo "${TMPOUT}" | awk '{ if ($0 ~ "------Cage") cage=$5; if ($0 ~ "Degraded") print cage" "$0}' | tr -s " " | tr -d '\n' )"
RC=1
else
echo "OK : All nodes have normal status"
RC=0
fi
fi
exit ${RC}
fi
if [ "${COMMAND}" == "check_vv" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showvv -showcols Name,State -notree -nohdtot 2>&1 )
if [ $? -gt 0 ]
then
output UNKNOWN Could not get data from 3PAR $INSERV "\n$TMPOUT"
fi
if [ $( echo "$TMPOUT" | grep -c -i failed ) -gt 0 ]
then
case ${VERBOSE} in
0) output CRITICAL There are failed VVs \
"$( echo "$TMPOUT" | grep -c -i failed )" Contact 3PAR support ;;
1) output CRITICAL There are failed VVs \
"$( echo "$TMPOUT" | grep -i failed | tr -d '\n')" ;;
2) OKVOLUMES=$(echo "$TMPOUT" | grep -i failed \
| cut -f 2,7,8,11,12 -d " " | sort -n \
| sed "s/\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/\1 \2 \3 size \5MB used \4MB /")
output CRITICAL There are failed VVs "\n$OKVOLUMES" ;;
*) OKVOLUMES=$(echo "$TMPOUT" | grep -i failed | sort -n )
output CRITICAL There are failed VVs "\n$OKVOLUMES" ;;
esac
else
if [ $( echo "${TMPOUT}" | grep -c -i degraded ) -gt 0 ]
then
case ${VERBOSE} in
0) output WARNING There are degraded VVs \
"$( echo "$TMPOUT" | grep -c -i degraded )" Contact 3PAR support ;;
1) output WARNING There are degraded VVs \
"$( echo "$TMPOUT" | grep -i degraded | tr -d '\n')" ;;
2) OKVOLUMES=$(echo "$TMPOUT" | grep -i degraded \
| cut -f 2,7,8,11,12 -d " " | sort -n \
| sed "s/\(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/\1 \2 \3 size \5MB used \4MB /")
output WARNING There are degraded VVs "\n$OKVOLUMES" ;;
*) OKVOLUMES=$(echo "$TMPOUT" | grep -i degraded | sort -n )
output WARNING There are degraded VVs "\n$OKVOLUMES" ;;
esac
else
case ${VERBOSE} in
0) output OK All $(echo "$TMPOUT" | grep -c normal ) VVs are normal ;;
1) OKVOLUMES=$(echo "$TMPOUT" | cut -f 2 -d " " | sort -n )
output OK All $(echo "$TMPOUT" | wc -l ) VVs are normal $OKVOLUMES ;;
2) OKVOLUMES=$(echo "$TMPOUT" | cut -f 2,7,11,12 -d " " | sort -n \
| sed "s/\(.*\) \(.*\) \(.*\) \(.*\)/\1 \2 size \4MB used \3MB /")
output OK All $(echo "$TMPOUT" | wc -l ) VVs are normal "\n$OKVOLUMES" ;;
*) OKVOLUMES=$(echo "$TMPOUT" | sort -n )
output OK All $(echo "$TMPOUT" | wc -l ) VVs are normal "\n$OKVOLUMES" ;;
esac
fi
fi
fi
if [ "${COMMAND}" == "check_ld" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showld -state -nohdtot 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
if [ $( echo "${TMPOUT}" | grep -c -i failed ) -gt 0 ]
then
echo "CRITICAL! There are failed LDs. Contact 3PAR support"
exit 2
else
if [ $( echo "${TMPOUT}" | grep -c -i degraded ) -gt 0 ]
then
echo "WARNING! There are degraded LDs. Contact 3PAR support"
exit 1
else
echo "OK : All LDs have normal status"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_port_fc" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showport -nohdtot 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
TMPOUT=$( echo "${TMPOUT}" | grep -v -i iscsi 2>&1 | grep -v -i rcip 2>&1 | grep -v -i free 2>&1)
if [ $( echo "${TMPOUT}" | grep -c -i error ) -gt 0 ]
then
echo "CRITICAL! Some ports are in the error state"
exit 2
else
if [ $( echo "${TMPOUT}" | grep -c -i loss_sync ) -gt 0 ] || [ $( echo "${TMPOUT}" | grep -c -i config_wait ) -gt 0 ] || [ $( echo "${TMPOUT}" | grep -c -i login_wait ) -gt 0 ] || [ $( echo "${TMPOUT}" | grep -c -i non_participate ) -gt 0 ]
then
echo "WARNING! Some ports are in an abnormal state " \
"(loss_sync, config_wait, login_wait or non_participate)"
exit 1
else
echo "OK : All FC ports have normal status (ready or offline)"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_cap_ssd" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showpd -p -devtype SSD -showcols Size_MB,Free_MB -csvtable 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
LASTLINE=$( echo "${TMPOUT}" | tail -1 )
if [ "${LASTLINE}" = "No PDs listed" ] || [ "${LASTLINE}" = "0,0" ]
then
echo "No SSD disks"
exit 0
fi
TOTCAPSSD=$( echo "${TMPOUT}" | tail -1 | cut -d, -f1 )
FREECAPSSD=$( echo "${TMPOUT}" | tail -1 | cut -d, -f2 )
USEDCAPPCSSD="$(( 100 - ( ( ${FREECAPSSD} * 100 ) / ${TOTCAPSSD} ) ))"
USEDCAPSSD=$(((${TOTCAPSSD}-${FREECAPSSD})))
WARNCAPSSDRAW=$((${TOTCAPSSD}*${PCWARNINGSSD}/100))
CRITCAPSSDRAW=$((${TOTCAPSSD}*${PCCRITICALSSD}/100))
#TOTCAPSSDGB=$((${TOTCAPSSD}/1024))
if [ "${USEDCAPPCSSD}" -ge "${PCCRITICALSSD}" ]
then
echo "CRITICAL! Used SSD capacity = ${USEDCAPPCSSD}% ( > ${PCCRITICALSSD}% )|UsedSpace=${USEDCAPPCSSD}%;${PCWARNINGSSD};${PCCRITICALSSD} UsedSpace=${USEDCAPSSD}MB;${WARNCAPSSDRAW};${CRITCAPSSDRAW};0;${TOTCAPSSD}"
exit 2
else
if [ "${USEDCAPPCSSD}" -ge "${PCWARNINGSSD}" ]
then
echo "WARNING! Used SSD capacity = ${USEDCAPPCSSD}% ( > ${PCWARNINGSSD}% )|UsedSpace=${USEDCAPPCSSD}%;${PCWARNINGSSD};${PCCRITICALSSD} UsedSpace=${USEDCAPSSD}MB;${WARNCAPSSDRAW};${CRITCAPSSDRAW};0;${TOTCAPSSD}"
exit 1
else
echo "OK : Used SSD capacity = ${USEDCAPPCSSD}% |UsedSpace=${USEDCAPPCSSD}%;${PCWARNINGSSD};${PCCRITICALSSD} UsedSpace=${USEDCAPSSD}MB;${WARNCAPSSDRAW};${CRITCAPSSDRAW};0;${TOTCAPSSD}"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_cap_fc" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showpd -p -devtype FC -showcols Size_MB,Free_MB -csvtable 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
LASTLINE=$( echo "${TMPOUT}" | tail -1 )
if [ "${LASTLINE}" = "No PDs listed" ] || [ "${LASTLINE}" = "0,0" ]
then
echo "No FC disks"
exit 0
fi
TOTCAPFC=$( echo "${TMPOUT}" | tail -1 | cut -d, -f1 )
FREECAPFC=$( echo "${TMPOUT}" | tail -1 | cut -d, -f2 )
USEDCAPPCFC="$(( 100 - ( ( ${FREECAPFC} * 100 ) / ${TOTCAPFC} ) ))"
USEDCAPFC=$(((${TOTCAPFC}-${FREECAPFC})))
WARNCAPFCRAW=$((${TOTCAPFC}*${PCWARNINGFC}/100))
CRITCAPFCRAW=$((${TOTCAPFC}*${PCCRITICALFC}/100))
#TOTCAPFCGB=$((${TOTCAPFC}/1024))
if [ "${USEDCAPPCFC}" -ge "${PCCRITICALFC}" ]
then
echo "CRITICAL! Used FC capacity = ${USEDCAPPCFC}\% \( \> ${PCCRITICALFC}\% \)\|UsedSpace=${USEDCAPPCFC}\%\;${PCWARNINGFC}\;${PCCRITICALFC} UsedSpace=${USEDCAPFC}\MB\;${WARNCAPFCRAW}\;${CRITCAPFCRAW}\;0\;${TOTCAPFC}"
exit 2
else
if [ "${USEDCAPPCFC}" -ge "${PCWARNINGFC}" ]
then
echo "WARNING! Used FC capacity = ${USEDCAPPCFC}\% \( \> ${PCWARNINGFC}\% \)\|UsedSpace=${USEDCAPPCFC}\%\;${PCWARNINGFC}\;${PCCRITICALFC} UsedSpace=${USEDCAPFC}\MB\;${WARNCAPFCRAW}\;${CRITCAPFCRAW}\;0\;${TOTCAPFC}"
exit 1
else
echo "OK : Used FC capacity = ${USEDCAPPCFC}\%\|UsedSpace=${USEDCAPPCFC}\%\;${PCWARNINGFC}\;${PCCRITICALFC} UsedSpace=${USEDCAPFC}\MB\;${WARNCAPFCRAW}\;${CRITCAPFCRAW}\;0\;${TOTCAPFC}"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_cap_nl" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showpd -p -devtype NL -showcols Size_MB,Free_MB -csvtable 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
LASTLINE=$(echo "${TMPOUT}" | tail -1 )
if [ "${LASTLINE}" = "No PDs listed" ] || [ "${LASTLINE}" = "0,0" ]
then
echo "No NL disks"
exit 0
fi
TOTCAPNL=$( echo "${TMPOUT}" | tail -1 | cut -d, -f1 )
FREECAPNL=$( echo "${TMPOUT}" | tail -1 | cut -d, -f2 )
USEDCAPPCNL="$(( 100 - ( ( ${FREECAPNL} * 100 ) / ${TOTCAPNL} ) ))"
if [ "${USEDCAPPCNL}" -ge "${PCCRITICALNL}" ]
then
echo "CRITICAL! Used NL capacity = ${USEDCAPPCNL}\% \( \> ${PCCRITICALNL}\% \)"
exit 2
else
if [ "${USEDCAPPCNL}" -ge "${PCWARNINGNL}" ]
then
echo "WARNING! Used NL capacity = ${USEDCAPPCNL}\% \( \> ${PCWARNINGNL}\% \)"
exit 1
else
echo "OK : Used NL capacity = ${USEDCAPPCNL}\%"
exit 0
fi
fi
fi
if [ ${COMMAND} == "check_volume" ]
then
if [ "${CMDARG1}" == "" ]
then
echo "Command 'check_volume' needs VOLUMENAME as additional parameter."
exit 3
fi
TMPOUT=$( ${CONNECTCOMMAND} showvv ${CMDARG1} -csvtable 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to 3PAR ${INSERV}"
exit 3
fi
LASTLINE=$(echo "${TMPOUT}" | tail -1 )
if [ "${LASTLINE}" = "no vv listed" ]
then
echo "No such volume: ${CMDARG1}"
exit 0
fi
TMPOUT=$( echo "${TMPOUT}" | grep ",base," | grep ",${CMDARG1}," )
VSIZE=$( echo "${TMPOUT}" | cut -d, -f12 )
VSIZE_Gb="$(( ${VSIZE} / 1024 ))"
USED=$( echo "${TMPOUT}" | cut -d, -f11 )
USED_Gb="$(( ${USED} / 1024 ))"
FREE="$(( ${VSIZE} - ${USED} ))"
FREE_Gb="$(( ${FREE} / 1024 ))"
FREEPERCENT="$(( 100 - ( ( ${USED} * 100 ) / ${VSIZE} ) ))"
USEDPERCENT="$(( 100 - ( ${FREEPERCENT} ) ))"
WARNCRAW="$(( ${VSIZE}*${WARNING}/100))"
WARNCRAW_Gb="$(( ${WARNCRAW} / 1024 ))"
CRITCCRAW="$(( ${VSIZE}*${CRITICAL}/100 ))"
CRITCCRAW_Gb="$(( ${CRITCCRAW} / 1024 ))"
MSG="TOTAL: ${VSIZE}Mb USED: ${USED}Mb (${USEDPERCENT}%) FREE: ${FREE}Mb (${FREEPERCENT}%) TotSize=${VSIZE_Gb}Gb Used=${USED_Gb}Gb, Warn on used: ${WARNCRAW_Gb}Gb, Critical on Used: ${CRITCCRAW_Gb}Gb"
if [ ${USED_Gb} -ge ${CRITCCRAW_Gb} ]
then
echo "CRITICAL: ${MSG}"
exit 2
else
if [ ${USED_Gb} -ge ${WARNCRAW_Gb} ]
then
echo "WARNING: ${MSG}"
exit 1
else
echo "OK: ${MSG}"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_qw" ]
then
if [ "${CMDARG1}" == "" ]
then
output "UNKN" "Command 'check_qw' needs QW IP as additional parameter."
fi
TMPOUT=$( ${CONNECTCOMMAND} setrcopytarget witness check ${CMDARG1} 2>&1 )
if [ $( echo "${TMPOUT}" | grep -c "Connectivity check passed" ) -eq 0 ]
then
output "UNKN" "${TMPOUT}"
fi
TMPOUT=$( ${CONNECTCOMMAND} showrcopy -qw targets 2>&1 )
if [ $( echo "${TMPOUT}" | grep -i " ${CMDARG1} " | grep -c Started ) -gt 0 ]
then
output "OK" "Quorum Witness normal status"
else
output "WARN" $( echo "Quorum Witness has problems" ; \
echo " ${TMPOUT} " ; )
fi
fi
if [ "${COMMAND}" == "check_alerts" ]
then
TMPOUT=$( ${CONNECTCOMMAND} showalert 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to InServ ${INSERV}"
exit 3
fi
if [ $( echo "${TMPOUT}" | grep -c -i fatal ) -gt 0 ] || [ $( echo "${TMPOUT}" | grep -c -i critical ) -gt 0 ] || [ $( echo "${TMPOUT}" | grep -c -i major ) -gt 0 ]
then
echo "CRITICAL! The system has fatal/critical/major level alerts. Please check immediately"
exit 2
else
if [ $( echo "${TMPOUT}" | grep -c -i minor ) -gt 0 ] || [ $( echo "${TMPOUT}" | grep -c -i degraded ) -gt 0 ]
then
echo "WARNING! The system has minor/degraded level alerts. Please check asap"
exit 1
else
echo "OK : No alarms"
exit 0
fi
fi
fi
if [ "${COMMAND}" == "check_health" ]
then
TMPOUT=$( ${CONNECTCOMMAND} checkhealth -quiet 2>&1 )
if [ $? -gt 0 ]
then
echo "Could not connect to InServ ${INSERV}"
exit 3
fi
if [ $( echo "${TMPOUT}" | grep total | awk '{print $1}' ) -gt 0 ]
then
echo "WARNING! The system is not healthy. Please check."
echo "${TMPOUT}"
exit 1
else
echo "OK : System is healthy"
exit 0
fi
fi
usage "ERROR Wrong command '${COMMAND}' ."
exit ${RETUNKN}
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab: