Browse Source

Added support for 'check' sync progress

master
Gitea 2 years ago
parent
commit
67d558dd2d
  1. 51
      check_mdstat.sh
  2. 1
      test/checking.input/md0/md/array_size
  3. 1
      test/checking.input/md0/md/array_state
  4. 1
      test/checking.input/md0/md/chunk_size
  5. 1
      test/checking.input/md0/md/component_size
  6. 1
      test/checking.input/md0/md/degraded
  7. 1
      test/checking.input/md0/md/dev-sda1/slot
  8. 1
      test/checking.input/md0/md/dev-sda1/state
  9. 1
      test/checking.input/md0/md/dev-sdb1/slot
  10. 1
      test/checking.input/md0/md/dev-sdb1/state
  11. 1
      test/checking.input/md0/md/dev-sdc1/slot
  12. 1
      test/checking.input/md0/md/dev-sdc1/state
  13. 1
      test/checking.input/md0/md/last_sync_action
  14. 1
      test/checking.input/md0/md/level
  15. 1
      test/checking.input/md0/md/max_read_errors
  16. 1
      test/checking.input/md0/md/raid_disks
  17. 1
      test/checking.input/md0/md/rd0
  18. 1
      test/checking.input/md0/md/rd1
  19. 1
      test/checking.input/md0/md/rd2
  20. 1
      test/checking.input/md0/md/sync_action
  21. 1
      test/checking.input/md0/md/sync_completed
  22. 1
      test/checking.input/md0/md/sync_speed
  23. 1
      test/checking.input/md0/queue/hw_sector_size
  24. 1
      test/checking.output
  25. 2
      test/recovering.output

51
check_mdstat.sh

