-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://withgod.googlecode.com/svn/trunk/mumble@24 345122f0-3075-11de-874f-bb9810f3bc79
- Loading branch information
0 parents
commit 2c122c0
Showing
3 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#! /usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
|
||
# If we're being run as a CGI in suexec, $HOME doesn't exist. Fake it. | ||
my $home = (getpwuid($<))[7]; | ||
|
||
# This needs to be done before "use Net::DBus" | ||
if (open(F, "$home/murmur/.dbus.sh")) { | ||
while(<F>) { | ||
chomp(); | ||
if ($_ =~ /^(.+?)\='(.+)';$/) { | ||
$ENV{$1}=$2; | ||
} | ||
} | ||
close(F); | ||
} | ||
|
||
use Net::DBus; | ||
use CGI::Carp qw(fatalsToBrowser); | ||
use HTML::Template; | ||
|
||
my $tmpl_fname = $1 if ($0 =~ /(.+)\.([a-z]+)$/); | ||
my $tmpl; | ||
if (-f "$tmpl_fname.tmpl") { | ||
$tmpl = HTML::Template->new(filename => "$tmpl_fname.tmpl"); | ||
} else { | ||
$tmpl = HTML::Template->new(filehandle => *DATA); | ||
} | ||
my $bus; | ||
my $service; | ||
|
||
# First try the system bus | ||
eval { | ||
$bus=Net::DBus->system(); | ||
$service = $bus->get_service("net.sourceforge.mumble.murmur"); | ||
}; | ||
|
||
# If that failed, the session bus | ||
if (! $service) { | ||
eval { | ||
$bus = Net::DBus->session(); | ||
$service = $bus->get_service("net.sourceforge.mumble.murmur"); | ||
} | ||
} | ||
|
||
die "Murmur service not found" if (! $service); | ||
|
||
# Fetch handle to remote object | ||
my $object = $service->get_object("/"); | ||
# Call a function on the murmur object | ||
my $servers = $object->getBootedServers(); | ||
|
||
my $params = []; | ||
foreach my $server (@{$servers}) { | ||
my $name = $object->getConf($server, "registername"); | ||
my $servobj = $service->get_object("/$server"); | ||
|
||
my %users; | ||
# First, get channel names | ||
my $channels = $servobj->getChannels(); | ||
my %channels; | ||
foreach my $c (@{$channels}) { | ||
my @c = @{$c}; | ||
my $id = $c[0]; | ||
my $name = $c[1]; | ||
$channels{$id}=$name; | ||
} | ||
# Then, get and print the players | ||
my $players = $servobj->getPlayers(); | ||
my $_total = 0; | ||
foreach my $p (@{$players}) { | ||
my @p = @{$p}; | ||
my $chanid = $p[6]; | ||
my $name = $p[8]; | ||
my $chan = $channels{$chanid}; | ||
$users{$chan} = [] unless $users{$chan}; | ||
push @{$users{$chan}}, $name; | ||
$_total++; | ||
} | ||
my $_channels = []; | ||
for my $c (sort keys %users) { | ||
my $_users = []; | ||
for my $u (sort @{$users{$c}}) { | ||
push @{$_users}, {'user' => $u}; | ||
} | ||
push @{$_channels}, { | ||
'channel' => $c, | ||
'users' => $_users | ||
}; | ||
} | ||
push @{$params}, {'server' => $server, 'name' => $name, 'total' => $_total, 'channels' => $_channels}; | ||
} | ||
|
||
$tmpl->param("servers", $params); | ||
print "Content-type: text/html;charset=utf8\r\n\r\n", | ||
$tmpl->output; | ||
|
||
__END__ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<HTML lang="ja"> | ||
<HEAD> | ||
<Title>mumble server user list</title> | ||
<STYLE TYPE="text/css"> | ||
<!-- | ||
body { | ||
background-color: #ffffff; | ||
color: #4b4b4b; | ||
font-family: verdana, arial, sans-serif; | ||
font-size: 13px; | ||
margin: 10px 20px; | ||
} | ||
dl { | ||
margin-left: 5px; | ||
} | ||
dt { | ||
clear: both; | ||
font-weight: bold; | ||
padding-left: 5px; | ||
border-left: #4b4b4b 5px solid | ||
} | ||
dd { | ||
float: left; | ||
margin-left: 5px; | ||
margin-bottom: 5px; | ||
margin-top: 2px; | ||
} | ||
--> | ||
</STYLE> | ||
</HEAD> | ||
<BODY bgcolor="#ffffff" text="#4b4b4b" link="#3399ff" alink="#0099cc" vlink="#006666"> | ||
<TMPL_LOOP NAME="servers"> | ||
<H1>Server #<TMPL_VAR NAME="server"> <TMPL_VAR NAME="name"></H1> | ||
total: <TMPL_VAR NAME="total"> | ||
<dl> | ||
<TMPL_LOOP NAME="channels"> | ||
<dt><TMPL_VAR NAME="channel"> | ||
<dd> | ||
<TMPL_LOOP NAME="users"> | ||
<TMPL_VAR NAME="user">, | ||
</TMPL_LOOP> | ||
</TMPL_LOOP> | ||
</dl> | ||
</TMPL_LOOP> | ||
</BODY> | ||
</HTML> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<HTML lang="ja"> | ||
<HEAD> | ||
<Title>mumble server user list</title> | ||
<STYLE TYPE="text/css"> | ||
<!-- | ||
body { | ||
background-color: #ffffff; | ||
color: #4b4b4b; | ||
font-family: verdana, arial, sans-serif; | ||
font-size: 13px; | ||
margin: 10px 20px; | ||
} | ||
dl { | ||
margin-left: 5px; | ||
} | ||
dt { | ||
clear: both; | ||
font-weight: bold; | ||
padding-left: 5px; | ||
border-left: #4b4b4b 5px solid | ||
} | ||
dd { | ||
float: left; | ||
margin-left: 5px; | ||
margin-bottom: 5px; | ||
margin-top: 2px; | ||
} | ||
--> | ||
</STYLE> | ||
</HEAD> | ||
<BODY bgcolor="#ffffff" text="#4b4b4b" link="#3399ff" alink="#0099cc" vlink="#006666"> | ||
<TMPL_LOOP NAME="servers"> | ||
<H1>Server #<TMPL_VAR NAME="server"> <TMPL_VAR NAME="name"></H1> | ||
total: <TMPL_VAR NAME="total"> | ||
<dl> | ||
<TMPL_LOOP NAME="channels"> | ||
<dt><TMPL_VAR NAME="channel"> | ||
<dd> | ||
<TMPL_LOOP NAME="users"> | ||
<TMPL_VAR NAME="user">, | ||
</TMPL_LOOP> | ||
</TMPL_LOOP> | ||
</dl> | ||
</TMPL_LOOP> | ||
</BODY> | ||
</HTML> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 | ||
# | ||
# murmur_ a simple munin plugin | ||
# written by withgod | ||
# | ||
# GPLv2 http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
# | ||
|
||
import sys,os,string,Ice | ||
|
||
proxy = 'Meta:tcp -h 127.0.0.1 -p 6502' | ||
slice = '/usr/share/slice/Murmur.ice' | ||
server = string.replace(os.path.basename(sys.argv[0]), 'murmur_', '') | ||
|
||
|
||
if server == '': | ||
server = 1 | ||
else: | ||
server = int(server) | ||
|
||
if len(sys.argv) > 1 and sys.argv[1] == 'autoconf': | ||
if os.path.exists(slice): | ||
print 'yes' | ||
sys.exit() | ||
else: | ||
print 'no' | ||
sys.exit(2) | ||
|
||
Ice.loadSlice(slice) | ||
import Murmur | ||
ice = Ice.initialize() | ||
prx = ice.stringToProxy(proxy) | ||
murmur = Murmur.MetaPrx.checkedCast(prx) | ||
|
||
_server = murmur.getServer(server) | ||
server_name = _server.getConf("registerName") | ||
user_count = 0 | ||
|
||
if _server.isRunning: | ||
server_version = murmur.getVersion() | ||
# release 1.1.8 or under getPlayers but now trunk is getUsers | ||
if server_version[0] <= 1 and server_version[1] <= 1 and server_version[2] <= 8: | ||
user_count = len(_server.getPlayers()) | ||
else: | ||
user_count = len(_server.getUsers()) | ||
|
||
if len(sys.argv) > 1 and sys.argv[1] == 'config': | ||
print "graph_title Number of Mumble User [" + server_name + "]" | ||
print "graph_args --base 1000 -l 0" | ||
print "graph_category mumble" | ||
print "graph_vlabel number of User" | ||
print "graph_info This graph shows the number of user in mumble [" + server_name+ "]." | ||
print "mumble.label users" | ||
print "mumble.draw LINE2" | ||
else: | ||
print "mumble.value %d" % (user_count) | ||
|