From 8a481afc06da254a98d2c99b2fce6f739d75d3ca Mon Sep 17 00:00:00 2001 From: northox Date: Mon, 12 Sep 2011 05:37:58 +0200 Subject: [PATCH] Initial version --- plugins/other/openbsd-memory | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 plugins/other/openbsd-memory diff --git a/plugins/other/openbsd-memory b/plugins/other/openbsd-memory new file mode 100755 index 00000000..9c4741e2 --- /dev/null +++ b/plugins/other/openbsd-memory @@ -0,0 +1,39 @@ +#!/bin/sh +if [ "$1" = "config" ]; then + echo "graph_title Memory usage (in MB)" + echo 'graph_category system' + echo "acti.label Active momery" + echo "total.label Memory total" + echo "free.label Free memory" + echo "swap.label Swap in use" + echo "swapt.label Swap total" + exit 0 +fi + +# Memory: Real: 14M/69M act/tot Free: 173M Swap: 0K/612M used/tot + +top -un | nawk ' +function scale(v) { + if (value ~ /G$/) { sub("G", "", v); v *= 1024 } + else if (v ~ /M$/) sub("M", "", v) + else if (v ~ /K$/) { sub("K", "", v); v /= 1024 } + else v /= 1024 * 1024; + return v; +} +function spliter(v, i) { + split(v,a,"/"); + return(a[i]); +} +/^Memory/ { + acti = scale(spliter($3,1)); + total = scale(spliter($3,2)); + free = scale($6); + swap = scale(spliter($8,1)); + swapt = scale(spliter($8,2)); + + print "acti.value", acti + print "total.value", total + print "free.value", free + print "swap.value", swap + print "swapt.value", swapt +}'