diff --git a/src/Checks/PingCheck.php b/src/Checks/PingCheck.php new file mode 100644 index 0000000..ce52f0b --- /dev/null +++ b/src/Checks/PingCheck.php @@ -0,0 +1,43 @@ +address = $address; + + return $this; + } + + public function maxTimeout(int $milliseconds): static + { + $this->waitTime = $milliseconds; + + return $this; + } + + public function run(): Result + { + $result = Result::new(); + + $process = Process::run("ping {$this->address} -c 1 -W {$this->waitTime}"); + + if (! $process->successful()) { + throw new \Exception($process->errorOutput()); + } + + return ! str_contains($output = $process->output(), '1 packets out of wait time') && str_contains($output, '1 packets received') + ? $result->ok("Application is able to ping address [{$this->address}]") + : $result->failed("Application is unable to ping address [{$this->address}],"); + } +} diff --git a/src/Checks/StorageCheck.php b/src/Checks/StorageCheck.php index 2370f8c..8236782 100644 --- a/src/Checks/StorageCheck.php +++ b/src/Checks/StorageCheck.php @@ -61,7 +61,7 @@ public function run(): Result foreach ($directories as $directory) { $checked[] = $directory; $directory = implode('/', $checked); - + if (! empty($disk->allFiles($directory))) { continue; }