Date: Fri, 22 Feb 2013 22:42:56 -0500 From: Garrett Wollman <wollman@bimajority.org> To: stable@freebsd.org Cc: lupe@lupe-christoph.de Subject: A useful munin plugin for monitoring memory usage Message-ID: <20776.15040.300235.897884@hergotha.csail.mit.edu>
index | next in thread | raw e-mail
[-- Attachment #1 --]
We were having some memory starvation issues (which it turned out were
caused by our backup system), and I found it useful to create a munin
plugin to monitor UMA statistics (as displayed by 'vmstat -z'). As
I'm not interested in dealing with github.com, I thought I would share
it with the people most likely to benefit. Here's an example of the
graph that gets generated:
[-- Attachment #2 --]
(hopefully mailman will let the image through). The plugin itself
(undoubtedly not in the best of style) follows.
-GAWollman
#!/bin/sh
#
# Plugin to monitor FreeBSD Unified Memory Allocator
# (UMA) statistics from "vmstat -z"
# Based on the nfsd (NFS server statistics) plugin.
#
#%# family=auto
#%# capabilities=autoconf
getnames () {
/usr/bin/vmstat -z | awk -F: 'NR > 2 && NF > 1 { print $1 }'
}
if [ "$1" = "autoconf" ]; then
if /usr/bin/vmstat -z 2>/dev/null | \
egrep '^ITEM[[:space:]]+' >/dev/null; then
echo yes
exit 0
else
echo no
exit 0
fi
fi
if [ "$1" = "config" ]; then
area='AREA'
echo 'graph_title FreeBSD Unified Memory Allocator'
echo 'graph_vlabel bytes'
echo 'graph_total total'
echo 'graph_category system'
getnames | while read label; do
a=$(printf "%s" "$label" | tr -C 'A-Za-z0-9_' '_')
echo "$a.label $label"
echo "$a.type GAUGE"
echo "$a.min 0"
echo "$a.draw $area"
area='STACK'
done
exit 0
fi
/usr/bin/vmstat -z | awk -F '[:,] +' '
NR > 2 && NF > 1 {
name=$1
gsub("[^A-Za-z0-9_]", "_", name)
print name ".value " $2*$4
if($3 > 0) {
print name ".warning " int($2*$3*0.92)
print name ".critical " int($2*$3*0.95)
}
}
'
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20776.15040.300235.897884>
