46 lines
1 KiB
PHP
46 lines
1 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* Holds the status-check command controller.
|
||
|
* @package Sakura
|
||
|
*/
|
||
|
|
||
|
namespace Sakura\Console\Command;
|
||
|
|
||
|
use CLIFramework\Command;
|
||
|
use Sakura\Status;
|
||
|
|
||
|
/**
|
||
|
* Checks status for hosts set in config and saves results to the database.
|
||
|
* @package Sakura
|
||
|
* @author Julian van de Groep <me@flash.moe>
|
||
|
*/
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|