Community Forums Today's Posts     Member List     Archive    
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Location
    The Netherlands
    Posts
    18

    Teamspeak 2 stats script for Perl (simple)

    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 :
    Code:
    #!/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.

  2. #2
    Join Date
    Jun 2002
    Location
    Northern California
    Posts
    351
    As a rule, use -wT in the shebang line, to get Taint mode turned on. (This doesn't normally work in Windows Perl, though. See the Active State site for more info on how to deal with that.)

    Also note that there's a separate forum for Webpost/scripts, as those will be common to the Linux and Windows servers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 16
    Last Post: 25-11-2008, 09:16
  2. Simple way to setup Teamspeak Server for you and your friends
    By toonarmy in forum [TeamSpeak 2] Server Support
    Replies: 0
    Last Post: 05-05-2008, 14:11
  3. Stats Script...
    By Bigman in forum [TeamSpeak 2] Addons & Scripts
    Replies: 1
    Last Post: 13-03-2003, 10:08
  4. TeamSpeak Server won't report Statistics to your Webserver/PHP Script
    By T. Boonstra in forum [TeamSpeak Classic] General Questions
    Replies: 0
    Last Post: 21-06-2002, 21:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •