-
Notifications
You must be signed in to change notification settings - Fork 14
/
check_disk_health.sh
executable file
·47 lines (43 loc) · 1.04 KB
/
check_disk_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
#!/bin/bash
# Author: GuangHongwei
# Email: [email protected]
# Desc: Check Disk Health Status
# Require dell server and install MegaCli tools
#
MegaCli="sudo /opt/MegaRAID/MegaCli/MegaCli64"
check_support() {
if [ ! -f ${MegaCli#sudo} ];then
echo 2
return 1
fi
count=`$MegaCli -adpCount | grep "Controller" | awk -F: '{ print $2 }'`
if [ "${count/./}" -gt 0 ];then
echo 1
return 0
else
echo 0
return 1
fi
}
check_disk_count() {
check_support &> /dev/null
if [ $? != '0' ];then
echo 0
return 1
fi
count=`$MegaCli -AdpAllInfo -aALL | grep -A9 "Device Present" | grep "^[[:space:]]*$1" | awk -F: '{ print $2 }'`
echo ${count/ /}
}
case $1 in
Support)
check_support
;;
*)
echo "Critical Failed Degraded Offline Physical Virtual Disks" | grep "$1" &> /dev/null
if [ $? != '0' ] || [ -z "$1" ] ;then
echo "Usage: $0 Critical Failed Degraded Offline Physical Virtual Disks Support"
else
check_disk_count $1
fi
;;
esac