From dbc4a16539c59d4b7c62e38ee98f6bb6039cf9fd Mon Sep 17 00:00:00 2001 From: David <75451291+dulkoss@users.noreply.github.com> Date: Fri, 22 Sep 2023 15:53:14 +0200 Subject: [PATCH 1/2] add PingCheck --- src/Checks/PingCheck.php | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/Checks/PingCheck.php 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}],"); + } +} From 02bf442e809cf538f56315de3e543df5e3723b61 Mon Sep 17 00:00:00 2001 From: dulkoss Date: Fri, 22 Sep 2023 13:55:53 +0000 Subject: [PATCH 2/2] Fix styling --- src/Checks/StorageCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }