|
|
@ -3,15 +3,6 @@ require_once('../vendor/autoload.php');
|
|
|
|
require_once('help.php'); // provides $help_texts
|
|
|
|
require_once('help.php'); // provides $help_texts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$host = 'localhost';
|
|
|
|
|
|
|
|
$port = 10011;
|
|
|
|
|
|
|
|
$user = rawurlencode('serveradmin');
|
|
|
|
|
|
|
|
$password = rawurlencode('4NReP1Wf');
|
|
|
|
|
|
|
|
$ssh = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$uri = 'serverquery://'.$user.':'.$password.'@'.$host.':'.$port.'/';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// initialize the Prometheus registry
|
|
|
|
// initialize the Prometheus registry
|
|
|
|
$registry = new \Prometheus\CollectorRegistry(new \Prometheus\Storage\InMemory());
|
|
|
|
$registry = new \Prometheus\CollectorRegistry(new \Prometheus\Storage\InMemory());
|
|
|
|
$namespace = 'ts3';
|
|
|
|
$namespace = 'ts3';
|
|
|
@ -20,11 +11,25 @@ $virtualserver_label_keys = [
|
|
|
|
'virtualserver_port',
|
|
|
|
'virtualserver_port',
|
|
|
|
'virtualserver_unique_identifier'
|
|
|
|
'virtualserver_unique_identifier'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
$totals = [
|
|
|
|
|
|
|
|
'virtualserver_uptime'
|
|
|
|
// set ${namespace}_up for exporter status
|
|
|
|
];
|
|
|
|
$up = $registry->getOrRegisterGauge(
|
|
|
|
|
|
|
|
$namespace,
|
|
|
|
|
|
|
|
'up',
|
|
|
|
|
|
|
|
$help_texts['up'],
|
|
|
|
|
|
|
|
[]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
$up->set(1, []);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$host = '192.168.178.55';
|
|
|
|
|
|
|
|
$port = 10011;
|
|
|
|
|
|
|
|
$user = rawurlencode('serveradmin');
|
|
|
|
|
|
|
|
$password = rawurlencode('4NReP1Wf');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$uri = 'serverquery://'.$user.':'.$password.'@'.$host.':'.$port.'/';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
// open a connection to the server
|
|
|
|
// open a connection to the server
|
|
|
|
$ts3 = TeamSpeak3::factory($uri);
|
|
|
|
$ts3 = TeamSpeak3::factory($uri);
|
|
|
|
|
|
|
|
|
|
|
@ -37,7 +42,6 @@ foreach($ts3->serverList() as $virtualserver) {
|
|
|
|
|
|
|
|
|
|
|
|
// fill $virtualserver_label_values
|
|
|
|
// fill $virtualserver_label_values
|
|
|
|
foreach($virtualserver_label_keys as $virtualserver_label_key) {
|
|
|
|
foreach($virtualserver_label_keys as $virtualserver_label_key) {
|
|
|
|
$value = $infos[$virtualserver_label_key];
|
|
|
|
|
|
|
|
$virtualserver_label_values[] = $infos[$virtualserver_label_key];
|
|
|
|
$virtualserver_label_values[] = $infos[$virtualserver_label_key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -58,9 +62,13 @@ foreach($ts3->serverList() as $virtualserver) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
|
|
|
// something failed, set ${namespace}_up to 0
|
|
|
|
|
|
|
|
$up->set(0, []);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// render all metrics as HTML and output them
|
|
|
|
// render all metrics and output them
|
|
|
|
$renderer = new \Prometheus\RenderTextFormat();
|
|
|
|
$renderer = new \Prometheus\RenderTextFormat();
|
|
|
|
$result = $renderer->render($registry->getMetricFamilySamples());
|
|
|
|
$result = $renderer->render($registry->getMetricFamilySamples());
|
|
|
|
|
|
|
|
|
|
|
|