1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

- have some dirs

This commit is contained in:
Steve Schnepp 2012-02-13 18:24:46 +01:00
parent 0b089ea777
commit 08346aac58
687 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,80 @@
#!/usr/bin/perl -w
# teamspeak_user.pl
# Munin Plugin for Teamspeak3 Servers
# displays the number of connected users on TS3 servers
#######################################################
#
# by Tim Wulkau - www.wulkau.de
#
# 18.11.10 - v0.4
# -added queryuser login
# -subtract queryclients from usercount (tanks to Jakob Lenfers for the idea)
# 02.10.10 - v0.3
# -fixed welcomemessage error
# 31.01.10 - v0.2
# -fixed multiserver support
# -corrected usercount
# 17.01.10 - v0.1
# -initial release
#
######################################################
use strict;
use Net::Telnet;
# CONFIG HERE!
my $hostname = "localhost"; # serveraddress
my $port = 10011; # querryport (default: 10011)
my @serverids = (1); # array of virtualserverids (1,2,3,4,...)
my $username = ""; # only set if the default queryuser hasn´t enough rights (should work without this)
my $password = "";
# SCRIPT START!
if(exists $ARGV[0] and $ARGV[0] eq "config")
{
print "graph_title Teamspeak User\n";
print "graph_vlabel Connected Teamspeak Users\n";
print "graph_category Teamspeak\n";
print "graph_info This graph shows the number of connected users on a Teamspeak3 server\n";
foreach my $server (@serverids)
{
print "$server.label Users on Serverid $server\n";
print "$server.type GAUGE\n";
#print "$server.draw AREA\n";
}
exit 0;
}
else
{
my $telnet = new Net::Telnet(Timeout=>5, Errmode=>"return", Prompt=>"/\r/");
if (!$telnet->open(Host=>$hostname, Port=>$port)) {
die exit;
}
$telnet->waitfor("/Welcome to the TeamSpeak 3 ServerQuery interface/");
foreach my $server (@serverids)
{
$telnet->cmd("use sid=$server");
$telnet->waitfor("/error id=0 msg=ok/");
if($username && $password) {
$telnet->cmd("login $username $password");
$telnet->waitfor("/error id=0 msg=ok/");
}
$telnet->cmd("serverinfo");
my $clients = 0;
my $queryclients = 0;
my $line = $telnet->getline(Timeout=>5);
if ($line =~ m/virtualserver_clientsonline=(\d+) /) {
$clients = $1;
}
if ($line =~ m/virtualserver_queryclientsonline=(\d+) /) {
$queryclients = $1;
}
$telnet->waitfor("/error id=0 msg=ok/");
print "$server.value ".($clients - $queryclients)."\n";
}
$telnet->close;
}
exit;

212
plugins/teamspeak/ts3v2_ Executable file
View file

