-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckDiskStatus.sh
51 lines (50 loc) · 1.37 KB
/
checkDiskStatus.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
#!/bin/bash
declare -A map=(["c"]="" ["d"]="" ["e"]="" ["h"]="")
using=0
while true
do
time=$(date)
for var in c d e h
do
diskStatus=`hdparm -C /dev/sd"$var"|grep standby`
if [ -z "$diskStatus" ];
then
using=0
temp="$var"1
work=`lsof /dev/sd"$temp"`
if [ "${map["$var"]}" != "$work" ];
then
map["$var"]=$work
if [ -z "$work" ];
then
echo "${time}">>diskStatus.txt
echo "/dev/sd"$var" is running">>diskStatus.txt
echo "not working standby soon">>diskStatus.txt
else
echo "${time}">>diskStatus.txt
echo "/dev/sd"$var" is running">>diskStatus.txt
lsof /dev/sd"$temp">>diskStatus.txt
fi
fi
fi
done
if [ $using -eq 0 ];
then
flag=0
for var in c d e h
do
diskStatus=`hdparm -C /dev/sd"$var"|grep standby`
if [ -z "$diskStatus" ];
then
flag=1
fi
done
if [ $flag=0 ];
then
echo "${time}">>diskStatus.txt
echo -e "all disk is standby\n">>diskStatus.txt
using=1
fi
fi
sleep 20
done