Added support for 'check' sync progress
This commit is contained in:
parent
30a77ea9ba
commit
67d558dd2d
25 changed files with 53 additions and 23 deletions
|
@ -57,8 +57,9 @@ CHUNK_SIZE_IN_BYTES= # size in bytes for chunks
|
||||||
NUM_DEVICES=0 # int with total number of devices in raid
|
NUM_DEVICES=0 # int with total number of devices in raid
|
||||||
NUM_ACTIVE_DEVICES=0 # int with number of active devices in raid
|
NUM_ACTIVE_DEVICES=0 # int with number of active devices in raid
|
||||||
NUM_SPARE_DEVICES=0 # int with number of spare devices in raid
|
NUM_SPARE_DEVICES=0 # int with number of spare devices in raid
|
||||||
RECOVERY_PROGRESS= # float in percent
|
rYNC_ACTION= # "idle", "check" or "recover"
|
||||||
RECOVERY_SPEED= # sync speed in K/s
|
SYNC_PROGRESS= # float in percent
|
||||||
|
SYNC_SPEED= # sync speed in K/s
|
||||||
declare -A DEVICE_STATE # dict of strings. key = dev, value = state
|
declare -A DEVICE_STATE # dict of strings. key = dev, value = state
|
||||||
declare -A FAULTY_DEVICES # dict with only faulty devices. key = dev, value = true
|
declare -A FAULTY_DEVICES # dict with only faulty devices. key = dev, value = true
|
||||||
declare -A TO_REPLACE_DEVICES # dict of devices in raid that shall be replaced. key = dev, value = true
|
declare -A TO_REPLACE_DEVICES # dict of devices in raid that shall be replaced. key = dev, value = true
|
||||||
|
@ -71,15 +72,19 @@ function getDataFromSys {
|
||||||
CHUNK_SIZE_IN_BYTES=$(<$INPUT/chunk_size)
|
CHUNK_SIZE_IN_BYTES=$(<$INPUT/chunk_size)
|
||||||
SIZE_IN_BLOCKS=$(<$INPUT/component_size)
|
SIZE_IN_BLOCKS=$(<$INPUT/component_size)
|
||||||
STATE=$(<$INPUT/array_state)
|
STATE=$(<$INPUT/array_state)
|
||||||
RECOVERY_PROGRESS=$(<$INPUT/sync_completed)
|
SYNC_ACTION=$(<$INPUT/sync_action)
|
||||||
RECOVERY_SPEED=$(<$INPUT/sync_speed)
|
if [ "$SYNC_ACTION" != "idle" ]; then
|
||||||
|
SYNC_PROGRESS=$(<$INPUT/sync_completed)
|
||||||
|
SYNC_SPEED=$(<$INPUT/sync_speed)
|
||||||
|
fi
|
||||||
|
|
||||||
log "LEVEL = $LEVEL"
|
log "LEVEL = $LEVEL"
|
||||||
log "STATE = $STATE"
|
log "STATE = $STATE"
|
||||||
log "CHUNK_SIZE_IN_BYTES = $CHUNK_SIZE_IN_BYTES"
|
log "CHUNK_SIZE_IN_BYTES = $CHUNK_SIZE_IN_BYTES"
|
||||||
log "SIZE_IN_BLOCKS = $SIZE_IN_BLOCKS"
|
log "SIZE_IN_BLOCKS = $SIZE_IN_BLOCKS"
|
||||||
log "RECOVERY_PROGRESS = $RECOVERY_PROGRESS"
|
log "SYNC_ACTION = $SYNC_ACTION"
|
||||||
log "RECOVERY_SPEED = $RECOVERY_SPEED"
|
log "SYNC_PROGRESS = $SYNC_PROGRESS"
|
||||||
|
log "SYNC_SPEED = $SYNC_SPEED"
|
||||||
|
|
||||||
for dev in `find $INPUT -type d -name 'dev-*' -printf "%f\n"`; do
|
for dev in `find $INPUT -type d -name 'dev-*' -printf "%f\n"`; do
|
||||||
local deviceName=${dev:4}
|
local deviceName=${dev:4}
|
||||||
|
@ -106,15 +111,15 @@ function getDataFromSys {
|
||||||
log "FAULTY_DEVICES = ${FAULTY_DEVICES[*]}"
|
log "FAULTY_DEVICES = ${FAULTY_DEVICES[*]}"
|
||||||
log "TO_REPLACE_DEVICES = ${TO_REPLACE_DEVICES[*]}"
|
log "TO_REPLACE_DEVICES = ${TO_REPLACE_DEVICES[*]}"
|
||||||
|
|
||||||
if [ "$RECOVERY_PROGRESS" != "none" ]; then
|
if [ "$SYNC_ACTION" != "idle" ]; then
|
||||||
RECOVERY_NUM=${RECOVERY_PROGRESS% /*}
|
SYNC_NUM=${SYNC_PROGRESS% /*}
|
||||||
log "'$RECOVERY_NUM'"
|
log "'$SYNC_NUM'"
|
||||||
RECOVERY_DEN=${RECOVERY_PROGRESS#*/ }
|
SYNC_DEN=${SYNC_PROGRESS#*/ }
|
||||||
log "'$RECOVERY_DEN'"
|
log "'$SYNC_DEN'"
|
||||||
RECOVERY_PERCENT=$(($RECOVERY_NUM*100/$RECOVERY_DEN))
|
SYNC_PERCENT=$(($SYNC_NUM*100/$SYNC_DEN))
|
||||||
BLOCK_SIZE=$(<$(dirname $INPUT)/queue/hw_sector_size)
|
BLOCK_SIZE=$(<$(dirname $INPUT)/queue/hw_sector_size)
|
||||||
RECOVERY_REMAINING_S=$(( ($RECOVERY_DEN-$RECOVERY_NUM)*$BLOCK_SIZE/1024/$RECOVERY_SPEED))
|
SYNC_REMAINING_S=$(( ($SYNC_DEN-$SYNC_NUM)*$BLOCK_SIZE/1024/$SYNC_SPEED))
|
||||||
RECOVERY_REMAINING_MIN=$(($RECOVERY_REMAINING_S/60))
|
SYNC_REMAINING_MIN=$(($SYNC_REMAINING_S/60))
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,10 +145,14 @@ function printOutputAndExit {
|
||||||
info="${info}These devices should be replaced: ${!TO_REPLACE_DEVICES[@]}"
|
info="${info}These devices should be replaced: ${!TO_REPLACE_DEVICES[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$RECOVERY_PROGRESS" != "none" ]; then
|
if [ "$SYNC_ACTION" == "recover" ]; then
|
||||||
if [ -z "$result" ]; then result="WARNING"; fi
|
if [ -z "$result" ]; then result="WARNING"; fi
|
||||||
if [ -n "$info" ]; then info="$info. "; fi
|
if [ -n "$info" ]; then info="$info. "; fi
|
||||||
info="${info}Recovering: $RECOVERY_PERCENT%, remaining ${RECOVERY_REMAINING_MIN}min"
|
info="${info}Recovering: $SYNC_PERCENT%, remaining ${SYNC_REMAINING_MIN}min"
|
||||||
|
fi
|
||||||
|
if [ "$SYNC_ACTION" == "check" ]; then
|
||||||
|
if [ -n "$info" ]; then info="$info. "; fi
|
||||||
|
info="${info}Checking: $SYNC_PERCENT%, remaining ${SYNC_REMAINING_MIN}min"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$result" ]; then result="OK"; fi
|
if [ -z "$result" ]; then result="OK"; fi
|
||||||
|
@ -160,12 +169,10 @@ function printOutputAndExit {
|
||||||
echo -n " 'num active devices'=$NUM_ACTIVE_DEVICES;;;0;$NUM_DEVICES"
|
echo -n " 'num active devices'=$NUM_ACTIVE_DEVICES;;;0;$NUM_DEVICES"
|
||||||
echo -n " 'num failed devices'=${#FAILED_DEVICES[@]};;1;0;$NUM_DEVICES"
|
echo -n " 'num failed devices'=${#FAILED_DEVICES[@]};;1;0;$NUM_DEVICES"
|
||||||
echo -n " 'num spare devices'=$NUM_SPARE_DEVICES;;;0"
|
echo -n " 'num spare devices'=$NUM_SPARE_DEVICES;;;0"
|
||||||
if [ "$RECOVERY_PROGRESS" != "none" ]; then
|
if [ "$SYNC_ACTION" != "idle" ]; then
|
||||||
if [ -z "$result" ]; then result="WARNING"; fi
|
echo -n " 'sync progress'=$SYNC_NUM;0;;0;$SYNC_DEN"
|
||||||
if [ -n "$info" ]; then info="$info. "; fi
|
echo -n " 'sync speed [1/s]'=${SYNC_SPEED}K"
|
||||||
echo -n " 'recovery progress'=$RECOVERY_NUM;0;;0;$RECOVERY_DEN"
|
echo -n " 'sync remaining'=${SYNC_REMAINING_S}s"
|
||||||
echo -n " 'recovery speed [1/s]'=${RECOVERY_SPEED}K"
|
|
||||||
echo -n " 'recovery remaining'=${RECOVERY_REMAINING_S}s"
|
|
||||||
fi
|
fi
|
||||||
for dev in ${!DEVICE_STATE[@]}; do
|
for dev in ${!DEVICE_STATE[@]}; do
|
||||||
echo -n " 'dev $dev: ${DEVICE_STATE[$dev]}"
|
echo -n " 'dev $dev: ${DEVICE_STATE[$dev]}"
|
||||||
|
|
1
test/checking.input/md0/md/array_size
Normal file
1
test/checking.input/md0/md/array_size
Normal file
|
@ -0,0 +1 @@
|
||||||
|
default
|
1
test/checking.input/md0/md/array_state
Normal file
1
test/checking.input/md0/md/array_state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
clean
|
1
test/checking.input/md0/md/chunk_size
Normal file
1
test/checking.input/md0/md/chunk_size
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0
|
1
test/checking.input/md0/md/component_size
Normal file
1
test/checking.input/md0/md/component_size
Normal file
|
@ -0,0 +1 @@
|
||||||
|
976431104
|
1
test/checking.input/md0/md/degraded
Normal file
1
test/checking.input/md0/md/degraded
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0
|
1
test/checking.input/md0/md/dev-sda1/slot
Normal file
1
test/checking.input/md0/md/dev-sda1/slot
Normal file
|
@ -0,0 +1 @@
|
||||||
|
2
|
1
test/checking.input/md0/md/dev-sda1/state
Normal file
1
test/checking.input/md0/md/dev-sda1/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
in_sync
|
1
test/checking.input/md0/md/dev-sdb1/slot
Normal file
1
test/checking.input/md0/md/dev-sdb1/slot
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1
|
1
test/checking.input/md0/md/dev-sdb1/state
Normal file
1
test/checking.input/md0/md/dev-sdb1/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
in_sync
|
1
test/checking.input/md0/md/dev-sdc1/slot
Normal file
1
test/checking.input/md0/md/dev-sdc1/slot
Normal file
|
@ -0,0 +1 @@
|
||||||
|
0
|
1
test/checking.input/md0/md/dev-sdc1/state
Normal file
1
test/checking.input/md0/md/dev-sdc1/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
in_sync
|
1
test/checking.input/md0/md/last_sync_action
Normal file
1
test/checking.input/md0/md/last_sync_action
Normal file
|
@ -0,0 +1 @@
|
||||||
|
check
|
1
test/checking.input/md0/md/level
Normal file
1
test/checking.input/md0/md/level
Normal file
|
@ -0,0 +1 @@
|
||||||
|
raid1
|
1
test/checking.input/md0/md/max_read_errors
Normal file
1
test/checking.input/md0/md/max_read_errors
Normal file
|
@ -0,0 +1 @@
|
||||||
|
20
|
1
test/checking.input/md0/md/raid_disks
Normal file
1
test/checking.input/md0/md/raid_disks
Normal file
|
@ -0,0 +1 @@
|
||||||
|
3
|
1
test/checking.input/md0/md/rd0
Symbolic link
1
test/checking.input/md0/md/rd0
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
dev-sdc1
|
1
test/checking.input/md0/md/rd1
Symbolic link
1
test/checking.input/md0/md/rd1
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
dev-sdb1
|
1
test/checking.input/md0/md/rd2
Symbolic link
1
test/checking.input/md0/md/rd2
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
dev-sda1
|
1
test/checking.input/md0/md/sync_action
Normal file
1
test/checking.input/md0/md/sync_action
Normal file
|
@ -0,0 +1 @@
|
||||||
|
check
|
1
test/checking.input/md0/md/sync_completed
Normal file
1
test/checking.input/md0/md/sync_completed
Normal file
|
@ -0,0 +1 @@
|
||||||
|
1893234560 / 1952862208
|
1
test/checking.input/md0/md/sync_speed
Normal file
1
test/checking.input/md0/md/sync_speed
Normal file
|
@ -0,0 +1 @@
|
||||||
|
13718
|
1
test/checking.input/md0/queue/hw_sector_size
Normal file
1
test/checking.input/md0/queue/hw_sector_size
Normal file
|
@ -0,0 +1 @@
|
||||||
|
512
|
1
test/checking.output
Normal file
1
test/checking.output
Normal file
|
@ -0,0 +1 @@
|
||||||
|
OK: Checking: 96%, remaining 36min | 'raid level: raid1'=0 'size in blocks'=976431104 'num devices'=3 'num active devices'=3;;;0;3 'num failed devices'=0;;1;0;3 'num spare devices'=0;;;0 'sync progress'=1893234560;0;;0;1952862208 'sync speed [1/s]'=13718K 'sync remaining'=2173s 'dev sdc1: in_sync'=0 'dev sdb1: in_sync'=0 'dev sda1: in_sync'=0
|
|
@ -1 +1 @@
|
||||||
CRITICAL: Missing 1 of 3 devices. Recovering: 88%, remaining 108min | 'raid level: raid1'=0 'size in blocks'=976431104 'num devices'=3 'num active devices'=2;;;0;3 'num failed devices'=0;;1;0;3 'num spare devices'=1;;;0 'recovery progress'=1728697856;0;;0;1952862208 'recovery speed [1/s]'=17170K 'recovery remaining'=6527s 'dev sdd1: spare'=0 'dev sdc1: in_sync'=0 'dev sda1: in_sync'=0
|
CRITICAL: Missing 1 of 3 devices. Recovering: 88%, remaining 108min | 'raid level: raid1'=0 'size in blocks'=976431104 'num devices'=3 'num active devices'=2;;;0;3 'num failed devices'=0;;1;0;3 'num spare devices'=1;;;0 'sync progress'=1728697856;0;;0;1952862208 'sync speed [1/s]'=17170K 'sync remaining'=6527s 'dev sdd1: spare'=0 'dev sdc1: in_sync'=0 'dev sda1: in_sync'=0
|
||||||
|
|
Loading…
Reference in a new issue