Closed dpremy closed 8 years ago
Thanks for the report. If it's the same code than the freebsd one you could write it like that:
elif is_freebsd || is_openbsd; then
iostat -c 2 | tail -n 1 | awk '{usage=100-$NF} END {printf("%5.1f%%", usage)}'
I let the issue open and wait for a PR :)
I don't have any FreeBSD to verify, but it should have the same tools, in which case iostat never gives a decimal output for cpu usage. This means the iostat awk gives the cpu status with one decimal place added, but it will always be ".0".
Possibly for BSD flavors we change the iostat line to the following to still keep the spacing, but trim out the unused decimal?
iostat -c 2 | tail -n 1 | awk '{usage=100-$NF} END {printf("%5.0f%%", usage)}'
@dpremy decimal is for consistency between systems. For example, in ArchLinux iostat return decimal. I try to avoid most of OS specific code for maintenance.
It should work now, don't hesitate to open a new issue if there's still a problem
OpenBSD isn't detected and the unknown iostat warning is displayed.
Simply copying FreeBSD's checks and command will work to support OpenBSD 6.0 amd64.
I'll try to make a pull request if I have some time later on.