From owner-freebsd-stable@FreeBSD.ORG Sat Feb 23 03:43:03 2013 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7564F52E for ; Sat, 23 Feb 2013 03:43:03 +0000 (UTC) (envelope-from wollman@hergotha.csail.mit.edu) Received: from hergotha.csail.mit.edu (wollman-1-pt.tunnel.tserv4.nyc4.ipv6.he.net [IPv6:2001:470:1f06:ccb::2]) by mx1.freebsd.org (Postfix) with ESMTP id 3A93E9E1 for ; Sat, 23 Feb 2013 03:42:59 +0000 (UTC) Received: from hergotha.csail.mit.edu (localhost [127.0.0.1]) by hergotha.csail.mit.edu (8.14.5/8.14.5) with ESMTP id r1N3gvGN006701; Fri, 22 Feb 2013 22:42:57 -0500 (EST) (envelope-from wollman@hergotha.csail.mit.edu) Received: (from wollman@localhost) by hergotha.csail.mit.edu (8.14.5/8.14.4/Submit) id r1N3gu6U006698; Fri, 22 Feb 2013 22:42:56 -0500 (EST) (envelope-from wollman) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2gmmaHoB6p" Content-Transfer-Encoding: 7bit Message-ID: <20776.15040.300235.897884@hergotha.csail.mit.edu> Date: Fri, 22 Feb 2013 22:42:56 -0500 From: Garrett Wollman To: stable@freebsd.org Subject: A useful munin plugin for monitoring memory usage X-Mailer: VM 7.17 under 21.4 (patch 22) "Instant Classic" XEmacs Lucid X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (hergotha.csail.mit.edu [127.0.0.1]); Fri, 22 Feb 2013 22:42:57 -0500 (EST) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on hergotha.csail.mit.edu X-Mailman-Approved-At: Sat, 23 Feb 2013 04:02:33 +0000 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: lupe@lupe-christoph.de X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Feb 2013 03:43:03 -0000 --2gmmaHoB6p Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit 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: --2gmmaHoB6p Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit (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) } } ' --2gmmaHoB6p--