Browse Source

various fixes to adapt the new model layout

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
ee406af055
  1. 19
      munin.py
  2. 4
      pyweb/mumble/management/commands/checkenv.py
  3. 2
      pyweb/mumble/management/server_detect.py

19
munin.py

@ -40,7 +40,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'pyweb.settings'
#os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs' #os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs'
from django.conf import settings from django.conf import settings
from mumble.models import *
from mumble.models import MumbleServer, Mumble
warn = getattr( settings, "MUNIN_WARNING", 0.80 ) warn = getattr( settings, "MUNIN_WARNING", 0.80 )
crit = getattr( settings, "MUNIN_CRITICAL", 0.95 ) crit = getattr( settings, "MUNIN_CRITICAL", 0.95 )
@ -48,7 +48,12 @@ title = getattr( settings, "MUNIN_TITLE", "Mumble Users" )
categ = getattr( settings, "MUNIN_CATEGORY", "network" ) categ = getattr( settings, "MUNIN_CATEGORY", "network" )
mm = Mumble.objects.filter( booted = True ).order_by( "id" );
def get_running_instances():
for server in MumbleServer.objects.all():
runinst = server.ctl.getBootedServers()
for inst in server.mumble_set.filter( srvid__in=runinst ):
yield inst
if sys.argv[-1] == 'config': if sys.argv[-1] == 'config':
print "graph_vlabel Users" print "graph_vlabel Users"
@ -56,7 +61,7 @@ if sys.argv[-1] == 'config':
print "graph_title", title print "graph_title", title
print "graph_category", categ print "graph_category", categ
for mumble in mm:
for mumble in get_running_instances():
print "srv%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 ); print "srv%d.info %s" % ( mumble.id, mumble.connecturl );
if mumble.users: if mumble.users:
@ -65,13 +70,13 @@ if sys.argv[-1] == 'config':
elif sys.argv[-1] == 'autoconf': elif sys.argv[-1] == 'autoconf':
if mm.count() == 0:
if Mumble.objects.count() == 0:
print "no (no servers configured)"; print "no (no servers configured)";
else: else:
# check if connecting works # check if connecting works
try: try:
for mumble in mm:
mumble.getCtl();
for mumble in get_running_instances():
mumble.ctl
except Exception, instance: except Exception, instance:
print "no (can't connect to server %s: %s)" % ( mumble.name, instance ); print "no (can't connect to server %s: %s)" % ( mumble.name, instance );
else: else:
@ -79,6 +84,6 @@ elif sys.argv[-1] == 'autoconf':
else: else:
for mumble in mm:
for mumble in get_running_instances():
print "srv%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) ); print "srv%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) );

4
pyweb/mumble/management/commands/checkenv.py

@ -166,10 +166,10 @@ class Command( BaseCommand ):
else: else:
for mumble in mm: for mumble in mm:
try: try:
mumble.getCtl();
mumble.ctl
except Ice.Exception, err: except Ice.Exception, err:
raise TestFailed( raise TestFailed(
"Connecting to Murmur `%s` (%s) failed: %s" % ( mumble.name, mumble.dbus, err )
"Connecting to Murmur `%s` (%s) failed: %s" % ( mumble.name, mumble.server, err )
); );
print "[ OK ]"; print "[ OK ]";

2
pyweb/mumble/management/server_detect.py

@ -97,7 +97,7 @@ def find_existing_instances( **kwargs ):
try: try:
meta = models.MumbleServer.objects.get( dbus=dbusName ); meta = models.MumbleServer.objects.get( dbus=dbusName );
except models.MumbleServer.DoesNotExist: except models.MumbleServer.DoesNotExist:
meta = models.MumbleServer( dbus=dbusName );
meta = models.MumbleServer( dbus=dbusName, secret=icesecret );
meta.save(); meta.save();
for id in servIDs: for id in servIDs:

Loading…
Cancel
Save