标签:
转
#!/bin/sh
mem=`free -m | awk ‘NR==2{print $2}‘`
ps aux | sort -k 4 -r | awk ‘$4 ~ /^[0-9]/ && $4>0 {print $4,$11}‘ | awk ‘{print $1/100*mem" "$2}‘ mem=$mem | sort -k 2 | awk ‘
{
a[$2] += $1;
b[$2]++;
total += $1;
total++;
}
END{
for(i in a){
t=i;
gsub(/:|.*\//, "", t);
printf "%10s %s\n" ,a[i]"MB", t"["b[i]"]";
}
print "Memory Total: "mem"MB, used: "total"MB, free: "mem-total"MB."
}‘ mem=$mem | sort -n -r
标签:
原文地址:http://www.cnblogs.com/hanxing/p/4267772.html