@ -0,0 +1,212 @@
#!/usr/bin/perl -w
# ts3v2_ (perl)
# Munin Plugin for Teamspeak3 Servers
# displays the number of connected users on TS3 servers
# and average transferrate per second over 5 min.
#
# You can use it with symlinks for overview and explicit ids.
# Also you can configure the following variables:
# host
# port
#
# by Marc Urben, www.oxi.ch or www.oom.ch
#
# Based on Tim Wulkau's script. Thank you!
# www.wulkau.de
#
#######################################################
# 02.10.10 - v0.3
# -now works again with 3.0.0-beta29
#
# 18.04.10 - v0.2
# -transfer mode added
#
# 13.04.10 - v0.1
# -initial release
#
######################################################
#%# family=auto
#%# capabilities=autoconf suggest
use strict;
use Net::Telnet;
# CONFIG HERE!
my $hostname = $ENV{host} || "188.40.110.119"; # serveraddress
my $port = $ENV{port} || 10011; # querryport
my $filename = "ts3v2_";
# SCRIPT START!
#init telnet connection
my $name = ""; my $server = ""; my @num; my $id = 0; my $i = 0; my $myserver; my $transfer;
my $telnet = new Net::Telnet(Timeout=>1, Errmode=>"return", Prompt=>"/\r/");
if (!$telnet->open(Host=>$hostname, Port=>$port)) {
die "Server could not be reached, please check your config!";
}
#get argument
my $argument = "";
if ($0 =~ /$filename(\w+)$/i) {
$argument = $1;
} elsif ($ARGV[0] ne "suggest" and $ARGV[0] ne "autoconf") {
die "Error: We need to know what serverid you want, so link this plugin as "
.$filename."1, ".$filename."2 or ".$filename."overview.\n";
}
#check for overview, transfer or single server mode
my $mode = "";
if ($argument eq "overview" or $argument eq "transfer" or $ARGV[0] eq "suggest" or $ARGV[0] eq "autoconf") {
if ($argument eq "overview") {
$mode = "o";
} elsif($argument eq "transfer") {
$mode = "t";
}
$telnet->waitfor("/Welcome/");
$telnet->cmd("serverlist");
my $line = $telnet->getline(Timeout=>1);
my @servers = split(/\|/, $line);
foreach (@servers) {
if ($_ =~ m/virtualserver_id=(\d+) virtual/) {
push(@num, $1);
} else {
die "ERROR: server string not recognized!\n";
}
}
$telnet->waitfor("/error id=0 msg=ok/");
} elsif ($argument =~ /^[+-]?\d+$/ ) {
$mode = "s";
$server = $argument;
} else {
die "ERROR: unknown plugin mode: $argument\n";
}
#check for config mode
if (exists $ARGV[0] and $ARGV[0] eq "autoconf") {
print "yes";
exit 0;
} elsif (exists $ARGV[0] and $ARGV[0] eq "suggest") {
print "overview\n";
print "transfer\n";
foreach (@num) {
print $_."\n";
}
exit 0;
} elsif (exists $ARGV[0] and $ARGV[0] eq "config") {
if ($mode eq "s") {
#single server mode
$telnet->waitfor("/Welcome/");
$telnet->cmd("use sid=".$server);
$telnet->waitfor("/error id=0 msg=ok/");
$telnet->cmd("serverinfo");
my $line = $telnet->getline(Timeout=>1);
if ($line =~ m/virtualserver_id=(\d+) virtual/) {
my $id = $1;
} else {
die "ERROR: server string not recognized!\n";
}
if ($line =~ m/virtualserver_name=(.*) virtualserver_welcomemessage/) {
$name = $1;
$name =~ s/\\s/ /g;
} else {
die "ERROR: server string not recognized!\n";
}
$telnet->waitfor("/error id=0 msg=ok/");
print "graph_title Teamspeak Users ".$name."\n";
print "graph_vlabel Connected Teamspeak Users\n";
print "graph_category Teamspeak\n";
print "graph_info This graph shows the number of connected users on a Teamspeak3 server\n";
print "users.label Users\n";
print "users.info Connected users to ".$name."\n";
print "users.type GAUGE\n";
exit 0;
} elsif ($mode eq "o") {
#overview mode
print "graph_title Teamspeak Users Overview\n";
print "graph_vlabel Connected Teamspeak Users\n";
print "graph_category Teamspeak\n";
print "graph_info This graph shows the number of connected users on a Teamspeak3 server\n";
foreach (@num) {
$telnet->waitfor("/Welcome/");
$telnet->cmd("use sid=".$_);
$telnet->waitfor("/error id=0 msg=ok/");
$telnet->cmd("serverinfo");
my $line = $telnet->getline(Timeout=>1);
if ($line =~ m/virtualserver_name=(.*) virtualserver_welcomemessage/) {
$name = $1;
$name =~ s/\\s/ /g;
} else {
die "ERROR: server string not recognized!\n";
}
$telnet->waitfor("/error id=0 msg=ok/");
print $_.".label ".$name."\n";
print $_.".info Users connected on ".$name."\n";
print $_.".type GAUGE\n";
}
exit 0;
} elsif ($mode eq "t") {
#transfer mode
print "graph_title Teamspeak Transfer Overview\n";
print "graph_vlabel Teamspeak Transfer\n";
print "graph_category Teamspeak\n";
print "graph_info This graph shows the Teamspeak3 Transfer Overview\n";
print "transfer.label ~ Transfer per second\n";
print "transfer.info Transfer per second over 5 min\n";
print "transfer.type DERIVE\n";
exit 0;
}
} else {
#go go magic, go!
if ($mode eq "s") {
#single mode
$telnet->waitfor("/Welcome/");
$telnet->cmd("use sid=".$server);
$telnet->waitfor("/error id=0 msg=ok/");
$telnet->cmd("serverinfo");
my $line = $telnet->getline(Timeout=>1);
if ($line =~ m/virtualserver_clientsonline=(\d+) /) {
print "users.value ".($1-1)."\n";
} else {
print "users.value 0\n";
}
$telnet->waitfor("/error id=0 msg=ok/");
} elsif ($mode eq "o") {
#overview mode
for (@num) {
$telnet->waitfor("/Welcome/");
$telnet->cmd("use sid=".$_);
$telnet->waitfor("/error id=0 msg=ok/");
$telnet->cmd("serverinfo");
my $line = $telnet->getline(Timeout=>1);
if ($line =~ m/virtualserver_clientsonline=(\d+) /) {
print $_.".value ".($1-1)."\n";
} else {
print $_.".value 0\n";
}
$telnet->waitfor("/error id=0 msg=ok/");
}
} elsif ($mode eq "t") {
$telnet->waitfor("/Welcome/");
$telnet->cmd("hostinfo");
my @tsave;
my $line = $telnet->getline(Timeout=>1);
if ($line =~ m/connection_bytes_received_total=(\d+) connection_bandwidth_sent_last_second_total/) {
$transfer = $1;
print "transfer.value ".(($transfer-($transfer%300))/300)."\n";
} else {
die "ERROR: server string not recognized!\n";
}
$telnet->waitfor("/error id=0 msg=ok/");
}
}
#close telnet connection
$telnet->close;
exit;

