freets3.ovh
Active Member
- Sep 19, 2015
- 150
- 105
- 85
Hello, I decided to share my status script with you, here is a demo : http://admin.freets3.ovh/stats.php
PHP:
status.php
<?
require("config.php");
$count = 0;
foreach(array_reverse($roots) as $serv){
$servip = $roots[$count][0];
$servport = $roots[$count][1];
try{
$con = TeamSpeak3::factory("serverquery://serveradmin:{$querypw}@{$servip}:{$servport}/");
$curservers = $con["virtualservers_running_total"];
}catch(Exception $e){
echo "Error (ID ".$e->getCode().") <b>".$e->getMessage()."</b> on IP: $servip:$servport<br/>";
}
$count++;
if($curservers < $serv_limit){
$curport = $servport;
$curip = $servip;
$servno = $count;
break;
}
}
?>
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Server</th>
<th>Servers Online</th>
<th>Clients Online</th>
<th>Bandwidth</th>
<th>IP</th>
</tr>
</thead>
<tbody><?
$count = 0;
foreach($roots as $serv){
$servip = $roots[$count][0];
$servport = $roots[$count][1];
//Create connection
$con = TeamSpeak3::factory("serverquery://serveradmin:{$querypw}@{$servip}:{$servport}/");
// Get info
$curservers = $con["virtualservers_running_total"];
$curclients = $con["virtualservers_total_clients_online"];
$curbytes = ($con["connection_bytes_received_total"] / 1024);
if($curservers < 1000){
$class = " class=\"success\"";
}else{
$class = " class=\"danger\"";
}
// Calculate totals
$servers = ($con["virtualservers_running_total"] + $servers);
$clients = ($con["virtualservers_total_clients_online"] + $clients);
$band = ($con["connection_bytes_received_total"] + $con["connection_bytes_sent_total"] + $band);
$count++; // Increment counter
echo "<tr$class>";
echo "<td>Query #$count</td>";
echo "<td>".number_format($curservers)."</td>";
echo "<td>".number_format($curclients)."</td>";
echo "<td>".TeamSpeak3_Helper_Convert::bytes($curbytes)."</td>";
echo "<td>$servip:$servport</td>";
echo "</tr>";
} ?>
<tr>
<td>
<b>Totals</b>
</td>
<td><?
echo number_format($servers)?>
</td>
<td><?
echo number_format($clients)?>
</td>
<td><?
echo TeamSpeak3_Helper_Convert::bytes($band)?>
</td>
<td>
All
</td>
</tr>
</tbody>
</table>
PHP:
config.php
<?
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$serv_limit = 1000;
$querypw = "Query Password";
$roots = array(
array("149.202.65.197",10011),
array("149.202.65.197",10012),
array("149.202.65.197",10013),
array("149.202.65.197",10014),
array("149.202.65.197",10016),
array("149.202.65.197",10017),
array("149.202.65.197",10018),
array("149.202.65.197",10020),
array("149.202.65.197",10022),
array("149.202.65.197",10023),
array("149.202.65.197",10024),
array("149.202.65.197",10025),
array("149.202.65.197",10026)
);
?>
I think you forgot to mention that you need bootstrap for that table
Last edited: