Skip to content

Commit 0a13d5c

Browse files
Sebastian Lsumpfralle
Sebastian L
authored andcommittedDec 28, 2021
murmur-stats: Enhancements
- python3 compatibility - multigraph - added muted/registered/unregistered users
1 parent 63f8552 commit 0a13d5c

File tree

1 file changed

+57
-18
lines changed

1 file changed

+57
-18
lines changed
 

‎plugins/mumble/murmur-stats

+57-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8
33
# Python Plugin for Munin
44
# Copyright (C) 2010 Natenom (Natenom@googlemail.com)
@@ -14,31 +14,70 @@ iceslice='/usr/share/slice/Murmur.ice'
1414
#Murmur-Port (not needed to work, only for display purposes)
1515
serverport=64738
1616

17-
#Port where ice listen
17+
#Server and Port where ice listens
18+
icehost="127.0.0.1"
1819
iceport=6502
1920

20-
2121
import Ice, sys
2222
Ice.loadSlice('', ['-I' + Ice.getSliceDir(), iceslice])
23-
ice = Ice.initialize()
2423
import Murmur
2524

2625
if (sys.argv[1:]):
2726
if (sys.argv[1] == "config"):
28-
print 'graph_title Murmur (Port %s)' % (serverport)
29-
print 'graph_category voip'
30-
print 'graph_vlabel Count'
31-
print 'users.label Users'
32-
print 'uptime.label Uptime in days'
33-
print 'chancount.label Channelcount/10'
34-
print 'bancount.label Bans on server'
27+
print('multigraph murmur_stats_users')
28+
print('graph_title Users on mumble server')
29+
print('graph_category voip')
30+
print('graph_vlabel Count')
31+
print('users_total.label Total users')
32+
print('users_muted.label Muted users')
33+
print('users_registered.label Registered users')
34+
print('users_unregistered.label Unregistered users')
35+
print('bancount.label Bans on server')
36+
print('multigraph murmur_stats_channels')
37+
print('graph_title Channels on mumble server')
38+
print('graph_category voip')
39+
print('graph_vlabel Channels')
40+
print('graph_args -l 0')
41+
print('chancount.draw AREA')
42+
print('chancount.label Channels')
43+
print('multigraph murmur_stats_uptime')
44+
print('graph_title Uptime of mumble server')
45+
print('graph_category voip')
46+
print('graph_vlabel Uptime')
47+
print('uptime.label Uptime in days')
3548
sys.exit(0)
3649

37-
meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy("Meta:tcp -h 127.0.0.1 -p %s" % (iceport)))
38-
server=meta.getServer(1)
39-
print "users.value %i" % (len(server.getUsers()))
40-
print "uptime.value %.2f" % (float(meta.getUptime())/60/60/24)
41-
print "chancount.value %.1f" % (len(server.getChannels())/10)
42-
print "bancount.value %i" % (len(server.getBans()))
50+
ice = Ice.initialize()
51+
52+
try:
53+
meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy("Meta:tcp -h %s -p %s" % (icehost, iceport)))
54+
except Ice.ConnectionRefusedException:
55+
print('Could not connect to mumble server via Ice.', file=sys.stderr)
56+
ice.destroy()
57+
sys.exit(1)
58+
59+
try:
60+
server=meta.getServer(1)
61+
except Murmur.InvalidSecretException:
62+
print('Given icesecretread password is wrong.', file=sys.stderr)
63+
ice.destroy()
64+
sys.exit(1)
65+
66+
users = server.getUsers()
67+
68+
users_unregistered = len(list(user for user in users.values() if user.userid == -1))
69+
users_registered = len(list(user for user in users.values() if user.userid >= 0))
70+
users_muted = len(list(user for user in users.values() if user.mute or user.selfMute or user.suppress))
71+
72+
print("multigraph murmur_stats_users")
73+
print("users_total.value %i" % (len(users)))
74+
print("users_muted.value %i" % users_muted)
75+
print("users_registered.value %i" % (users_registered))
76+
print("users_unregistered.value %i" % (users_unregistered))
77+
print("bancount.value %i" % (len(server.getBans())))
78+
print("multigraph murmur_stats_channels")
79+
print("chancount.value %i" % (len(server.getChannels())))
80+
print("multigraph murmur_stats_uptime")
81+
print("uptime.value %.2f" % (float(meta.getUptime())/60/60/24))
4382

44-
ice.shutdown()
83+
ice.destroy()

0 commit comments

Comments
 (0)
Please sign in to comment.