From 84730737c72d204c733c5afbaede0386fb1d16ef Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Thu, 11 Feb 2010 11:49:56 +0100 Subject: [PATCH] fix IDs to be compatible with Munin 1.4, display a bit more info in the graphs and allow stuff to be configured. fixes #77 --- munin.py | 19 +++++++++++++++---- pyweb/settings.py | 9 +++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/munin.py b/munin.py index b255465..c2e6f12 100755 --- a/munin.py +++ b/munin.py @@ -39,18 +39,29 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'pyweb.settings' # Uncomment this line to point the egg cache to /tmp. #os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs' +from django.conf import settings from mumble.models import * +warn = getattr( settings, "MUNIN_WARNING", 0.80 ) +crit = getattr( settings, "MUNIN_CRITICAL", 0.95 ) +title = getattr( settings, "MUNIN_TITLE", "Mumble Users" ) +categ = getattr( settings, "MUNIN_CATEGORY", "network" ) + + mm = Mumble.objects.filter( booted = True ).order_by( "id" ); if sys.argv[-1] == 'config': print "graph_vlabel Users" print "graph_args --base 1000" - print "graph_title Mumble Users" - print "graph_category network" + print "graph_title", title + print "graph_category", categ for mumble in mm: - print "%d.label %s" % ( mumble.id, mumble.name.replace( '#', '' ) ); + print "srv%d.label %s" % ( mumble.id, mumble.name.replace( '#', '' ) ); + print "srv%d.info %s" % ( mumble.id, mumble.connecturl ); + if mumble.users: + print "srv%d.warning %d" % ( mumble.id, int( mumble.users * warn ) ); + print "srv%d.critical %d" % ( mumble.id, int( mumble.users * crit ) ); elif sys.argv[-1] == 'autoconf': @@ -69,5 +80,5 @@ elif sys.argv[-1] == 'autoconf': else: for mumble in mm: - print "%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) ); + print "srv%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) ); diff --git a/pyweb/settings.py b/pyweb/settings.py index abb75be..b769d1f 100644 --- a/pyweb/settings.py +++ b/pyweb/settings.py @@ -94,6 +94,15 @@ PROTECTED_MODE = False ALLOW_ACCOUNT_LINKING = True # Allow linking in general? ALLOW_ACCOUNT_LINKING_ADMINS = False # Allow linking for Admin accounts? +# Warning and Critical levels for the Munin plugin. These will be multiplied with the +# server instance's slot count to calculate the real levels. +MUNIN_WARNING = 0.80 +MUNIN_CRITICAL = 0.95 +# The graph title. +MUNIN_TITLE = 'Mumble Users' +# see for a list of valid categories. +MUNIN_CATEGORY = 'network' + # Database settings for Mumble-Django's database. These do NOT need to point to Murmur's database, # Mumble-Django should use its own! DATABASE_ENGINE = 'sqlite3'