mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Initial version
This commit is contained in:
parent
d37f5311bd
commit
b58e31e879
225
plugins/other/murmurice_host_port_id_description
Executable file
225
plugins/other/murmurice_host_port_id_description
Executable file
@ -0,0 +1,225 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
error_reporting( E_ALL & ~E_NOTICE ); //to avoid of the crap generation
|
||||
|
||||
/* // do not remove this line
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Murmur users online grapher PHP using ICE
|
||||
ver 0.4 2011.06.10, 15:44
|
||||
author _KaszpiR_ kaszpir at gmail dot com
|
||||
code is under GPL
|
||||
|
||||
Requirements:
|
||||
- PHP installed in CLI (so you can run it in command line)
|
||||
Make sure the first line of this file points to the pworking php cli inrepreter
|
||||
- ICE framework on server
|
||||
- Murmur server with ICE enabled
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Configuration:
|
||||
1. link creation
|
||||
create a symlink to thie file in the following format:
|
||||
murmurice_ip_port_sid_description
|
||||
where ip/port correspond to the ip and port on which the mumble ice interface listens to
|
||||
sid is the server id we want to query (mumble can run multiple servers )
|
||||
description - any kind of short text where _ will be replaced with spaces
|
||||
|
||||
By default script tries to connect 127.0.0.1:6502 and query server id 1
|
||||
|
||||
2. ice profile configuration
|
||||
This is not needed with ice 3.4.1
|
||||
Scroll down in this file and change
|
||||
$ice_profile = 'Murmur';
|
||||
to the profile that is installed on the server, this is required if you have multiple Ice profiles for various applicaitions.
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Script returns:
|
||||
channels number = number of existing channels on server (with temoprary ones)
|
||||
players number = number of all connected users on server
|
||||
registered number = number of connected and registered users on server
|
||||
unregistered number = number of connected and not registered users on server
|
||||
chanlinks number = linked chanels
|
||||
error number = this is set to 1 when there is error with communicatind with server via ice
|
||||
|
||||
On any error script exits with status 1, otherwise it is 0.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Changelog:
|
||||
|
||||
- ver 0.4 2011.06.10, 15:44 stable
|
||||
fix for ICE 3.4.1 that does not use Ice_loadprofile() function
|
||||
extended description
|
||||
fixed typos
|
||||
fixed warning messages in logs
|
||||
release
|
||||
|
||||
- ver 0.3 2011.04.2, 12:32 stable
|
||||
fi
|
||||
|
||||
- ver 0.2 2010.02.16 beta
|
||||
some minor fixes
|
||||
|
||||
- ver 0.1 2009.03.13 alpha
|
||||
first private release
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Todo:
|
||||
- load iceprofile from env var
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
*/ //do not remove this line
|
||||
|
||||
$ice_profile = 'Murmur';
|
||||
|
||||
|
||||
|
||||
// Define STDIN in case if it is not already defined by PHP for some reason
|
||||
if(!defined("STDIN"))
|
||||
{
|
||||
define("STDIN", fopen('php://stdin','r'));
|
||||
}
|
||||
|
||||
if(!defined("STDERR"))
|
||||
{
|
||||
define("STDERR", fopen('php://stderr','w'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
list($dummy,$ip,$port,$serverid,$desc) = explode("_",$argv[0],5);
|
||||
|
||||
if(!$ip) $ip="127.0.0.1";
|
||||
if(!$port) $port=6502;
|
||||
if(!$serverid) $serverid=1;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//autoconf test
|
||||
if(isset($argv[1]) && $argv[1] == "autoconf")
|
||||
{
|
||||
if(FALSE)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
fwrite(STDOUT, "No\n");
|
||||
fwrite(STDERR, "symlink ".$argv[0]." to somethilg like ".$argv[0]."_127.0.0.1_6502_1_description_here \n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//config, set rrd files
|
||||
if(isset($argv[1]) && $argv[1] == "config")
|
||||
{
|
||||
if(TRUE)
|
||||
{
|
||||
// yea dirty hack
|
||||
echo "graph_title Mumble Users".($desc?" on ".str_replace("_"," ",$desc):"")."\n";
|
||||
echo "graph_vlabel Connected Users\n";
|
||||
echo "graph_category VoIP\n";
|
||||
echo "graph_info This graph shows the number of connected users on a murmur server\n";
|
||||
echo "channels.label Chans\n";
|
||||
echo "players.label Total Users\n";
|
||||
echo "registered.label Registerd\n";
|
||||
echo "unregistered.label Unregistered\n";
|
||||
echo "chanlinks.label Linked chans\n";
|
||||
echo "error.label Server status error\n";
|
||||
|
||||
$arr=array("channels","players","registered","unregistered","chanlinks","error");
|
||||
foreach($arr as $field){
|
||||
echo "".$field.".draw LINE1\n";
|
||||
echo "".$field.".type GAUGE\n";
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}else {
|
||||
echo "RTFM\n";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$online_noreg=0;
|
||||
$online_reg=0;
|
||||
$channels=0;
|
||||
$links=0;
|
||||
//echo "Serverid:".$serverid."\n";
|
||||
|
||||
|
||||
if (Ice_intversion() >= 30400) {
|
||||
require 'Ice.php';
|
||||
require 'Murmur.php';
|
||||
} else {
|
||||
Ice_loadProfile($ice_profile);
|
||||
}
|
||||
|
||||
try {
|
||||
if (Ice_intversion() >= 30400) {
|
||||
$initData = new Ice_InitializationData;
|
||||
$initData->properties = Ice_createProperties();
|
||||
$initData->properties->setProperty("Ice.MessageSizeMax", "65536");
|
||||
$ICE = Ice_initialize($initData);
|
||||
}
|
||||
|
||||
|
||||
$base = $ICE->stringToProxy("Meta:tcp -h ".$ip." -p ".$port);
|
||||
$meta = $base->ice_checkedCast("::Murmur::Meta");
|
||||
|
||||
$servers = $meta->getBootedServers();
|
||||
$default = $meta->getDefaultConf();
|
||||
foreach($servers as $s) {
|
||||
$name = $s->getConf("registername");
|
||||
if (! $name) {
|
||||
$name = $default["registername"];
|
||||
}
|
||||
|
||||
if($s->id() !=$serverid) continue;
|
||||
|
||||
$chanlist = $s->getChannels();
|
||||
$channels = count($chanlist);
|
||||
foreach($chanlist as $chan=>$c){
|
||||
$links+=count($c->links);
|
||||
}
|
||||
$players = $s->getUsers();
|
||||
foreach($players as $id => $p) {
|
||||
if($p->userid ==-1)
|
||||
$online_noreg++;
|
||||
else
|
||||
$online_reg++;
|
||||
}
|
||||
}
|
||||
} catch (Ice_LocalException $ex) {
|
||||
fwrite(STDERR,"ERROR: IP=".$ip.", Port=".$port.", Id=".$serverid."\n");
|
||||
fwrite(STDERR,$ex);
|
||||
echo "channels.value 0\n";
|
||||
echo "players.value 0\n";
|
||||
echo "registered.value 0\n";
|
||||
echo "unregistered.value 0\n";
|
||||
echo "chanlinks.value ".$links."\n";
|
||||
echo "error.value 1\n";
|
||||
|
||||
return 1;
|
||||
}
|
||||
echo "channels.value ".$channels."\n";
|
||||
echo "players.value ".($online_noreg+$online_reg)."\n";
|
||||
echo "registered.value ".$online_reg."\n";
|
||||
echo "unregistered.value ".$online_noreg."\n";
|
||||
echo "chanlinks.value ".$links."\n";
|
||||
echo "error.value 0\n";
|
||||
return 0;
|
||||
?>
|
Loading…
Reference in New Issue
Block a user