Awk resource script

a guest Nov 17th, 2012 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for i in $(awk -F: '{print $2}' /etc/trueuserdomains); do top -bn 1 -u "$i"|awk '/^[0-9]/ {sumCpu +=$9; sumRam += $10;} END {if ((sumCpu > 0) || (sumRam > 0)) print "User '$i':\t\tTotal %RAM: ", sumRam, "\t\tTotal %CPU: ", sumCpu; else print "User '$i' is not showing resource usage";}'; done |sort -nk 5
RAW Paste Data
Want to get better at Bash?
Learn to code Bash in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!