Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2016
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2. require '../autoload.php';
  3. $Config = new Config();
  4.  
  5.  
  6. $datas = array();
  7.  
  8. if (count($Config->get('ping:hosts')) > 0)
  9. $hosts = $Config->get('ping:hosts');
  10.  
  11. foreach ($hosts as $host)
  12. {
  13. exec('/bin/ping -c 1 '.$host.' | awk -F/ \'/^rtt/ { print $5 }\'', $result);
  14.  
  15. if (!isset($result[0]))
  16. {
  17. $result[0] = 0;
  18. }
  19.  
  20. $datas[] = array(
  21. 'host' => $host,
  22. 'ping' => $result[0],
  23. );
  24.  
  25. unset($result);
  26. }
  27.  
  28. echo json_encode($datas);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement