mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Merge 6ce54ca9d6
into a9c6242e09
This commit is contained in:
commit
4d4960b7b6
1 changed files with 6 additions and 23 deletions
|
@ -92,26 +92,9 @@ OTHER_PRINT=""
|
||||||
[ -z "$OTHER_FIELD" ] || OTHER_PRINT="print \"$(clean_fieldname "$OTHER_FIELD")\", others_sum;"
|
[ -z "$OTHER_FIELD" ] || OTHER_PRINT="print \"$(clean_fieldname "$OTHER_FIELD")\", others_sum;"
|
||||||
|
|
||||||
ps ax --format "%cpu user" | tail +2 | \
|
ps ax --format "%cpu user" | tail +2 | \
|
||||||
awk -v USERS="$USERS" '
|
awk '{
|
||||||
# Store the CPU usage of each process - the mapping to the
|
arr[$2]+=$1
|
||||||
# user happens later. We cannot use the second column
|
}
|
||||||
# (username) directly, since it may be abbreviated (ending
|
END {
|
||||||
# with "+").
|
for (key in arr) printf("%s.value %s\n", key, arr[key])
|
||||||
{ CPU_USER[$2]=$1 }
|
}' | sort -k1,1
|
||||||
END {
|
|
||||||
others_sum = 0
|
|
||||||
split(USERS, user_array)
|
|
||||||
for (user in CPU_USER) {
|
|
||||||
m = match(USERS,user)
|
|
||||||
if (m != 0) {
|
|
||||||
_user=user
|
|
||||||
gsub(/[-.]/,"_",_user);
|
|
||||||
print _user, (CPU_USER[user])
|
|
||||||
} else
|
|
||||||
others_sum += CPU_USER[user]
|
|
||||||
}
|
|
||||||
'"$OTHER_PRINT"'
|
|
||||||
}' | while read -r user count; do
|
|
||||||
# apply fieldname cleanup
|
|
||||||
echo "$(clean_fieldname "$user").value $count"
|
|
||||||
done
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue