From 3d719ea1e67133cfced20ff79aca3cd51bca7ecf Mon Sep 17 00:00:00 2001 From: _KaszpiR_ Date: Fri, 10 Jun 2011 17:13:34 +0200 Subject: [PATCH] Initial version --- .../murmurice_host_port_id_description_avg | 241 ++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100755 plugins/other/murmurice_host_port_id_description_avg diff --git a/plugins/other/murmurice_host_port_id_description_avg b/plugins/other/murmurice_host_port_id_description_avg new file mode 100755 index 00000000..14025867 --- /dev/null +++ b/plugins/other/murmurice_host_port_id_description_avg @@ -0,0 +1,241 @@ +#!/usr/bin/php += 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++; + if($p->mute) $mute++; + if($p->deaf) $deaf++; + if($p->suppress) $suppress++; + if($p->selfMute) $selfmute++; + if($p->selfDeaf) $selfdeaf++; + $avg_perchan[$p->channel]++; + } + } + + $active_chans = count(array_keys($avg_perchan)); + if($active_chans == 0 ) $avg = 0; + else $avg = round( count($players) / $active_chans); + +} catch (Ice_LocalException $ex) { + fwrite(STDERR,"ERROR: IP=".$ip.", Port=".$port.", Id=".$serverid."\n"); + fwrite(STDERR,$ex); + echo "mute.value 0\n"; + echo "deaf.value 0\n"; + echo "suppress.value 0\n"; + echo "selfmute.value 0\n"; + echo "selfdeaf.value 0\n"; + echo "avgperchan.value 0\n"; + echo "error.value 1\n"; + +return 1; +} +echo "mute.value ".$mute."\n"; +echo "deaf.value ".$deaf."\n"; +echo "suppress.value ".$suppress."\n"; +echo "selfmute.value ".$selfmute."\n"; +echo "selfdeaf.value ".$selfdeaf."\n"; +echo "avgperchan.value ".$avg."\n"; +echo "error.value 0\n"; +return 0; +?> \ No newline at end of file