diff --git a/app/AgentScheduler.php b/app/AgentScheduler.php index 5b5553556e5bd5910916b0ae0e4f62396863250a..8ec0514d0a71d6187570aa558fea02ba010ed5a6 100644 --- a/app/AgentScheduler.php +++ b/app/AgentScheduler.php @@ -19,7 +19,7 @@ class AgentScheduler { /** - * + * * @var LazyCollection<Sensor> */ private $sensors; @@ -46,7 +46,7 @@ class AgentScheduler } /** - * + * * @return LazyCollection<Sensor> */ public function sensors() : LazyCollection @@ -55,7 +55,7 @@ class AgentScheduler } /** - * + * * @return LazyCollection<Sensor> */ public function autodiscover() : LazyCollection @@ -74,7 +74,7 @@ class AgentScheduler } /** - * + * * @param LazyCollection<Sensor> $sensors * @return array */ @@ -92,12 +92,14 @@ class AgentScheduler /** * Get the list of defined agent labels. - * + * * @return array */ public function agentLabel() : array { - return $this->sensors->map(function(Sensor $sensor) {return $sensor->config()->label; })->toArray(); + return $this->sensors->map(function (Sensor $sensor) { + return $sensor->config()->label; + })->toArray(); } // ------------------ SCHEDULING of agents diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index fe98d115a1816a9e3086ca35349628559bc1aac5..1efd38846ddac9dae13c1169360a276dbed26a72 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -7,7 +7,8 @@ use App\Record; use Illuminate\Http\Request; -class ApiController extends Controller { +class ApiController extends Controller +{ public function echo(Request $request, Server $server) { @@ -58,7 +59,7 @@ class ApiController extends Controller { "max" => $server->info()->cpuinfo()["threads"]]; } - public function ifconfig (Server $server, string $token) + public function ifconfig(Server $server, string $token) { if ($server->read_token != $token) { abort(403); @@ -69,7 +70,7 @@ class ApiController extends Controller { return $sensor->points($server->lastRecords("ifconfig")); } - public function netstat (Server $server, string $token) + public function netstat(Server $server, string $token) { if ($server->read_token != $token) { abort(403); diff --git a/app/Jobs/RunAgent.php b/app/Jobs/RunAgent.php index 661937e9352af808da45e8c7e0cde128b8876d7d..db2eabf2cc6c697efad0902175cd06da19682372 100644 --- a/app/Jobs/RunAgent.php +++ b/app/Jobs/RunAgent.php @@ -16,14 +16,14 @@ class RunAgent implements ShouldQueue use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; /** - * + * * @var Sensor */ public $agent; /** - * + * * @var Server */ public $server; diff --git a/app/Jobs/StatusChangeDetection.php b/app/Jobs/StatusChangeDetection.php index c7df7498041371dd25c07bb87e9d99fc7b9b54d8..3cedb35cebc887100ec4b30e229ec384e5d78c8f 100644 --- a/app/Jobs/StatusChangeDetection.php +++ b/app/Jobs/StatusChangeDetection.php @@ -45,7 +45,7 @@ class StatusChangeDetection implements ShouldQueue $change = new StatusChange(); $change->server_id = $server->id; $change->time = time(); - $change->status = $current_status->code(); + $change->status = $current_status->code(); $change->save(); return; } @@ -55,7 +55,7 @@ class StatusChangeDetection implements ShouldQueue return; } - Log::notice("Status of server changed to " . $current_status->code() . + Log::notice("Status of server changed to " . $current_status->code() . " for server #" . $server->id); $change = new StatusChange(); diff --git a/app/Record.php b/app/Record.php index ca5801b96b8331bdfe977a91e57d7a3567867058..d12fac44a6763efc52c2d4cada1b8a686a4877b4 100644 --- a/app/Record.php +++ b/app/Record.php @@ -21,9 +21,9 @@ class Record extends Model return $this->belongsTo(Server::class); } - public function save(array $options = []) { + public function save(array $options = []) + { if (parent::save($options)) { - AgentScheduler::get()->notify($this); return true; } diff --git a/app/Report.php b/app/Report.php index d21932e1e09778e554bad09ae168b5418730d06b..030280ae508044de30c807b36025e0cc3e28de4c 100644 --- a/app/Report.php +++ b/app/Report.php @@ -11,12 +11,12 @@ use Illuminate\Database\Eloquent\Model; * @property integer $time * @property integer $server_id * @property string $label - * + * * Properties set by analysis agent: * @property int $status_code * @property string $title * @property string $html - * + * * @author tibo */ class Report extends Model implements HasStatus diff --git a/app/Sensor/CPUtemperature.php b/app/Sensor/CPUtemperature.php index cfa522848c1708b7259ae7abf6f96ddcb8b0d2a3..c26f250dd17548c58931127eb7e5ca8d632c0d81 100644 --- a/app/Sensor/CPUtemperature.php +++ b/app/Sensor/CPUtemperature.php @@ -34,7 +34,7 @@ class CPUtemperature implements Sensor { $report = (new Report())->setTitle("CPU temperature"); - $record = $records->last(); + $record = $records->last(); $cpus = $this->parse($record->data); $report->setHTML(view("sensor.cputemperature", ["cpus" => $cpus])); $report->setStatus(Status::max($cpus)); diff --git a/app/Sensor/ClientVersion.php b/app/Sensor/ClientVersion.php index 600d07109baf5e6bfb518ef38e5a576734ac4224..ce1611a75a7bccdaf1529f3c2bca15e4a94995a1 100644 --- a/app/Sensor/ClientVersion.php +++ b/app/Sensor/ClientVersion.php @@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\Collection; */ class ClientVersion implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("client-version", "version"); } diff --git a/app/Sensor/Date.php b/app/Sensor/Date.php index fa7580834bae846ca382d8b0b3cbc7d327233138..2e1857bb646fa51eb706d63a56dedff4614e9f7a 100644 --- a/app/Sensor/Date.php +++ b/app/Sensor/Date.php @@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection; */ class Date implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("date", "date"); } diff --git a/app/Sensor/Disks.php b/app/Sensor/Disks.php index 3edc3ebe9f664e598cde4c15fc98174a69fd4a94..2469d4043c550a5215dae975e5de91d1c643adca 100644 --- a/app/Sensor/Disks.php +++ b/app/Sensor/Disks.php @@ -18,7 +18,7 @@ use Illuminate\Support\Collection; */ class Disks implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("disks", "disks"); } @@ -38,7 +38,7 @@ class Disks implements Sensor } /** - * + * * @param string $string * @return Collection<Partition> */ diff --git a/app/Sensor/Ifconfig.php b/app/Sensor/Ifconfig.php index ae90db38dcd478e2dec384ad79a6961c820b0825..2fcefb4fd3dc690b7ac4e0f76757b96e9aaf269f 100644 --- a/app/Sensor/Ifconfig.php +++ b/app/Sensor/Ifconfig.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection; */ class Ifconfig implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("ifconfig", "ifconfig"); } diff --git a/app/Sensor/Inodes.php b/app/Sensor/Inodes.php index 2e619c24d9e8522604947bb02601112debdf6639..1d2c8e1e46d51e8fde406037645bfd659425bb95 100644 --- a/app/Sensor/Inodes.php +++ b/app/Sensor/Inodes.php @@ -10,6 +10,7 @@ use App\Status; use Illuminate\Database\Eloquent\Collection as DatabaseCollection; use Illuminate\Support\Collection; + /** * Description of Update * @@ -17,7 +18,7 @@ use Illuminate\Support\Collection; */ class Inodes implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("inodes", "inodes"); } diff --git a/app/Sensor/ListeningPorts.php b/app/Sensor/ListeningPorts.php index d9510810451f42067156fc0a0e91b37f380c0743..cc050a5e63f9a51c77f98f222ca843867578c4de 100644 --- a/app/Sensor/ListeningPorts.php +++ b/app/Sensor/ListeningPorts.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection; class ListeningPorts implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("listening-tcp", "netstat-listen-tcp"); } diff --git a/app/Sensor/LoadAvg.php b/app/Sensor/LoadAvg.php index 17601d4e3e5e8205f3fd481b6790ff6ee17eaff3..4d730ebb8644f703b80b98108dbb77a5b1766e90 100644 --- a/app/Sensor/LoadAvg.php +++ b/app/Sensor/LoadAvg.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection; */ class LoadAvg implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("loadavg", "loadavg"); } diff --git a/app/Sensor/MemInfo.php b/app/Sensor/MemInfo.php index cf6ff87ae3a18a6a0d7b2d1335e95527d6509efd..6070104aa5f752c8a11b49d337e6966c2aa2febe 100644 --- a/app/Sensor/MemInfo.php +++ b/app/Sensor/MemInfo.php @@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection; */ class MemInfo implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("memory", "memory"); } diff --git a/app/Sensor/Netstat.php b/app/Sensor/Netstat.php index d823200bb95e0dde1e5ed40120868252bfec83fd..4d78d7f130838464350b952ba0b50204a47558dc 100644 --- a/app/Sensor/Netstat.php +++ b/app/Sensor/Netstat.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection; class Netstat implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("netstat-retransmitted", "netstat-statistics"); } diff --git a/app/Sensor/Perccli.php b/app/Sensor/Perccli.php index 89227651910ce0fa84bd91d9e878a09c125043e4..1924223edd95cd91ba5b580f1d2c003bb513b1de 100644 --- a/app/Sensor/Perccli.php +++ b/app/Sensor/Perccli.php @@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection; */ class Perccli implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("perccli", "perccli"); } diff --git a/app/Sensor/Reboot.php b/app/Sensor/Reboot.php index 6cf1d2248c570f9c8c30b063dbe389736a456044..17793ccc7ae8b87f48490762940437dddbf1636a 100644 --- a/app/Sensor/Reboot.php +++ b/app/Sensor/Reboot.php @@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection; */ class Reboot implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("reboot", "reboot"); } diff --git a/app/Sensor/Ssacli.php b/app/Sensor/Ssacli.php index 42411ed3b0a1f40f6a217886d7e00b897c8b5dee..8516edc1d0cff91e2b8f27acaf16128ca30e067c 100644 --- a/app/Sensor/Ssacli.php +++ b/app/Sensor/Ssacli.php @@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection; */ class Ssacli implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("ssacli", "ssacli"); } @@ -28,7 +28,7 @@ class Ssacli implements Sensor { $report = (new Report())->setTitle("HP ssacli"); - $record = $records->last(); + $record = $records->last(); $disks = $this->parse($record->data); $report->setHTML(view("sensor.ssacli", ["disks" => $disks])); diff --git a/app/Sensor/USBtemperature.php b/app/Sensor/USBtemperature.php index 9ac23848d4595dd676458f0f2e94d0320d814b77..159671b287dcd09bf22b87fa92cddfa09a24043c 100644 --- a/app/Sensor/USBtemperature.php +++ b/app/Sensor/USBtemperature.php @@ -17,7 +17,7 @@ use Illuminate\Database\Eloquent\Collection; */ class USBtemperature implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("usb-temperature", "TEMPer"); } diff --git a/app/Sensor/Updates.php b/app/Sensor/Updates.php index 4fe3766a61bf67c812b1c39b097016e835c89055..b9330e5241d12873783c03862ed823ee8970aa0f 100644 --- a/app/Sensor/Updates.php +++ b/app/Sensor/Updates.php @@ -18,7 +18,7 @@ use Illuminate\Database\Eloquent\Collection; class Updates implements Sensor { - public function config(): SensorConfig + public function config(): SensorConfig { return new SensorConfig("updates", "updates"); } diff --git a/app/Server.php b/app/Server.php index bcdb25f259dd9f156c9f757df5beddb44829463d..06a46600329f436310ae2e178092b1388b5d7de0 100644 --- a/app/Server.php +++ b/app/Server.php @@ -88,7 +88,7 @@ class Server extends Model public function lastRecord(string $label) : ?Record { return $this->records() - ->where ("label", $label) + ->where("label", $label) ->orderBy("time", "desc")->first(); } @@ -103,7 +103,6 @@ class Server extends Model ->where("time", ">", $start) ->orderBy("time") ->get(); - } public function hasData() : bool @@ -160,7 +159,7 @@ class Server extends Model return $reports->filter(); } - public function lastReport (string $label) : ?Report + public function lastReport(string $label) : ?Report { $start = time() - 24 * 3600; return $this->reports() diff --git a/app/ServerInfo.php b/app/ServerInfo.php index 78ecacd8c3bf111257254cbdc9be5ec66fc35fd5..266453466c38f10196874316df2dda466df2cfe8 100644 --- a/app/ServerInfo.php +++ b/app/ServerInfo.php @@ -24,7 +24,7 @@ class ServerInfo private $parser; /** - * + * * @var Server */ private $server; diff --git a/app/Status.php b/app/Status.php index a21b6790e6b8bc5bfe28b7af419be75760c0db73..1ce71a59c079801dcc2822f972e1724773b97f9b 100644 --- a/app/Status.php +++ b/app/Status.php @@ -2,8 +2,6 @@ namespace App; -use Illuminate\Support\Collection; - /** * Wrapper around a status code */ @@ -87,7 +85,7 @@ class Status return self::maxArray($items); } - return self::maxCollection($items); + return self::maxCollection($items); } private static function maxArray(array $items) : Status diff --git a/composer.lock b/composer.lock index 49723b706a7bb1b7d4bf461fd5aefbf857beabfe..ad39082f560078a981c2a0f964848c1fa84ba9b6 100644 --- a/composer.lock +++ b/composer.lock @@ -7900,16 +7900,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.9.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", "shasum": "" }, "require": { @@ -7919,11 +7919,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -7938,22 +7938,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-02-16T15:06:51+00:00" }, { "name": "symfony/filesystem", @@ -8191,5 +8214,5 @@ "php": ">=7.4" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" }