TeamSpeak-3 - Current Players Template

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
initzero
Posts: 5
Joined: Tue Mar 17, 2009 12:43 pm

TeamSpeak-3 - Current Players Template

Post by initzero »

Hi Cacti Community,

For Teamspeak2 there are one nice Cacti Template available where give a good overview how many players are connected on a TeamSpeak-2 server.

No I have searched for a new templates for the TeampSpeak3 server.
And I have found one nice Perl-script where are coded for the Munin application. This Perl-script readout the virtualserver_clientsonline for each TS3 instance.

So I'm a really bad code-scripter and my Cacti knowhow are also limited. Maybe it will suffice to adapt the old code from Pinky... But if there someone where will code a new template that would be really awesome...

Cheerio,
InitZero
Korigon
Posts: 5
Joined: Tue Jul 26, 2005 7:09 pm

Post by Korigon »

Do you use Teamspeak 2 template already? (i mean with server selection ip:port) like this one http://forums.cacti.net/viewtopic.php?p=104424#104424 ?

if yes, you can use this script (ts3.php) with some cosmetic change in your XML..
Just remplace IP:Port by IP:ServerID

Code: Select all

root@ns1:/usr/share/cacti/site/scripts >php ts2.php 127.0.0.1:9006
max:100 now:55
root@ns1:/usr/share/cacti/site/scripts >php ts3.php 127.0.0.1:1
max:100 now:22
ts3.php

Code: Select all

#!/usr/bin/php
<?
 function getSocket($host, $port, $errno, $errstr, $timeout) {
        global $errno, $errstr;
        $socket = fsockopen($host, $port, $errno, $errstr, $timeout);
        if(!$socket or fread($socket, 3) != "TS3") {
                echo("Server error: Teamspeak server not running!\n");
                return false;
        }
        return $socket;
 }

 function sendQuery($socket, $query) {
        fputs($socket, $query."\n");
 }

 function closeSocket($socket) {
        fputs($socket, "quit\n");
 fclose($socket);
 }

 $server = explode(":", $argv[1]);
 $socket = getSocket($server[0], 10011, $errno, $errstr, 1);
 if($errno != 0) exit(1);
 sendQuery($socket, "use sid=".$server[1]);
 fread($socket, 19);
 sendQuery($socket, "serverinfo");
 $vars = fread($socket, 3000);
 closeSocket($socket);
 $var1 = explode(" ", $vars);
 $now = explode("=", $var1[7]);
 $max = explode("=", $var1[5]);
 $n = $now[1]-1;
 echo "max:$max[1] now:$n";
?>
All credits to original owner.
Attachments
cacti_graph_template_teamspeak_3_-_players.xml
TeamSpeak 3 Template updated.
(8.89 KiB) Downloaded 629 times
Hendrik
Posts: 4
Joined: Fri Apr 02, 2010 5:55 pm

Post by Hendrik »

Hi,

Any idea to get the traffic from the teamspeak 3 servers?

When ts3 restarts the counters are reset so i want cacti to monitor the traffic.

Thanks for the update on the players stats.
Its working great.
Hendrik
Posts: 4
Joined: Fri Apr 02, 2010 5:55 pm

Post by Hendrik »

I changed your script to get

Code: Select all

connection_bytes_sent_total=

Code: Select all

connection_bytes_received_total=
Only have no idea on how to make a template for it so it are nice graphs like interface traffic.

edit: nvm
Attachments
cacti_grafph_ts3_online_users.JPG
cacti_grafph_ts3_online_users.JPG (47.82 KiB) Viewed 10557 times
cacti_grafph_ts3_traffic.JPG
cacti_grafph_ts3_traffic.JPG (64.13 KiB) Viewed 10557 times
vtesei
Posts: 1
Joined: Fri Jun 18, 2010 2:41 am

Post by vtesei »

I make some changes to the script and work on template you posted, i've done some changes to get working bandwidth and players together so, it's based on scripts/templates in this page, and i would give a feedback to this community.

First problem i found was that server info was unable to be obtained without use of serverquery user/password [given by ts3 on its first start] .

what i'm posting is the result of my tries :)

Hope this will ben useful

Image
Image

Pack i post contains:
- bandwidth template & dependency
- players template & dependency
- php scripts i create to manage TS3, it is easy to extend if needed.
Attachments
teamspeak3_cacti.zip
(7.14 KiB) Downloaded 474 times
Hendrik
Posts: 4
Joined: Fri Apr 02, 2010 5:55 pm

Re: TeamSpeak-3 - Current Players Template

Post by Hendrik »

Does this script stopped working for beta29?

