From e5cf652ef6a847570d8b2f4cc12bea91a39cdc37 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Mon, 29 Jun 2009 22:46:27 +0200 Subject: [PATCH] proudly presenting an overly hacky, but still working Munin plugin that graphs the user count for each server instance! --- munin.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 munin.py diff --git a/munin.py b/munin.py new file mode 100755 index 0000000..351080e --- /dev/null +++ b/munin.py @@ -0,0 +1,42 @@ +#!/usr/bin/python + +# Set this to the same path you used in settings.py, or None for auto-detection. +MUMBLE_DJANGO_ROOT = None; + +### DO NOT CHANGE ANYTHING BELOW THIS LINE ### + +import os, sys +from os.path import join, dirname, abspath, exists + +# Path auto-detection +if not MUMBLE_DJANGO_ROOT or not exists( MUMBLE_DJANGO_ROOT ): + MUMBLE_DJANGO_ROOT = dirname(abspath(__file__)); + +# environment variables +sys.path.append( MUMBLE_DJANGO_ROOT ) +sys.path.append( join( MUMBLE_DJANGO_ROOT, 'pyweb' ) ) +os.environ['DJANGO_SETTINGS_MODULE'] = 'pyweb.settings' + + +# If you get an error about Python not being able to write to the Python +# egg cache, the egg cache path might be set awkwardly. This should not +# happen under normal circumstances, but every now and then, it does. +# Uncomment this line to point the egg cache to /tmp. +#os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs' + +from mumble.models import * +mm = Mumble.objects.filter( booted = True ) + +if sys.argv[-1] == 'config': + print "graph_vlabel Users" + print "graph_args --base 1000" + print "graph_title Mumble Users" + print "graph_category network" + + for mumble in mm: + print "%d.label %s" % ( mumble.id, mumble.name ); + +else: + for mumble in mm: + print "%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) ); +