From fad01c8b91f3c5070486a675250f4d9272f00acf Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 7 Oct 2010 16:19:21 +0200 Subject: [PATCH] Checks if the virtual server is booted before attempting to read the userlist. Stops weird and wonderful crashes in a non-static setup. --- plugins/other/mumble_users | 80 ++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/plugins/other/mumble_users b/plugins/other/mumble_users index 6087d157..ba85177e 100755 --- a/plugins/other/mumble_users +++ b/plugins/other/mumble_users @@ -1,38 +1,42 @@ -#!/usr/bin/python -# -# Munin Plugin for Murmur/ICE -# written by T. Fernandez -# 02/03/2010 -# -########################################################## - -slicefile = "./Murmur.ice" -prxstr = "Meta:tcp -h 127.0.0.1 -p 6502" - -import os -import sys - -import Ice -if not os.path.exists(slicefile): - print slicefile+" not found!" - quit(1) -Ice.loadSlice(slicefile) - -import Murmur -ice = Ice.initialize() -prx = ice.stringToProxy(prxstr) -murmur = Murmur.MetaPrx.checkedCast(prx) - -if (sys.argv.__len__() == 2) and (sys.argv[1] == "config"): - print "graph_title Mumble users" - print "graph_vlabel users" - print "graph_args --lower-limit 0" - for server in murmur.getAllServers(): - id = str(server.id()) - print "murmur"+id+".label Server "+id -else: - for server in murmur.getAllServers(): - id = str(server.id()) - users = server.getUsers() - print "murmur"+id+".value "+str(users.__len__()) -quit(0) +#!/usr/bin/python +# +# Munin Plugin for Murmur/ICE +# written by T. Fernandez +# fixes by Andrew Williams +# 07/10/2010 +# +########################################################## + +slicefile = "/usr/share/slice/Murmur.ice" +prxstr = "Meta:tcp -h 127.0.0.1 -p 6502" + +import os +import sys + +import Ice +if not os.path.exists(slicefile): + print slicefile+" not found!" + quit(1) +Ice.loadSlice(slicefile) + +import Murmur +ice = Ice.initialize() +prx = ice.stringToProxy(prxstr) +murmur = Murmur.MetaPrx.checkedCast(prx) + +if (sys.argv.__len__() == 2) and (sys.argv[1] == "config"): + print "graph_title Mumble users" + print "graph_vlabel users" + print "graph_args --lower-limit 0" + for server in murmur.getAllServers(): + id = str(server.id()) + print "murmur"+id+".label Server "+id +else: + for server in murmur.getAllServers(): + id = str(server.id()) + if server.isRunning(): + users = server.getUsers() + else: + users = [] + print "murmur"+id+".value "+str(users.__len__()) +quit(0)