104
plugins/teamspeak/tsuser Executable file
View file

@ -0,0 +1,104 @@
#!/usr/bin/perl
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2 dated June,
# 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# If you modify this plugin please be kind and send a copy to mailto@cot.ath.cx
# Thanks
#
# This plugin counts the number of connected users on your teamspeak2 server.
# You have to configure the variables below.
use strict;
use Socket;
##################
# Config Section #
##################
# The Host where your teamspeak server is running on.
my $host = 'localhost';
# The tcp query port.
my $port = 51234;
# The udp ports of the servers you wish to monitor.
# Enter comma seperated values. e.g. (8767, 8766, 8876)
my @uports = (8767);
#########################
# End of Config Section #
#########################
my $string = "server_currentusers";
if ( exists $ARGV[0] and $ARGV[0] eq "config" )
{
print "graph_title Teamspeak User\n";
print "graph_vlabel Connected Teamspeak Users\n";
print "graph_category Teamspeak\n";
#print "graph_args --base 1000 -l 0\n";
print "graph_info This graph shows the number of connected users on a teamspeak2 server\n";
foreach my $server (@uports)
{
print "$server.label Users on $server\n";
print "$server.type GAUGE\n";
#print "$server.draw AREA\n";
}
exit 0;
}
elsif ( exists $ARGV[0] and $ARGV[0] eq "autoconf" )
{
my $TSTCON = &tcpConnect($port, $host);
while(<$TSTCON>)
{
if ( $_ =~ /[TS]/ )
{
print "Yes\n";
exit 0;
}
}
}
else
{
foreach my $server (@uports)
{
my $FS = &tcpConnect($port, $host);
print $FS "si ".$server, "\n\n";
my $MASK = $string."=*";
while(<$FS>)
{
my $input_line = $_;
if ( $input_line =~ m/($MASK)/ )
{
$input_line =~ /(\d+)/;
print "$server.value $1\n";
close $FS;
}
}
}
}
sub tcpConnect()
{
my $proto = getprotobyname('tcp');
my $port = shift;
my $host = shift;
socket(my $FS, PF_INET, SOCK_STREAM, $proto);
my $sin = sockaddr_in($port, inet_aton($host));
connect($FS, $sin) or die exit;
my $old_fh = select($FS); $| = 1; select($old_fh);
return($FS);
}