You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On a Mac, with an external disk or a dmg mounted, the columns in the output of the iostat command get shifted to the right (each disk adds 3 columns). This causes the result of uw_load to be very wrong.
Reproduction steps:
Mount a dmg to add a new volume.
Usagewatch.uw_load# => 11.0
Eject the dmg:
Usagewatch.uw_load# => 2.78
Why is this happening?
The command used to get the current CPU load is iostat -w1 -c 2 | awk '{print $7}'.
That's happening because, with a mounted volume, the output of iostat -w1 -c 2 contains 3 more columns to the left of the load average columns, which messes up the result of the awk command.
# With an external volume:
$ iostat -w1 -c 2
disk0 disk2 cpu load average
KB/t tps MB/s KB/t tps MB/s us sy id 1m 5m 15m
18.83 29 0.53 352.03 0 0.00 15 13 72 1.97 2.44 2.99
4.00 14 0.05 0.00 0 0.00 6 9 85 1.97 2.44 2.99
# Without an external volume:
$ iostat -w1 -c 2
disk0 cpu load average
KB/t tps MB/s us sy id 1m 5m 15m
18.83 29 0.53 15 13 72 2.54 2.53 3.01
6.13 30 0.18 32 24 44 2.90 2.60 3.03
Potential fix: use echo $x | awk '{print $(NF-2)}'. This would take the 3rd to last column (ie 3rd starting from the rightmost column) instead of the 7th (starting from the left). Let me know if you can see any good reason not to do this, otherwise I'm happy to submit a PR!
On a Mac, with an external disk or a dmg mounted, the columns in the output of the iostat command get shifted to the right (each disk adds 3 columns). This causes the result of
uw_load
to be very wrong.Reproduction steps:
Mount a dmg to add a new volume.
Eject the dmg:
Why is this happening?
The command used to get the current CPU load is
iostat -w1 -c 2 | awk '{print $7}'
.That's happening because, with a mounted volume, the output of
iostat -w1 -c 2
contains 3 more columns to the left of the load average columns, which messes up the result of theawk
command.Cc @Lyriaaw
The text was updated successfully, but these errors were encountered: