X-Git-Url: http://git.pjr.cc/?p=glcas.git;a=blobdiff_plain;f=bin%2Fpinghelper.php;fp=bin%2Fpinghelper.php;h=d1e85334d49951810446da2d260dedee780cafe2;hp=0000000000000000000000000000000000000000;hb=e842b9e98acbc69ea55e655130b68df06f25b3cd;hpb=e81521d3926c7dff1484e5c86a02dcfd8dc93b8e diff --git a/bin/pinghelper.php b/bin/pinghelper.php new file mode 100644 index 0000000..d1e8533 --- /dev/null +++ b/bin/pinghelper.php @@ -0,0 +1,56 @@ +loadConfig($configpath); + + +$range = ""; +if(isset($argv[1])) { + $range = $argv[1]; +} else { + echo "Need at least one ip address\n"; +} + +for($i=1; $i < $argc; $i++) { + echo "pinging ".$argv[$i]."\n"; + $ip = $argv[$i]; + $res = exec("/bin/ping -c 1 $ip 2>&1", $arr, $returned); + + if($returned != 0) { + $glconfig->delData("ping", "$ip"); + $glconfig->addData("ping", "$ip", time(), "failed"); + } else { + $res_v = preg_split("/[\/ ]+/",$res); + $rettime = $res_v[7]; + print_r($res_v); + $glconfig->delData("ping", "$ip"); + $glconfig->addData("ping", "$ip", time(), $rettime); + } +} + +?> \ No newline at end of file