2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/system/top-free-memory
2012-02-13 18:24:46 +01:00

36 lines
767 B
Bash
Executable File

#!/bin/sh
#
# Initial Version 1.0 2009/05/18 14:00:01 BANT
# Anzeige von FREE Memory mit dem TOP Befehl aus SUN OS
#
#%# family=manual
TOP=/usr/local/bin/top
if [ "$1" = "config" ]; then
echo "graph_title FREE Memory usage (in MB)"
echo 'graph_category system'
echo "free.label Free memory"
exit 0
fi
# Linjen som grep'es ut kan se ut som dette:
#
# Memory: 16G phys mem, 6030M free mem, 32G swap, 32G free swap
$TOP -n -u | nawk '
function scale(value) {
if (value ~ /G$/) { sub("G", "", value); value *= 1024 }
else if (value ~ /M$/) sub("M", "", value)
else if (value ~ /K$/) { sub("K", "", value); value /= 1024 }
else value /= 1024 * 1024;
return value;
}
/^Memory/ {
free = scale($5);
print "free.value", free
}'