From 617994ca9db5688cef911ff45f70fb95a0664a7c Mon Sep 17 00:00:00 2001 From: northox Date: Sat, 24 Sep 2011 17:59:18 +0200 Subject: [PATCH] Initial version --- plugins/other/openbsd-swap | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 plugins/other/openbsd-swap diff --git a/plugins/other/openbsd-swap b/plugins/other/openbsd-swap new file mode 100755 index 00000000..e2533fd5 --- /dev/null +++ b/plugins/other/openbsd-swap @@ -0,0 +1,33 @@ +#!/bin/sh +# @author northox +# Mantor Organization +# +if [ "$1" = "config" ]; then + echo "graph_title Swap usage (in MB)" + echo 'graph_category system' + echo "swap.label Swap used" + 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/ { + swap = scale(spliter($8,1)); + swapt = scale(spliter($8,2)); + + print "swap.value", swap + print "swapt.value", swapt +}'