dot

packages and services management
Log | Files | Refs | README

commit 69fef782e94b46bb055e131e7b661356720fb1df
parent 2287a00679467602817980d3704bb37d39b46298
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Thu, 29 Jun 2017 08:42:03 +0200

cpu percent

Diffstat:
Mbin/status | 18++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/bin/status b/bin/status @@ -44,10 +44,10 @@ status_memory() ;; (FreeBSD) - pagesize=$(sysctl -n hw.pagesize) - inactive=$(($(sysctl -n vm.stats.vm.v_inactive_count) * pagesize)) - unused=$(( $(sysctl -n vm.stats.vm.v_free_count) * pagesize)) - cache=$(( $(sysctl -n vm.stats.vm.v_cache_count) * pagesize)) + pgsize=$(sysctl -n hw.pagesize) + inactive=$(($(sysctl -n vm.stats.vm.v_inactive_count) * pgsize)) + unused=$(( $(sysctl -n vm.stats.vm.v_free_count) * pgsize)) + cache=$(( $(sysctl -n vm.stats.vm.v_cache_count) * pgsize)) total=$(( $(sysctl -n hw.physmem) / 1024 / 1024)) free=$(((inactive + unused + cache) / 1024 / 1024)) used=$((total - free)) @@ -59,13 +59,19 @@ status_memory() ;; esac - printf 'MEM %sM/%sM' "$((used))" "$((total))" + printf 'MEM %s/%sM' "$((used))" "$((total))" } status_cpu() { - uptime | sed -r 's/.*load[^0-9]*([0-9.]*).*/CPU \1/' + top -bn 1 | + sed -nr 's/.*[Cc][Pp][Uu][ :]*([0-9.]+)%.*/CPU \1%/ p' | + tr -d '\n' + + uptime | + sed -r 's/.*load[^0-9]*([0-9.]*).*/ \1/' | + tr -d '\n' }