Merge lp:~gurnec/byobu/trunk-bugfix-1626218 into lp:byobu

Proposed by Christopher Gurnee
Status: Needs review
Proposed branch: lp:~gurnec/byobu/trunk-bugfix-1626218
Merge into: lp:byobu
Diff against target: 51 lines (+8/-11)
1 file modified
usr/lib/byobu/disk_io (+8/-11)
To merge this branch: bzr merge lp:~gurnec/byobu/trunk-bugfix-1626218
Reviewer Review Type Date Requested Status
Dustin Kirkland  Pending
Review via email: mp+379352@code.launchpad.net

Commit message

usr/lib/byobu/disk_io: LP: #1626218
remove disk_io status notification when it drops below the $DISK_IO_THRESHOLD

Description of the change

When the disk_io status notification is enabled and the machine's IO first exceeds $DISK_IO_THRESHOLD (defaults to 50kB/s), the status notification appears. If both the read and write IO drop below the threshold, the status notification is not removed, and instead its last value is displayed until the threshold is later exceeded and the old notification is overwritten.

This patch removes the notification once the IO drops below the threshold, closing LP #1626218.

To post a comment you must log in.

Unmerged revisions

2644. By Christopher Gurnee

usr/lib/byobu/disk_io: LP: #1626218
remove disk_io status notification when it drops below the $DISK_IO_THRESHOLD

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'usr/lib/byobu/disk_io'
--- usr/lib/byobu/disk_io 2019-06-12 00:01:41 +0000
+++ usr/lib/byobu/disk_io 2020-02-17 20:38:56 +0000
@@ -53,15 +53,13 @@
53 [ -e "$part" ] || return53 [ -e "$part" ] || return
54 getdisk "$part"54 getdisk "$part"
55 local disk=${_RET}55 local disk=${_RET}
56 local t2=$(date +%s) t1=56 local t2=$(date +%s) t1= over_threshold=0
57 for i in "read" "write"; do57 for i in "read" "write"; do
58 local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/disk.$i"58 local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/disk.$i"
59 t1=$(stat -c %Y "$cache") 2>/dev/null || t1=059 t1=$(stat -c %Y "$cache") 2>/dev/null || t1=0
60 local unit="kB/s"60 local unit="kB/s"
61 local rate=0 x1=0 x2=0 symbol= unit=61 local rate=0 x1=0 x2=0 symbol= unit=
62 if [ $t2 -le $t1 ]; then62 if [ $t2 -gt $t1 ]; then
63 rate=0
64 else
65 [ -r "$cache" ] && read x1 < "$cache" || x1=063 [ -r "$cache" ] && read x1 < "$cache" || x1=0
66 local a1= a2= a3= a4= a5= a6= a7= a8= a9= a10=64 local a1= a2= a3= a4= a5= a6= a7= a8= a9= a10=
67 read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 other < "/sys/block/$disk/stat"65 read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 other < "/sys/block/$disk/stat"
@@ -77,9 +75,9 @@
77 if [ $rate -lt $DISK_IO_THRESHOLD ]; then75 if [ $rate -lt $DISK_IO_THRESHOLD ]; then
78 # Below threshold, don't print76 # Below threshold, don't print
79 continue77 continue
80 elif [ "$rate" -lt 0 ]; then78 fi
81 rate=079 over_threshold=1
82 elif [ "$rate" -gt 1048576 ]; then80 if [ "$rate" -gt 1048576 ]; then
83 unit="GB/s"81 unit="GB/s"
84 fpdiv "$rate" 1048576 082 fpdiv "$rate" 1048576 0
85 rate=${_RET}83 rate=${_RET}
@@ -90,13 +88,12 @@
90 else88 else
91 unit="kB/s"89 unit="kB/s"
92 fi90 fi
93 fi
94 if [ -z "$rate" ] || [ "$rate" = "0" ]; then
95 rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/disk_io"*
96 else
97 color b M W; printf "%s%s" "$symbol" "$rate"; color -; color M W; printf "%s" "$unit"; color --91 color b M W; printf "%s%s" "$symbol" "$rate"; color -; color M W; printf "%s" "$unit"; color --
98 fi92 fi
99 done93 done
94 if [ "$over_threshold" = "0" ]; then
95 rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/disk_io"*
96 fi
100}97}
10198
102# vi: syntax=sh ts=4 noexpandtab99# vi: syntax=sh ts=4 noexpandtab

Subscribers

People subscribed via source and target branches