2014-06-18 04:11:11 -04:00
|
|
|
<?php
|
2015-07-07 09:57:41 -04:00
|
|
|
require '../autoload.php';
|
2014-06-18 04:11:11 -04:00
|
|
|
$Config = new Config();
|
|
|
|
|
|
|
|
|
|
|
|
$datas = array();
|
|
|
|
|
|
|
|
if (count($Config->get('ping:hosts')) > 0)
|
|
|
|
$hosts = $Config->get('ping:hosts');
|
|
|
|
else
|
|
|
|
$hosts = array('google.com', 'wikipedia.org');
|
|
|
|
|
|
|
|
foreach ($hosts as $host)
|
|
|
|
{
|
|
|
|
exec('/bin/ping -qc 1 '.$host.' | awk -F/ \'/^rtt/ { print $5 }\'', $result);
|
|
|
|
|
2014-11-11 09:28:05 -05:00
|
|
|
if (!isset($result[0]))
|
|
|
|
{
|
|
|
|
$result[0] = 0;
|
|
|
|
}
|
|
|
|
|
2014-06-18 04:11:11 -04:00
|
|
|
$datas[] = array(
|
|
|
|
'host' => $host,
|
|
|
|
'ping' => $result[0],
|
|
|
|
);
|
|
|
|
|
|
|
|
unset($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($datas);
|