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-memory
Veres Lajos fba800ae52 typofixes - https://github.com/vlajos/misspell_fixer
Suspicious sections:
plugins/mail/postfix_mail_stats		recieved.label
plugins/nginx/nginx_vhost_traffic
2015-03-02 11:51:38 +00:00

67 lines
1.6 KiB
Bash
Executable File

#!/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" som 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
}'