Open aurelienshz opened 4 years ago
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