munin plugin for gstat
gstat(8) is an utility that shows GEOM providers (and consumers) statistics.
It would be useful to have a munin plugin that plots IO activity if you have a storage box or a similar setup where there's a lot of disk action going on.
The code is for Python 2.6; if you're running 3.x you need to make slight adjustments (like print). Usage instructions are in the comments.
#!/usr/bin/env python ''' Munin plugin to monitor I/O transactions of geom(4) devices on FreeBSD as reported by gstat(8). To get the list of devices you might want to monitor, run gstat. If your device contains '/', substitute it with '_'; example: mirror/myarray -> mirror_myarray Install it as any other munin plugin (if you want to monitor device foo, symlink the plugin in your plugins directory as gstat_foo.py). The plugin need to be run as root. Add these 2 lines to your plugins.conf: [gstat_*] user root You need to restart munin_node for the changes to take effect. Written by ghirai-at-ghirai-d0t-com ''' import sys from subprocess import Popen,PIPE from string import split device = sys.argv[0][(sys.argv[0].find('_')+1):] if device == None: sys.exit(1) device = device.replace('_','/') if len(sys.argv) == 2 and sys.argv[1] == "autoconf": print "yes" elif len(sys.argv) == 2 and sys.argv[1] == "config": print 'graph_title I/O transactions for %s' % device print 'graph_vlabel Transfers in kBps' print 'graph_category Disk' print 'r.label read' print 'w.label write' print 'graph_args --base 1000 -l 0' else: r = 0 w = 0 res = Popen(['gstat','-b'],stdout=PIPE).stdout.read() res = res.split('\n') for ln in res: lns = split(ln) lns.reverse() try: if lns[0] == device: r = lns[6] w = lns[3] break except IndexError: break print 'r.value %s' % r print 'w.value %s' % w