edit:
They added:

Code: Select all

! serverquery sends between the ts3 prompt also a new welcome message 
Korigon
Posts: 5
Joined: Tue Jul 26, 2005 7:09 pm

Re: TeamSpeak-3 - Current Players Template

Post by Korigon »

Beta29 Welcome fix.

ts3.php

Code: Select all

#!/usr/bin/php
<?
 function getSocket($host, $port, $errno, $errstr, $timeout) {
        global $errno, $errstr;
        $socket = fsockopen($host, $port, $errno, $errstr, $timeout);
        if(!$socket or fread($socket, 4) != "TS3\n") {
                echo("Server error: Teamspeak server not running!\n");
                return false;
        }
        fread($socket, 200);
        return $socket;
 }

 function sendQuery($socket, $query) {
        fputs($socket, $query."\n");
 }

 function closeSocket($socket) {
        fputs($socket, "quit\n");
 fclose($socket);
 }

 $server = explode(":", $argv[1]);
 $socket = getSocket($server[0], 10011, $errno, $errstr, 1);
 if($errno != 0) exit(1);
 sendQuery($socket, "use sid=".$server[1]);
 fread($socket, 19);
 sendQuery($socket, "serverinfo");
 $vars = fread($socket, 3000);
 closeSocket($socket);
 $var1 = explode(" ", $vars);
 $now = explode("=", $var1[7]);
 $max = explode("=", $var1[5]);
 $n = $now[1]-1;
 echo "max:$max[1] now:$n";
?>
Hendrik
Posts: 4
Joined: Fri Apr 02, 2010 5:55 pm

Re: TeamSpeak-3 - Current Players Template

Post by Hendrik »

Thanks. :)

Its working again.

Only real slow for large teamspeak3 servers.
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: TeamSpeak-3 - Current Players Template

Post by TheWitness »

PHP is an awesome language...
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
cuculetea
Posts: 2
Joined: Tue Feb 28, 2012 9:44 am

Re: TeamSpeak-3 - Current Players Template

Post by cuculetea »

I see this is an old post, but anyone have it worked on latest version of teamspeak?!
ShadoX
Posts: 2
Joined: Thu Mar 08, 2012 5:59 am

Re: TeamSpeak-3 - Current Players Template

Post by ShadoX »

^ Bump ^

I'm also really interested in this, especially the players and bandwidth one :D
Any help would be great!
Some_Bored_Dude
Posts: 1
Joined: Sat Dec 27, 2008 8:35 pm
Location: Albany, WA
Contact:

Re: TeamSpeak-3 - Current Players Template

Post by Some_Bored_Dude »

I've added the changes from Korigon's post to vtesei's script which I can confirm works for me on TeamSpeak 3.0.5.

I am not the original author the template/script so I cannot provide guaranteed support.

The only thing I had problem with was Cacti's spine for polling. When I used that I couldn't get the players graph to populate. A debug of the log file showed it was getting a result of "output: U". Once I changed it to cmd.php for poller it started to work. Might have a bit more of a tackle later.
Attachments
teamspeak3_cacti_v0.2.zip
(6.76 KiB) Downloaded 349 times
cherrybox
Posts: 1
Joined: Wed Aug 28, 2013 10:37 pm

Re: TeamSpeak-3 - Current Players Template

Post by cherrybox »

shameless bump.

I've attempted to configure this using cacti 0.8.7e however the graph is unable to populate.

debug shows the following:

Code: Select all

AREA:a#8D85F3FF:"Clients"  \
GPRINT:a:LAST:"Now\:%8.0lf"  \
GPRINT:a:AVERAGE:"Avg\:%8.0lf"  \
GPRINT:a:MAX:"Max\:%8.0lf\n" 
RRDTool Says:
OK
running ts3_extended.php from ~/scripts/ shows the following:

Code: Select all

php ts3_extended.php IP ID admin admin clients
*removed actual details*
max:512 now:64

any ideas on why this might not be populating?
Gunslinger1973
Posts: 1
Joined: Fri Mar 21, 2014 3:21 am

Re: TeamSpeak-3 - Current Players Template

Post by Gunslinger1973 »

Hi out there

I'm lost and need some basic help on installing this template.

I have successfully imported the templates (bandwith and #of players). I now have in Cacti
  • Data Input Method
    Graph Templates
    Data Templates
The ts3_extended.php is present.

I dont' have a Data Query and/or Host Template.

When I create a new device I can create the Data sources but I dont have any data queries.

About the script in general - where do I change the query port and why do I nees a user and password?

Any help is appreciated ;-)
Regards,
Gunslinger
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests