Makull
27-08-2002, 10:23
Here is a Perl script I made to capture the stats the new 2.x server sends. I don't know where to place a second stats link in the ini file (you could in v1 but it doesn't seem to be in v2) so I altered the PostURL value in the ini file to point to my own script).
Here is the script :
#!/usr/bin/perl
#
# This file will save the statistics from TeamSpeak 2 to a local file
#
use strict;
use warnings;
use Fcntl ":flock";
use CGI;
# which path did we start from?
$0 =~ m/(.*)(\\|\/)/;
my $pathprogram = $1;
# save in @INC
push (@INC, $pathprogram);
# the filename to use for the stats
my $stats_file = 'stats.received';
# create CGI object
my $query = new CGI;
# open the stats file for writing
open(FILE, ">$pathprogram/$stats_file") || die("Couldn't open file $stats_file : $!\n");
flock(FILE, LOCK_EX);
# write all key/value pairs to the file
foreach my $item ($query->param) {
print FILE $item."=".$query->param($item)."\n";
}
flock(FILE, LOCK_UN);
close(FILE);
# in case the server requires scripts to send something back, just send a HTML header
print "Content-Type: text/html\n\n";
# Done
and here is an example of what you will get in the stats.received file :
server_adminemail=na
server_isplinkurl=na
server_ispname=Private
server_ispcountry=Earth
server_platform=Linux
server_version_major=2
server_version_minor=0
server_version_release=17
server_version_build=17
server_port=8767
server_name=Makull's BabbleBox
server_uptime=783
server_password=1
server_type1=clan
server_type2=freeware
clients_current=0
clients_maximum=10
channels_current=1
server_queryport=51234
You can then use a SSI or whatever to include this info on a webpage.
Here is the script :
#!/usr/bin/perl
#
# This file will save the statistics from TeamSpeak 2 to a local file
#
use strict;
use warnings;
use Fcntl ":flock";
use CGI;
# which path did we start from?
$0 =~ m/(.*)(\\|\/)/;
my $pathprogram = $1;
# save in @INC
push (@INC, $pathprogram);
# the filename to use for the stats
my $stats_file = 'stats.received';
# create CGI object
my $query = new CGI;
# open the stats file for writing
open(FILE, ">$pathprogram/$stats_file") || die("Couldn't open file $stats_file : $!\n");
flock(FILE, LOCK_EX);
# write all key/value pairs to the file
foreach my $item ($query->param) {
print FILE $item."=".$query->param($item)."\n";
}
flock(FILE, LOCK_UN);
close(FILE);
# in case the server requires scripts to send something back, just send a HTML header
print "Content-Type: text/html\n\n";
# Done
and here is an example of what you will get in the stats.received file :
server_adminemail=na
server_isplinkurl=na
server_ispname=Private
server_ispcountry=Earth
server_platform=Linux
server_version_major=2
server_version_minor=0
server_version_release=17
server_version_build=17
server_port=8767
server_name=Makull's BabbleBox
server_uptime=783
server_password=1
server_type1=clan
server_type2=freeware
clients_current=0
clients_maximum=10
channels_current=1
server_queryport=51234
You can then use a SSI or whatever to include this info on a webpage.