diff --git a/LibreNMS/Enum/ServiceStatus.php b/LibreNMS/Enum/ServiceStatus.php index b0ffc5dc34e4637c1efc09d5dcb4aaceb392d230..0898acd0a44cd4764b4cce262c91e26137d78ff1 100644 --- a/LibreNMS/Enum/ServiceStatus.php +++ b/LibreNMS/Enum/ServiceStatus.php @@ -1,4 +1,5 @@ 'int|min:0']), new ServiceOption('timeout', 't'), new ServiceOption('bytes', 'b'), - new ServiceOption('verbose', 'v', mode: InputOption::VALUE_NONE|InputOption::VALUE_IS_ARRAY), - new ServiceOption('Host', 'H', ['Host' => 'required|ip_or_hostname'], mode: InputOption::VALUE_IS_ARRAY) + new ServiceOption('verbose', 'v', mode: InputOption::VALUE_NONE | InputOption::VALUE_IS_ARRAY), + new ServiceOption('Host', 'H', ['Host' => 'required|ip_or_hostname'], mode: InputOption::VALUE_IS_ARRAY), ]; } @@ -91,7 +91,7 @@ class CheckIcmp extends Service ]), ]; - return array_filter($dataSets, fn($dataSet) => $ds === null || $ds === $dataSet->name); + return array_filter($dataSets, fn ($dataSet) => $ds === null || $ds === $dataSet->name); } public function graph(string $rrd_filename = ''): array @@ -100,11 +100,11 @@ class CheckIcmp extends Service 'rta' => [ 'unit' => 's', 'commands' => [ - 'DEF:DS0=' . $rrd_filename . ':rta:AVERAGE', - 'LINE1.25:DS0#' . LibrenmsConfig::get('graph_colours.mixed.0') . ':' . str_pad(substr('Round Trip Average', 0, 15), 15), - 'GPRINT:DS0:LAST:%5.2lf%s', - 'GPRINT:DS0:AVERAGE:%5.2lf%s', - 'GPRINT:DS0:MAX:%5.2lf%s\\l', + 'DEF:DS0=' . $rrd_filename . ':rta:AVERAGE', + 'LINE1.25:DS0#' . LibrenmsConfig::get('graph_colours.mixed.0') . ':' . str_pad(substr('Round Trip Average', 0, 15), 15), + 'GPRINT:DS0:LAST:%5.2lf%s', + 'GPRINT:DS0:AVERAGE:%5.2lf%s', + 'GPRINT:DS0:MAX:%5.2lf%s\\l', ], ], 'rtmax' => [ @@ -115,7 +115,7 @@ class CheckIcmp extends Service 'GPRINT:DS1:LAST:%5.2lf%s', 'GPRINT:DS1:AVERAGE:%5.2lf%s', 'GPRINT:DS1:MAX:%5.2lf%s\\l', - ] + ], ], 'rtmin' => [ 'unit' => 's', @@ -133,7 +133,7 @@ class CheckIcmp extends Service 'GPRINT:DS0:LAST:%5.2lf%s', 'GPRINT:DS0:AVERAGE:%5.2lf%s', 'GPRINT:DS0:MAX:%5.2lf%s\\l', - ] + ], ]; } } diff --git a/LibreNMS/Services/Checks/CheckLoad.php b/LibreNMS/Services/Checks/CheckLoad.php index 0dcd695e9b549c87197cb13bae361109f061fb77..dad7467e11a04facacf44c18481aebcbab61253d 100644 --- a/LibreNMS/Services/Checks/CheckLoad.php +++ b/LibreNMS/Services/Checks/CheckLoad.php @@ -1,4 +1,5 @@ 'int']), - new ServiceOption('procs-to-show', ) + new ServiceOption('procs-to-show'), ]; } @@ -46,21 +47,21 @@ class CheckLoad extends Service { return [ new ServiceDataSet('load', 'processes', [ - 'DEF:DS0=' . $rrd_filename . ':load1:AVERAGE', - 'LINE1.25:DS0#' . LibrenmsConfig::get('graph_colours.mixed.0') . ':' . str_pad(substr('Load 1', 0, 15), 15), - 'GPRINT:DS0:LAST:%5.2lf%s', - 'GPRINT:DS0:AVERAGE:%5.2lf%s', - 'GPRINT:DS0:MAX:%5.2lf%s\\l', - 'DEF:DS1=' . $rrd_filename . ':load5:AVERAGE', - 'LINE1.25:DS1#' . LibrenmsConfig::get('graph_colours.mixed.1') . ':' . str_pad(substr('Load 5', 0, 15), 15), - 'GPRINT:DS1:LAST:%5.2lf%s', - 'GPRINT:DS1:AVERAGE:%5.2lf%s', - 'GPRINT:DS1:MAX:%5.2lf%s\\l', - 'DEF:DS2=' . $rrd_filename . ':load15:AVERAGE', - 'LINE1.25:DS2#' . LibrenmsConfig::get('graph_colours.mixed.2') . ':' . str_pad(substr('Load 15', 0, 15), 15), - 'GPRINT:DS2:LAST:%5.2lf%s', - 'GPRINT:DS2:AVERAGE:%5.2lf%s', - 'GPRINT:DS2:MAX:%5.2lf%s\\l', + 'DEF:DS0=' . $rrd_filename . ':load1:AVERAGE', + 'LINE1.25:DS0#' . LibrenmsConfig::get('graph_colours.mixed.0') . ':' . str_pad(substr('Load 1', 0, 15), 15), + 'GPRINT:DS0:LAST:%5.2lf%s', + 'GPRINT:DS0:AVERAGE:%5.2lf%s', + 'GPRINT:DS0:MAX:%5.2lf%s\\l', + 'DEF:DS1=' . $rrd_filename . ':load5:AVERAGE', + 'LINE1.25:DS1#' . LibrenmsConfig::get('graph_colours.mixed.1') . ':' . str_pad(substr('Load 5', 0, 15), 15), + 'GPRINT:DS1:LAST:%5.2lf%s', + 'GPRINT:DS1:AVERAGE:%5.2lf%s', + 'GPRINT:DS1:MAX:%5.2lf%s\\l', + 'DEF:DS2=' . $rrd_filename . ':load15:AVERAGE', + 'LINE1.25:DS2#' . LibrenmsConfig::get('graph_colours.mixed.2') . ':' . str_pad(substr('Load 15', 0, 15), 15), + 'GPRINT:DS2:LAST:%5.2lf%s', + 'GPRINT:DS2:AVERAGE:%5.2lf%s', + 'GPRINT:DS2:MAX:%5.2lf%s\\l', ]), ]; } diff --git a/LibreNMS/Services/LegacyService.php b/LibreNMS/Services/LegacyService.php index 8cd4e9f78919abb9a1dd48a075ef4c9ab89234d0..59230325a332b84974f66bd448b794da1cdd2060 100644 --- a/LibreNMS/Services/LegacyService.php +++ b/LibreNMS/Services/LegacyService.php @@ -1,4 +1,5 @@ $unit) { $commands = $graphs[$name] ?? $this->defaultGraphCommands($rrd_filename, $name); - $dataSets[] = new ServiceDataSet($name, $unit,is_array($commands) ? $commands : [$commands]); + $dataSets[] = new ServiceDataSet($name, $unit, is_array($commands) ? $commands : [$commands]); } return $dataSets; diff --git a/LibreNMS/Services/Service.php b/LibreNMS/Services/Service.php index 1d66d9df8e3e782163351572b5a52c57beb21ed1..4d589f9d0846d824a57d251db21f3bbdad60cb4a 100644 --- a/LibreNMS/Services/Service.php +++ b/LibreNMS/Services/Service.php @@ -1,4 +1,5 @@ short) { - return [$this->short, (string) $value]; + if ($value) { + if ($this->short) { + return [$this->short, (string) $value]; + } } if ($this->long) { diff --git a/app/Models/Service.php b/app/Models/Service.php index fb0d7e0eda555127cc11e54c4a032f81854e2603..7fbc6fc614ba151e59db4fd3364fcfa1f54d7dcd 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -37,13 +37,12 @@ class Service extends DeviceRelatedModel if (is_array($params)) { return $params; - }; + } $params = []; $values = explode(' ', $value); foreach ($values as $index => $value) { if (str_starts_with($value, '-')) { - } } diff --git a/database/migrations/2025_12_14_144851_add_timestamps_to_services_table.php b/database/migrations/2025_12_14_144851_add_timestamps_to_services_table.php index 8fb01e5f76e82c15d227c8ebaf5394176177f5aa..cfa4a7821c252034616690e25b99fca44b973931 100644 --- a/database/migrations/2025_12_14_144851_add_timestamps_to_services_table.php +++ b/database/migrations/2025_12_14_144851_add_timestamps_to_services_table.php @@ -16,7 +16,7 @@ return new class extends Migration { if (! Schema::hasColumn($this->table, 'updated_at')) { Schema::table($this->table, function (Blueprint $table) { - $table->timestamps(); + $table->timestamps(); }); } diff --git a/includes/services.inc.php b/includes/services.inc.php index 68f12caf05ef79bb4c523caf876cbd0432114344..707f2df85289f1a21317678255e9f7f93b9fd089 100644 --- a/includes/services.inc.php +++ b/includes/services.inc.php @@ -24,7 +24,7 @@ function add_service($device, $type, $desc, $ip = '', $param = '', $ignore = 0, 'service_ds' => '{}', 'service_disabled' => $disabled, 'service_template_id' => $template_id, - 'service_name' => $name + 'service_name' => $name, ]); } diff --git a/lang/en/services.php b/lang/en/services.php index 9335d7c9774dad6eb6d19fd1949337a7b13d629b..10e47b5c3f8dc04a3ed92c6a461302a7c19ca3ad 100644 --- a/lang/en/services.php +++ b/lang/en/services.php @@ -4,17 +4,17 @@ return [ 'load' => [ 'options' => [ 'warning' => [ - 'help' => 'Exit with WARNING status if load average exceeds WLOADn' + 'help' => 'Exit with WARNING status if load average exceeds WLOADn', ], 'critical' => [ - 'help' => 'Exit with CRITICAL status if load average exceeds CLOADn' + 'help' => 'Exit with CRITICAL status if load average exceeds CLOADn', ], 'percpu' => [ - 'help' => 'Divide the load averages by the number of CPUs (when possible)' + 'help' => 'Divide the load averages by the number of CPUs (when possible)', ], 'procs-to-show' => [ - 'help' => "Number of processes to show when printing the top consuming processes.\nNUMBER_OF_PROCS=0 disables this feature. Default value is 0" - ] + 'help' => "Number of processes to show when printing the top consuming processes.\nNUMBER_OF_PROCS=0 disables this feature. Default value is 0", + ], ], ], ];