diff --git a/plugins/system/cpubyuser b/plugins/system/cpubyuser index 04dc2c2f..39469981 100755 --- a/plugins/system/cpubyuser +++ b/plugins/system/cpubyuser @@ -39,6 +39,9 @@ . "$MUNIN_LIBDIR/plugins/plugin.sh" +[ "$USERS" = "ALL" ] && USERS=$(w --no-header | awk '{ print $1 }' | sort | uniq) + + if [ "$1" = "autoconf" ]; then if [ -n "$USERS" ]; then echo "yes" @@ -68,10 +71,6 @@ if [ "$1" = "config" ]; then exit fi -if [ "$USERS" = "ALL" ]; then - USERS=$( w | awk '{ print $1 }' ) -fi - top -b -n 1 | tail -n +8 | \ awk -v USERS="$USERS" ' { if ($2 != "USER") CPU_USER[$2]+=$9 }