-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckDiskStatusSharp.sh
54 lines (54 loc) · 1.49 KB
/
checkDiskStatusSharp.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
#!/bin/bash
declare -A map=(["c"]="" ["d"]="" ["e"]="" ["f"]="" ["g"]="" ["h"]="")
diskStandby=0
while true
do
time=$(date)
flag=0
> runningJob.txt
for var in c d e f g h
do
diskLable="$var"1
job=`lsof /dev/sd"$diskLable"`
lsof /dev/sd"$diskLable">>runningJob.txt
if [ -n "$job" ];
then
flag=1
diskStandby=0
if [ "${map["$var"]}" != "$job" ];
then
map["$var"]=$job
echo "${time}">>diskStatus.txt
echo "/dev/sd"$var" is running">>diskStatus.txt
lsof /dev/sd"$diskLable">>diskStatus.txt
fi
elif [ $diskStandby -eq "0" ] && [ "${map["$var"]}" != "$job" ];
then
map["$var"]=$job
echo "${time}">>diskStatus.txt
echo "/dev/sd"$var" is running">>diskStatus.txt
echo "not working standby soon">>diskStatus.txt
fi
done
if [ $diskStandby -eq 0 ] && [ $flag -eq 0 ];
then
isRunning=0
sleep 40
for var in c d e h
do
diskStatus=`hdparm -C /dev/sd"$var"|grep standby`
if [ -z "$diskStatus" ];
then
isRunning=1
fi
done
if [ $isRunning -eq 0 ];
then
echo "${time}">>
diskStatus.txt
echo -e "all disk is standby\n">>diskStatus.txt
diskStandby=1
fi
fi
sleep 20
done