1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
#!@@GOODSH@@
# -*- sh -*-
: << =cut
=head1 NAME
memory - Show memory stats based on top output
=head1 Applicable systems
Solaris systems with the package SUNWtop or other package containint
top installed.
=head1 CONFIGURATION
The following shows the default settings for this plugin:
[memory]
env.top /usr/local/bin/top
You can also set warning and critical limits with these env settings:
real_warning
real_critical
used_warning
used_critical
swapt_warning
swapu_warning
All sizes are calculated and warned against in MB.
=head1 AUTHOR
Unknown author
=head1 LICENSE
GPLv2
=head1 BUGS
=over 4
=item Reporting size
Fixme: Reporting size in MB is Wrong. Report bytes and let rrd scale units
=item Should use kstat
Fixme: Using kstat would be much better
=back
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. "$MUNIN_LIBDIR/plugins/plugin.sh"
TOP=${top:-/usr/local/bin/top}
if [ "$1" = "autoconf" ]; then
if [ -x $TOP ] ; then
echo yes
exit 0
else
echo "no (no executable: $TOP)"
exit 0
fi
fi
if [ "$1" = "config" ]; then
echo "graph_title Memory usage (in MB)"
echo 'graph_category system'
echo "real.label Physical mem"
echo "used.label Mem used"
echo "swapt.label Total swap"
echo "swapu.label Swap used"
print_warning real
print_critical real
print_warning used
print_critical used
print_warning swapt
print_critical swapt
print_warning swapu
print_critical swapu
exit 0
fi
# Linjen som grep'es ut kan se ut som dette:
#
# Memory: 320M real, 142M free, 129M swap in use, 1095M swap free
$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);
swapt = scale($8);
swapf = scale($11);
memused = real - free
swapu = swapt - swapf
print "real.value", real
print "used.value", memused
print "swapt.value", swapt
print "swapu.value", swapu
}'
# vim: syntax=sh ts=2 et
|