From a7784ca796cb4d5bb0db9a02117a2c8863bb792c Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Thu, 27 Aug 2009 23:28:23 +0200 Subject: [PATCH] add check if connecting works to autoconf --- munin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/munin.py b/munin.py index 716371f..73044a7 100755 --- a/munin.py +++ b/munin.py @@ -40,6 +40,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'pyweb.settings' #os.environ['PYTHON_EGG_CACHE'] = '/tmp/pyeggs' from mumble.models import * + mm = Mumble.objects.filter( booted = True ).order_by( "id" ); if sys.argv[-1] == 'config': @@ -51,11 +52,20 @@ if sys.argv[-1] == 'config': for mumble in mm: print "%d.label %s" % ( mumble.id, mumble.name ); + elif sys.argv[-1] == 'autoconf': - if len(mm) == 0: + if mm.count() == 0: print "no (no servers configured)"; else: - print "yes"; + # 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: + print "yes"; + else: for mumble in mm: