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

Proposed by Christopher Gurnee on 2020-02-17
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  2020-02-17 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 on 2020-02-17

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
1=== modified file 'usr/lib/byobu/disk_io'
2--- usr/lib/byobu/disk_io 2019-06-12 00:01:41 +0000
3+++ usr/lib/byobu/disk_io 2020-02-17 20:38:56 +0000
4@@ -53,15 +53,13 @@
5 [ -e "$part" ] || return
6 getdisk "$part"
7 local disk=${_RET}
8- local t2=$(date +%s) t1=
9+ local t2=$(date +%s) t1= over_threshold=0
10 for i in "read" "write"; do
11 local cache="$BYOBU_RUN_DIR/cache.$BYOBU_BACKEND/disk.$i"
12 t1=$(stat -c %Y "$cache") 2>/dev/null || t1=0
13 local unit="kB/s"
14 local rate=0 x1=0 x2=0 symbol= unit=
15- if [ $t2 -le $t1 ]; then
16- rate=0
17- else
18+ if [ $t2 -gt $t1 ]; then
19 [ -r "$cache" ] && read x1 < "$cache" || x1=0
20 local a1= a2= a3= a4= a5= a6= a7= a8= a9= a10=
21 read a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 other < "/sys/block/$disk/stat"
22@@ -77,9 +75,9 @@
23 if [ $rate -lt $DISK_IO_THRESHOLD ]; then
24 # Below threshold, don't print
25 continue
26- elif [ "$rate" -lt 0 ]; then
27- rate=0
28- elif [ "$rate" -gt 1048576 ]; then
29+ fi
30+ over_threshold=1
31+ if [ "$rate" -gt 1048576 ]; then
32 unit="GB/s"
33 fpdiv "$rate" 1048576 0
34 rate=${_RET}
35@@ -90,13 +88,12 @@
36 else
37 unit="kB/s"
38 fi
39- fi
40- if [ -z "$rate" ] || [ "$rate" = "0" ]; then
41- rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/disk_io"*
42- else
43 color b M W; printf "%s%s" "$symbol" "$rate"; color -; color M W; printf "%s" "$unit"; color --
44 fi
45 done
46+ if [ "$over_threshold" = "0" ]; then
47+ rm -f "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/disk_io"*
48+ fi
49 }
50
51 # vi: syntax=sh ts=4 noexpandtab

Subscribers

People subscribed via source and target branches