ezservermonitor-web/libs/ping.php
ShevAbam 9970343fe5 General : cleaning and optimizing CSS
General : responsive design
General : reload button now spins when you reload block
General : update jQuery plugin Knob to 1.2.11
General : optimizing security (config file esm.config.json is now in the conf/ folder with an htaccess)
CPU : retrieves correctly CPU frequency for Raspberry Pi
CPU : add CPU temperature (+ option to enable/disable)
System : little correction for getting distro name
Swap : fix if swap is disabled
Services status : adds protocol TCP or UDP for checking service status
Services status : new option to hide port number (see show_port in services section)
2015-07-07 15:57:41 +02:00

30 lines
532 B
PHP

<?php
require '../autoload.php';
$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);
if (!isset($result[0]))
{
$result[0] = 0;
}
$datas[] = array(
'host' => $host,
'ping' => $result[0],
);
unset($result);
}
echo json_encode($datas);