summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@cryptonomic.net>2021-10-19 09:37:20 -0400
committerAndrew Cady <d@cryptonomic.net>2021-10-19 09:37:20 -0400
commit4671ce5bdc54e615311f6f47014ea9fa1d8c90fa (patch)
tree4fa75f03d4d143a2f7961384252a759a90e17fb5
parentc524ba32d4f462e9e58e5a63dd34994c5456ab8a (diff)
ioslay: keep 10 iterations worth of data from iotop
-rwxr-xr-xioslay-firefox30
1 files changed, 22 insertions, 8 deletions
diff --git a/ioslay-firefox b/ioslay-firefox
index eac3184..d56553f 100755
--- a/ioslay-firefox
+++ b/ioslay-firefox
@@ -21,22 +21,36 @@ set -- $(web_content_pids | tac)
21 21
22set -- $(printf "\055\055pid=%s " $*) 22set -- $(printf "\055\055pid=%s " $*)
23 23
24log=
24over_count=0 25over_count=0
25sudo -- iotop -qq -b "$@" | 26sudo -- iotop -qq -b "$@" |
26 while read line 27 while read line
27 do 28 do
28 case "$line" in 29 case "$line" in
29 "Total DISK"*) 30 "Total DISK"*)
30 if [ "$OVER" ] 31 if [ "$over" ]
31 then 32 then
32 over_count=$((over_count + 1)) 33 log="$log 1"
33 if [ "$over_count" -gt 3 ]
34 then
35 fireslay
36 fi
37 over= 34 over=
38 else 35 else
39 over_count=0 36 log="$log 0"
37 fi
38 set -- $log
39 while [ $# -gt 10 ]
40 do
41 shift
42 done
43 log=$*
44
45 total=0
46 echo "log=$log" >&2
47 for n in $log
48 do
49 total=$((total+n))
50 done
51 if [ "$total" -gt 5 ]
52 then
53 fireslay
40 fi 54 fi
41 ;; 55 ;;
42 "Current DISK"*) continue ;; 56 "Current DISK"*) continue ;;
@@ -45,7 +59,7 @@ sudo -- iotop -qq -b "$@" |
45 pct=${10%.*} 59 pct=${10%.*}
46 if [ $pct -gt 90 ] 60 if [ $pct -gt 90 ]
47 then 61 then
48 printf '[%d] %s%% %s\n' "$over_count" "${10}" "${12}" >&2 62 printf '[%d] %s%% %s\n' "$total" "${10}" "${12}" >&2
49 over=y 63 over=y
50 fi 64 fi
51 ;; 65 ;;