2011-09-12 05:37:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo "graph_title Memory usage (in MB)"
|
|
|
|
echo 'graph_category system'
|
2011-09-24 17:42:01 +02:00
|
|
|
echo "acti.label Active"
|
|
|
|
echo "used.label Used"
|
|
|
|
echo "total.label Total"
|
|
|
|
echo "free.label Free"
|
2011-09-12 05:37:58 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot
|
|
|
|
|
|
|
|
top -un | nawk '
|
|
|
|
function scale(v) {
|
2011-09-26 14:16:21 +02:00
|
|
|
if (v ~ /G$/) { sub("G", "", v);v *= 1024 }
|
2011-09-12 05:37:58 +02:00
|
|
|
else if (v ~ /M$/) sub("M", "", v)
|
2011-09-26 14:16:21 +02:00
|
|
|
else if (v ~ /K$/) { sub("K", "", v);v /= 1024 }
|
2011-09-12 05:37:58 +02:00
|
|
|
else v /= 1024 * 1024;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
function spliter(v, i) {
|
2011-09-26 14:16:21 +02:00
|
|
|
split(v, a, "/");
|
2011-09-12 05:37:58 +02:00
|
|
|
return(a[i]);
|
|
|
|
}
|
|
|
|
/^Memory/ {
|
|
|
|
acti = scale(spliter($3,1));
|
2011-09-24 17:42:01 +02:00
|
|
|
used = scale(spliter($3,2));
|
2011-09-12 05:37:58 +02:00
|
|
|
free = scale($6);
|
2011-09-24 17:42:01 +02:00
|
|
|
total = used + free;
|
2011-09-12 05:37:58 +02:00
|
|
|
|
|
|
|
print "acti.value", acti
|
2011-09-24 17:42:01 +02:00
|
|
|
print "used.value", used
|
2011-09-12 05:37:58 +02:00
|
|
|
print "total.value", total
|
|
|
|
print "free.value", free
|
|
|
|
}'
|