Skip to content

Commit 1c4fcf2

Browse files
authored
Add files via upload
Fix fn
1 parent 11d3718 commit 1c4fcf2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

conkys_start.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn_cteni_promennych () {
105105
fn_treshold () {
106106
fn_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
110110
co="json.temperature.current"
111111
# Test if it is the first pass
@@ -123,9 +123,11 @@ else
123123
fi
124124
fi
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 ))
129131
return $ERSTE_GANG
130132
}
131133

@@ -165,7 +167,8 @@ fi
165167
fn_temp () {
166168
ACT=$ACTIVE
167169
ACTIVE=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 ))
169172
co="json.temperature.current"
170173
TEMP=`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
178181
ACTIVE=1
179182
pocatecni_cas=$(date +%s)
180-
TR1=0
183+
TRW1=0
181184
echo "$(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
207211
done

0 commit comments

Comments
 (0)