Files
html/api/s95-ping.php

28 lines
993 B
PHP

<?php
header('Content-Type: application/json');
// S95 checks (inside network, private IPs accessible)
$targets = [
'S95_10.1.0.3_5432' => '10.1.0.3:5432',
'S95_10.1.0.3_22' => '10.1.0.3:22',
'S95_95.216.167.89_5890' => '95.216.167.89:5890',
'S95_95.216.167.89_8443' => '95.216.167.89:8443',
'S95_95.216.167.89_22' => '95.216.167.89:22',
'S151_151.80.235.110_80' => '151.80.235.110:80',
'S151_151.80.235.110_22' => '151.80.235.110:22',
];
$results = [];
foreach ($targets as $name => $hp) {
list($host, $port) = explode(':', $hp);
$t0 = microtime(true);
$fp = @fsockopen($host, (int)$port, $err, $errstr, 3);
$lat = round((microtime(true) - $t0) * 1000, 1);
$results[$name] = $fp ? ['up' => true, 'lat_ms' => $lat] : ['up' => false, 'err' => $errstr ?: 'timeout'];
if ($fp) fclose($fp);
}
echo json_encode([
'doctrine' => 216,
'source' => 'S204_inside',
'targets' => $results,
'generated' => date('c')
], JSON_PRETTY_PRINT);