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:

(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)
        }
}
'

_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscr...@freebsd.org"

Reply via email to