diff options
author | ShevAbam <shevabam@gmail.com> | 2014-06-18 10:11:11 +0200 |
---|---|---|
committer | ShevAbam <shevabam@gmail.com> | 2014-06-18 10:11:11 +0200 |
commit | 20705a550df5b13a544dc0865c6aef16e64c99d9 (patch) | |
tree | e396dface41e30d39a68d5fe66097b1f8f641a81 /libs/ping.php |
+ First commit (version 2.0)v2.0
Diffstat (limited to 'libs/ping.php')
-rw-r--r-- | libs/ping.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libs/ping.php b/libs/ping.php new file mode 100644 index 0000000..1cadb70 --- /dev/null +++ b/libs/ping.php @@ -0,0 +1,25 @@ +<?php +require 'Utils/Config.class.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); + + $datas[] = array( + 'host' => $host, + 'ping' => $result[0], + ); + + unset($result); +} + +echo json_encode($datas);
\ No newline at end of file |