@ -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_ACTIVE_DEVICES=0 # int with number of active devices in raid
NUM_SPARE_DEVICES=0 # int with number of spare devices in raid
RECOVERY_PROGRESS= # float in percent
RECOVERY_SPEED= # sync speed in K/s
rYNC_ACTION= # "idle", "check" or "recover"
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 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
@ -71,15 +72,19 @@ function getDataFromSys {
CHUNK_SIZE_IN_BYTES=$(<$INPUT/chunk_size)
SIZE_IN_BLOCKS=$(<$INPUT/component_size)
STATE=$(<$INPUT/array_state)
RECOVERY_PROGRESS=$(<$INPUT/sync_completed)
RECOVERY_SPEED=$(<$INPUT/sync_speed)
SYNC_ACTION=$(<$INPUT/sync_action)
if [ "$SYNC_ACTION" != "idle" ]; then
SYNC_PROGRESS=$(<$INPUT/sync_completed)
SYNC_SPEED=$(<$INPUT/sync_speed)
fi
log "LEVEL = $LEVEL"
log "STATE = $STATE"
log "CHUNK_SIZE_IN_BYTES = $CHUNK_SIZE_IN_BYTES"
log "SIZE_IN_BLOCKS = $SIZE_IN_BLOCKS"
log "RECOVERY_PROGRESS = $RECOVERY_PROGRESS"
log "RECOVERY_SPEED = $RECOVERY_SPEED"
log "SYNC_ACTION = $SYNC_ACTION"
log "SYNC_PROGRESS = $SYNC_PROGRESS"
log "SYNC_SPEED = $SYNC_SPEED"
for dev in `find $INPUT -type d -name 'dev-*' -printf "%f\n"`; do
local deviceName=${dev:4}
@ -106,15 +111,15 @@ function getDataFromSys {
log "FAULTY_DEVICES = ${FAULTY_DEVICES[*]}"
log "TO_REPLACE_DEVICES = ${TO_REPLACE_DEVICES[*]}"
if [ "$RECOVERY_PROGRESS" != "none" ]; then
RECOVERY_NUM=${RECOVERY_PROGRESS% /*}
log "'$RECOVERY_NUM'"
RECOVERY_DEN=${RECOVERY_PROGRESS#*/ }
log "'$RECOVERY_DEN'"
RECOVERY_PERCENT=$(($RECOVERY_NUM*100/$RECOVERY_DEN))
if [ "$SYNC_ACTION" != "idle" ]; then
SYNC_NUM=${SYNC_PROGRESS% /*}
log "'$SYNC_NUM'"
SYNC_DEN=${SYNC_PROGRESS#*/ }
log "'$SYNC_DEN'"
SYNC_PERCENT=$(($SYNC_NUM*100/$SYNC_DEN))
BLOCK_SIZE=$(<$(dirname $INPUT)/queue/hw_sector_size)
RECOVERY_REMAINING_S=$(( ($RECOVERY_DEN-$RECOVERY_NUM)*$BLOCK_SIZE/1024/$RECOVERY_SPEED))
RECOVERY_REMAINING_MIN=$(($RECOVERY_REMAINING_S/60))
SYNC_REMAINING_S=$(( ($SYNC_DEN-$SYNC_NUM)*$BLOCK_SIZE/1024/$SYNC_SPEED))
SYNC_REMAINING_MIN=$(($SYNC_REMAINING_S/60))
fi
}
@ -140,10 +145,14 @@ function printOutputAndExit {
info="${info}These devices should be replaced: ${!TO_REPLACE_DEVICES[@]}"
fi
if [ "$RECOVERY_PROGRESS" != "none" ]; then
if [ "$SYNC_ACTION" == "recover" ]; then
if [ -z "$result" ]; then result="WARNING"; 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
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 failed devices'=${#FAILED_DEVICES[@]};;1;0;$NUM_DEVICES"
echo -n " 'num spare devices'=$NUM_SPARE_DEVICES;;;0"
if [ "$RECOVERY_PROGRESS" != "none" ]; then
if [ -z "$result" ]; then result="WARNING"; fi
if [ -n "$info" ]; then info="$info. "; fi
echo -n " 'recovery progress'=$RECOVERY_NUM;0;;0;$RECOVERY_DEN"
echo -n " 'recovery speed [1/s]'=${RECOVERY_SPEED}K"
echo -n " 'recovery remaining'=${RECOVERY_REMAINING_S}s"
if [ "$SYNC_ACTION" != "idle" ]; then
echo -n " 'sync progress'=$SYNC_NUM;0;;0;$SYNC_DEN"
echo -n " 'sync speed [1/s]'=${SYNC_SPEED}K"
echo -n " 'sync remaining'=${SYNC_REMAINING_S}s"
fi
for dev in ${!DEVICE_STATE[@]}; do
echo -n " 'dev $dev: ${DEVICE_STATE[$dev]}"

1
test/checking.input/md0/md/array_size

@ -0,0 +1 @@
default

1
test/checking.input/md0/md/array_state

@ -0,0 +1 @@
clean

1
test/checking.input/md0/md/chunk_size

@ -0,0 +1 @@
0

1
test/checking.input/md0/md/component_size

@ -0,0 +1 @@
976431104

1
test/checking.input/md0/md/degraded

@ -0,0 +1 @@
0

1
test/checking.input/md0/md/dev-sda1/slot

@ -0,0 +1 @@
2

1
test/checking.input/md0/md/dev-sda1/state

@ -0,0 +1 @@
in_sync

1
test/checking.input/md0/md/dev-sdb1/slot

@ -0,0 +1 @@
1

1
test/checking.input/md0/md/dev-sdb1/state

@ -0,0 +1 @@
in_sync

1
test/checking.input/md0/md/dev-sdc1/slot

@ -0,0 +1 @@
0

1
test/checking.input/md0/md/dev-sdc1/state

@ -0,0 +1 @@
in_sync

1
test/checking.input/md0/md/last_sync_action

@ -0,0 +1 @@
check

1
test/checking.input/md0/md/level

@ -0,0 +1 @@
raid1

1
test/checking.input/md0/md/max_read_errors

@ -0,0 +1 @@
20

1
test/checking.input/md0/md/raid_disks

@ -0,0 +1 @@
3

1
test/checking.input/md0/md/rd0

@ -0,0 +1 @@
dev-sdc1

1
test/checking.input/md0/md/rd1

@ -0,0 +1 @@
dev-sdb1

1
test/checking.input/md0/md/rd2

@ -0,0 +1 @@
dev-sda1

1
test/checking.input/md0/md/sync_action

@ -0,0 +1 @@
check

1
test/checking.input/md0/md/sync_completed

@ -0,0 +1 @@
1893234560 / 1952862208

1
test/checking.input/md0/md/sync_speed

@ -0,0 +1 @@
13718

1
test/checking.input/md0/queue/hw_sector_size

@ -0,0 +1 @@
512

1
test/checking.output

@ -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

2
test/recovering.output

@ -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…
Cancel
Save