Added ping error

This commit is contained in:
TimZ99 2020-01-15 10:33:47 +01:00
parent 6ba4b59239
commit 0550ff7dcf
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
1 changed files with 7 additions and 5 deletions

View File

@ -175,7 +175,9 @@ class StatusUpdater
if ($max_runs == null || $max_runs > 1) {
$max_runs = 1;
}
$txt = exec("ping -c " . $max_runs . " " . $this->server['ip']);
$result = null;
// Execute ping
$txt = exec("ping -c " . $max_runs . " " . $this->server['ip'] . " 2>&1", $output);
// Non-greedy match on filler
$re1 = '.*?';
// Uninteresting: float
@ -184,16 +186,16 @@ class StatusUpdater
$re3 = '.*?';
// Float 1
$re4 = '([+-]?\\d*\\.\\d+)(?![-+0-9\\.])';
if ($c = preg_match_all("/" . $re1 . $re2 . $re3 . $re4 . "/is", $txt, $matches)) {
if (preg_match_all("/" . $re1 . $re2 . $re3 . $re4 . "/is", $txt, $matches)) {
$result = $matches[1][0];
} else {
$result = null;
}
if (!is_null($result)) {
$this->header = $output[0];
$status = true;
} else {
$this->header = "-";
$this->error = $output[0];
$status = false;
}
//Divide by a thousand to convert to milliseconds