@@ -105,7 +105,7 @@ fn_cteni_promennych () {
105105fn_treshold () {
106106fn_type
107107# Read how many 'reads' HD has
108- read TR zbytek < <( cat /sys/block/$DISK /stat 2> /dev/null) || exit_script " can not read stat file" 1
108+ read TR zb1 zb2 zb3 TW rest < <( cat /sys/block/$DISK /stat 2> /dev/null) || exit_script " can not read stat file" 1
109109# Prepare question
110110co=" json.temperature.current"
111111# Test if it is the first pass
@@ -123,9 +123,11 @@ else
123123 fi
124124fi
125125# Again read how many 'reads' are from HD stat file
126- read TR1 zbytek < <( cat /sys/block/$DISK /stat 2> /dev/null) || exit_script " can not read stat file" 1
127- # Diference between reads make our own threshold
128- TRESHOLD=$(( $TR1 - $TR ))
126+ read TR1 zb1 zb2 zb3 TW1 rest < <( cat /sys/block/$DISK /stat 2> /dev/null) || exit_script " can not read stat file" 1
127+ # Diference between readI/Os and writeI/Os make our own threshold
128+ TRESHOLDr=$(( $TR1 - $TR ))
129+ TRESHOLDw=$(( $TW1 - $TW ))
130+ TRESHOLD=$(( $TRESHOLDr + $TRESHOLDw ))
129131return $ERSTE_GANG
130132}
131133
165167fn_temp () {
166168ACT=$ACTIVE
167169ACTIVE=0
168- read TR zbytek < <( cat /sys/block/$DISK /stat 2> /dev/null)
170+ read TR zb1 zb2 zb3 TW rest < <( cat /sys/block/$DISK /stat 2> /dev/null)
171+ TRW=$(( $TR + $TW ))
169172co=" json.temperature.current"
170173TEMP=` ptam_se <<< $( Dotaz )` && ACTIVE=1
171174[ $TEMP ] && echo $TEMP > $OPERATIVNI_DIR /$DISK /temp
@@ -177,7 +180,7 @@ echo $ACTIVE > $OPERATIVNI_DIR/$DISK/activity
177180# initilization of variables
178181ACTIVE=1
179182pocatecni_cas=$( date +%s)
180- TR1 =0
183+ TRW1 =0
181184echo " $( date +' %F %T' ) $DISK started" >> " $LOG "
182185
183186
@@ -197,11 +200,12 @@ while :; do
197200 [ $ACTIVE -eq 0 ] && continue
198201
199202 # if threshold is bigger than our own default, downcount again
200- [ $(( $TR - $TR1 )) -gt $TRESHOLD ] && pocatecni_cas=$( date +%s)
203+ # [ $(( $TRW - $TRW1 )) -gt $TRESHOLD ] && pocatecni_cas=$(date +%s) && echo "$(date +'%F %T') $DISK set new timestamp" >> "$LOG"
204+ [ $(( $TRW - $TRW1 )) -gt $TRESHOLD ] && pocatecni_cas=$( date +%s)
201205
202206 # HD timeout, go to sleep (switch to standby mode)
203207 [ $(( $pocatecni_cas + $SPAT_ZA )) -lt $( date +%s) ] && Uspi
204208
205209 # clear reads
206- TR1= $TR
210+ TRW1= $TRW
207211done
0 commit comments