ryuma
Member
- May 30, 2016
- 36
- 1
- 43
Hi,
I want to share a simple monitoring system.
the first pass the script changes the name of the server and welcome message
the second execution of the script if the server name has changed, the server is turned off.
in the third script execution if the server is lagged behind the AFK, it is removed.
Create a file in the root of your script and add it to the cron
I want to share a simple monitoring system.
the first pass the script changes the name of the server and welcome message
the second execution of the script if the server name has changed, the server is turned off.
in the third script execution if the server is lagged behind the AFK, it is removed.
Create a file in the root of your script and add it to the cron
PHP:
<html>
<?php
require_once(__DIR__.'/libs/TeamSpeak3/TeamSpeak3.php');
require_once(__DIR__.'/configs/settingsts3.php');
$tslist = TeamSpeak3::factory("serverquery://".$ts3_user.":".$ts3_pass."@".$ts3_ip.":".$ts3_queryport."");
$afkName = 'AFK SYSTEM I-VOICE';
$afkMessage = 'Здравствуйте, во избежание отключения TeamSpeak3 сервера, измените название сервера установленнное системой мониторинга';
foreach ($tslist->serverList() as $serverID => $serverNAME)
{
if(strcasecmp($serverNAME->virtualserver_status,'online') == 0 )
{
if ($serverNAME->virtualserver_maxclients <= 50)
{
if(strcasecmp($serverNAME, $afkName) == 0 )
{
$server_aurostartoff = $serverNAME->virtualserver_autostart = 0;
$server_stop = $tslist->serverStop($serverID);
echo 'Сервер ID - ' .$serverID. ': Порт - ' .$serverPORT. ' : Отключен<br>';
}
else
{
$serverPORT = $serverNAME->virtualserver_port;
$modifServer = $serverNAME->modify(array(
"virtualserver_name" => $afkName,
"virtualserver_welcomemessage" => $afkMessage,
));
echo 'Сервер ID - ' .$serverID. ': Порт - ' .$serverPORT. ' : Переименован ' .$serverNAME. '<br>';
}
}
usleep(200000);
}
elseif (strcasecmp($serverNAME->virtualserver_status,'offline') == 0 )
{
if(strcasecmp($serverNAME, $afkName) == 0 )
{
$serverPORT = $serverNAME->virtualserver_port;
$server_del = $tslist->serverDelete($serverID);
echo 'Сервер: ID - ' .$serverID. ': Порт - ' .$serverPORT. ' : Удален по причине ' .$serverNAME. '<br>';
}
usleep(200000);
}
else {echo 'Нет серверов для редактирования';}
}
?>
</html>