From 687d49a9580728e3cf2c97c2bdd3c76e9542157f Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 10 Dec 2016 20:47:09 +0100 Subject: [PATCH] add status check command --- app/Console/Command/StatusCheckCommand.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/Console/Command/StatusCheckCommand.php diff --git a/app/Console/Command/StatusCheckCommand.php b/app/Console/Command/StatusCheckCommand.php new file mode 100644 index 0000000..3bb839f --- /dev/null +++ b/app/Console/Command/StatusCheckCommand.php @@ -0,0 +1,45 @@ + + */ +class StatusCheckCommand extends Command +{ + /** + * A quick description of this command. + * @return string. + */ + public function brief(): string + { + return 'Checks status for hosts set in config and saves results to the database.'; + } + + /** + * Command. + */ + public function execute(): void + { + $endpoints = config('status.check'); + + foreach ($endpoints as $name => $data) { + [$host, $port, $proc] = explode('/', $data, 3); + + $this->getLogger()->writeln("Checking {$host} ($proc) on port {$port}..."); + + $status = new Status($host, $port, $proc); + $status->check(); + $status->save(); + } + } +}