2009-05-04 04:29:41 +02:00
|
|
|
|
#!/usr/bin/php
|
|
|
|
|
<?php
|
|
|
|
|
/*
|
2011-01-13 20:08:31 +01:00
|
|
|
|
: << =cut
|
|
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
|
|
murmur_ice_users
|
|
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
|
|
This plugin monitors users on a Mumble server (a.k.a. murmur).
|
|
|
|
|
It uses PHP and ICE to to query murmur. On debian, you can install mumble-server-web
|
|
|
|
|
to get the dependencies installed and set up.
|
|
|
|
|
|
2009-05-04 04:29:41 +02:00
|
|
|
|
|
2011-01-13 20:08:31 +01:00
|
|
|
|
=head1 CONFIGURATION
|
2009-05-04 04:29:41 +02:00
|
|
|
|
|
|
|
|
|
You can specify a different ip:port in the munin-node config file as follow:
|
|
|
|
|
|
2011-01-13 20:08:31 +01:00
|
|
|
|
[murmur_ice_users]
|
|
|
|
|
env.host 127.0.0.1
|
|
|
|
|
env.port 6502
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
|
|
Thomas L<>veil
|
|
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
|
|
Permission to use, copy, and modify this software with or without fee
|
|
|
|
|
is hereby granted, provided that this entire notice is included in
|
|
|
|
|
all source code copies of any software which is or includes a copy or
|
|
|
|
|
modification of this software.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
|
|
|
|
|
IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
|
|
|
|
|
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
|
|
|
|
|
MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
|
|
|
|
|
PURPOSE.
|
2009-05-04 04:29:41 +02:00
|
|
|
|
|
2011-01-13 20:08:31 +01:00
|
|
|
|
=head1 CONTRIBUTE
|
2009-05-04 04:29:41 +02:00
|
|
|
|
|
2011-01-13 20:08:31 +01:00
|
|
|
|
find this plugin on github at http://github.com/VolatileMesh/munin-plugins
|
|
|
|
|
|
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
|
|
|
|
|
|
#%# family=contrib
|
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
|
|
=head1 VERSION
|
|
|
|
|
|
|
|
|
|
1.1
|
|
|
|
|
|
|
|
|
|
=head1 CHANGELOG
|
|
|
|
|
|
|
|
|
|
=head2 1.0 - 2009/05/04
|
|
|
|
|
|
|
|
|
|
initial release
|
|
|
|
|
|
|
|
|
|
=head2 1.1 - 2011/01/13
|
|
|
|
|
|
|
|
|
|
fix to make it work with murmur v1.2.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=cut
|
2009-05-04 04:29:41 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2011-01-13 20:08:31 +01:00
|
|
|
|
|
2009-05-04 04:29:41 +02:00
|
|
|
|
$host = "127.0.0.1";
|
|
|
|
|
$port = "6502";
|
|
|
|
|
|
|
|
|
|
if (isset($_ENV['host'])) $host = $_ENV['host'];
|
|
|
|
|
if (isset($_ENV['port'])) $port = $_ENV['port'];
|
|
|
|
|
|
2011-01-13 20:08:31 +01:00
|
|
|
|
if (count($argv)==1) {
|
|
|
|
|
do_count();
|
|
|
|
|
}
|
2009-05-04 04:29:41 +02:00
|
|
|
|
|
|
|
|
|
switch ($argv[1])
|
|
|
|
|
{
|
|
|
|
|
case 'autoconf':
|
|
|
|
|
do_autoconf();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'config':
|
|
|
|
|
do_config();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
do_count();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function do_autoconf()
|
|
|
|
|
{
|
|
|
|
|
global $ICE, $host, $port;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Ice_loadProfile();
|
|
|
|
|
$iceproxy = $ICE->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);
|
2011-01-13 20:08:31 +01:00
|
|
|
|
|
|
|
|
|
$tree = $s->getTree();
|
|
|
|
|
//print_r($tree);
|
2009-05-04 04:29:41 +02:00
|
|
|
|
$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)
|
|
|
|
|
{
|
2011-01-13 20:08:31 +01:00
|
|
|
|
$count = intval(count($channelTree->users));
|
2009-05-04 04:29:41 +02:00
|
|
|
|
|
|
|
|
|
if (isset($channelTree->children))
|
|
|
|
|
{
|
|
|
|
|
foreach ($channelTree->children as $c)
|
|
|
|
|
{
|
|
|
|
|
$count += countConnectedUsers($c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|