Browse Source

add check if connecting works to autoconf

Natenom/support-murmur-13-1446181288462
Michael Ziegler 16 years ago
parent
commit
a7784ca796
  1. 12
      munin.py

12
munin.py

@ -40,6 +40,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'pyweb.settings'
#os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs' #os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs'
from mumble.models import * from mumble.models import *
mm = Mumble.objects.filter( booted = True ).order_by( "id" ); mm = Mumble.objects.filter( booted = True ).order_by( "id" );
if sys.argv[-1] == 'config': if sys.argv[-1] == 'config':
@ -51,12 +52,21 @@ if sys.argv[-1] == 'config':
for mumble in mm: for mumble in mm:
print "%d.label %s" % ( mumble.id, mumble.name ); print "%d.label %s" % ( mumble.id, mumble.name );
elif sys.argv[-1] == 'autoconf': elif sys.argv[-1] == 'autoconf':
if len(mm) == 0:
if mm.count() == 0:
print "no (no servers configured)"; print "no (no servers configured)";
else:
# check if connecting works
try:
for mumble in mm:
mumble.getCtl();
except Exception, instance:
print "no (can't connect to server %s: %s)" % ( mumble.name, instance );
else: else:
print "yes"; print "yes";
else: else:
for mumble in mm: for mumble in mm:
print "%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) ); print "%d.value %d" % ( mumble.id, len( mumble.ctl.getPlayers( mumble.srvid ) ) );

Loading…
Cancel
Save