2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/bsd/openbsd-memory

37 lines
805 B
Plaintext
Raw Normal View History

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'
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));
used = scale(spliter($3,2));
2011-09-12 05:37:58 +02:00
free = scale($6);
total = used + free;
2011-09-12 05:37:58 +02:00
print "acti.value", acti
print "used.value", used
2011-09-12 05:37:58 +02:00
print "total.value", total
print "free.value", free
}'