Repository
Munin (contrib)
Last change
2020-03-26
Graph Categories
Family
manual
Keywords
Language
Shell

top-memory

Sadly there is no documentation for this plugin.

#!/bin/sh
#
# $Log$
# Revision 1.4.2.1  2005/03/07 19:06:13  jimmyo
# sunos/memory repaired (SF#1143610).
#
# Revision 1.4  2004/05/20 19:02:38  jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.3  2004/05/15 21:33:30  jimmyo
# "Upped" some plugins from contrib/manual to manual or auto.
#
# Revision 1.2  2004/05/09 20:42:08  jimmyo
# Fixed problem with sunos/memory, when memory was reported in gigabytes (SF#930964).
#
# Revision 1.1  2004/01/02 18:50:01  jimmyo
# Renamed occurrences of lrrd -> munin
#
# Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
# Revision 1.3 2009/05/18 14:00:01 BANT
# Update for Free Memory
#
#%# family=manual


TOP=/usr/local/bin/top

if [ "$1" = "config" ]; then

        echo "graph_title Memory usage (in MB)"
	echo 'graph_category system'
	echo "real.label Physical memory"
        echo "free.label Free memory"
	echo "swap.label Swap in use"
        echo "swapf.label Swap free"
        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/ {
  real  = scale($2);
  free  = scale($5);
  swap  = scale($8);
  swapf = scale($10);

  print "real.value", real
  print "free.value", free
  print "swap.value", swap
  print "swapf.value", swapf
}'