Révision 0a13d5c2
murmur-stats: Enhancements
- python3 compatibility
- multigraph
- added muted/registered/unregistered users
| plugins/mumble/murmur-stats | ||
|---|---|---|
| 1 |
#!/usr/bin/env python |
|
| 1 |
#!/usr/bin/env python3
|
|
| 2 | 2 |
# -*- coding: utf-8 |
| 3 | 3 |
# Python Plugin for Munin |
| 4 | 4 |
# Copyright (C) 2010 Natenom (Natenom@googlemail.com) |
| ... | ... | |
| 14 | 14 |
#Murmur-Port (not needed to work, only for display purposes) |
| 15 | 15 |
serverport=64738 |
| 16 | 16 |
|
| 17 |
#Port where ice listen |
|
| 17 |
#Server and Port where ice listens |
|
| 18 |
icehost="127.0.0.1" |
|
| 18 | 19 |
iceport=6502 |
| 19 | 20 |
|
| 20 |
|
|
| 21 | 21 |
import Ice, sys |
| 22 | 22 |
Ice.loadSlice('', ['-I' + Ice.getSliceDir(), iceslice])
|
| 23 |
ice = Ice.initialize() |
|
| 24 | 23 |
import Murmur |
| 25 | 24 |
|
| 26 | 25 |
if (sys.argv[1:]): |
| 27 | 26 |
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')
|
|
| 35 | 48 |
sys.exit(0) |
| 36 | 49 |
|
| 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))
|
|
| 43 | 82 |
|
| 44 |
ice.shutdown() |
|
| 83 |
ice.destroy() |
|
Formats disponibles : Unified diff