From 13e5226dd46f6caebc8a3c187c3ac270168b9404 Mon Sep 17 00:00:00 2001 From: Thomas Leveil Date: Mon, 4 May 2009 04:29:41 +0200 Subject: [PATCH] Initial version --- plugins/other/murmur_ice_users | 132 +++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100755 plugins/other/murmur_ice_users diff --git a/plugins/other/murmur_ice_users b/plugins/other/murmur_ice_users new file mode 100755 index 00000000..f4841e9c --- /dev/null +++ b/plugins/other/murmur_ice_users @@ -0,0 +1,132 @@ +#!/usr/bin/php +stringToProxy("Meta:tcp -h $host -p $port"); + $metaServer = $iceproxy->ice_checkedCast("::Murmur::Meta"); + fwrite(STDOUT, "yes\n"); + exit(0); + } + catch (Exception $e) + { + fwrite(STDOUT, "no\n"); + exit(1); + } +} + +function do_config() +{ + fwrite(STDOUT, "graph_title Mumble Users\n"); + fwrite(STDOUT, "graph_vlabel Connected Users\n"); + fwrite(STDOUT, "graph_category VoIP\n"); + fwrite(STDOUT, "graph_info This graph shows the number of connected users on a murmur server\n"); + fwrite(STDOUT, "maxusers.label Maximum number of users allowed\n"); + fwrite(STDOUT, "maxusers.type GAUGE\n"); + fwrite(STDOUT, "online.label connected users\n"); + fwrite(STDOUT, "online.type GAUGE\n"); + exit(0); +} + +function do_count() +{ + global $ICE, $host, $port; + + $totalMaxUsers="U"; + $totalConnectedUsers="U"; + + try + { + Ice_loadProfile(); + $iceproxy = $ICE->stringToProxy("Meta:tcp -h $host -p $port"); + $metaServer = $iceproxy->ice_checkedCast("::Murmur::Meta"); + $AdefaultConf = $metaServer->getDefaultConf(); + + $AvirtualServer = $metaServer->getBootedServers(); + + $totalMaxUsers = 0; + foreach ($AvirtualServer as $numserver=>$s) + { + $maxusers = $s->getConf('users'); + if (!$maxusers) $maxusers = $AdefaultConf['users']; + $totalMaxUsers += intval($maxusers); + + $connectedUsers = countConnectedUsers($s->getTree()); + $totalConnectedUsers += $connectedUsers; + } + + + fwrite(STDOUT, "maxusers.value ".$totalMaxUsers."\n"); + fwrite(STDOUT, "online.value ".$totalConnectedUsers."\n"); + exit(0); + } + catch (Exception $e) + { + fwrite(STDERR, $e."\n"); + exit(1); + } +} + +function countConnectedUsers($channelTree) +{ + $count = intval($channelTree->players); + + if (isset($channelTree->children)) + { + foreach ($channelTree->children as $c) + { + $count += countConnectedUsers($c); + } + } + + return $count; +} + +?> \ No newline at end of file