Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LibreNMS/Enum/Sensor.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
return match ($this) {
self::AIRFLOW => \LibreNMS\Interfaces\Discovery\Sensors\SensorAirflowDiscovery::class,
self::BER => \LibreNMS\Interfaces\Discovery\Sensors\SensorBerDiscovery::class,
self::BITRATE => \LibreNMS\Interfaces\Discovery\Sensors\SensorBitRateDiscovery::class,

Check failure on line 125 in LibreNMS/Enum/Sensor.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Interface LibreNMS\Interfaces\Discovery\Sensors\SensorBitrateDiscovery referenced with incorrect case: LibreNMS\Interfaces\Discovery\Sensors\SensorBitRateDiscovery.
self::CHARGE => \LibreNMS\Interfaces\Discovery\Sensors\SensorChargeDiscovery::class,
self::CHROMATIC_DISPERSION => \LibreNMS\Interfaces\Discovery\Sensors\SensorChromaticDispersionDiscovery::class,
self::COOLING => \LibreNMS\Interfaces\Discovery\Sensors\SensorCoolingDiscovery::class,
Expand Down Expand Up @@ -159,7 +159,7 @@
*/
public function getPollingInterface(): string
{
return match($this) {
return match ($this) {
self::AIRFLOW => \LibreNMS\Interfaces\Polling\Sensors\SensorAirflowPolling::class,
self::BER => \LibreNMS\Interfaces\Polling\Sensors\SensorBerPolling::class,
self::BITRATE => \LibreNMS\Interfaces\Polling\Sensors\SensorBitratePolling::class,
Expand Down
7 changes: 4 additions & 3 deletions LibreNMS/Modules/Sensors.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Sensors.php
*
Expand Down Expand Up @@ -104,7 +105,6 @@
);
}


discovery_process($os, $sensor_class, $pre_cache);
app('sensor-discovery')->sync(sensor_class: $sensor_class, poller_type: 'snmp');
// $this->syncModelsByGroup($os->getDevice(), 'sensors', $sensors, ['sensor_class' => $type]);
Expand All @@ -126,6 +126,7 @@
// fetch data for all non-custom polled sensors
$oids = $all_sensors->filter(function ($sensor, $sensor_class) use ($os) {
$polling_interface = Sensor::from($sensor_class)->getPollingInterface();

return ! $os instanceof $polling_interface;
})->flatten()->pluck('sensor_oid')->unique()->all();

Expand Down Expand Up @@ -253,7 +254,7 @@
'state_translation_id',
'state_index_id',
'sensors_to_state_translations_id',
'lastupdate'
'lastupdate',
]),
'state_indexes' => StateIndex::join('state_translations', 'state_indexes.state_index_id', '=', 'state_translations.state_index_id')
->joinSub(
Expand All @@ -275,27 +276,27 @@
'state_translations.state_draw_graph',
'state_translations.state_value',
'state_translations.state_generic_value',
])
])
->get(),
];
}

private function discoverLegacySensor(array $device, string $dir): void
{
if (isset($device->os_group) && is_file($dir . $device->os_group . '.inc.php')) {

Check failure on line 286 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Cannot access property $os_group on array.
include $dir . $device->os_group . '.inc.php';
}
if (is_file($dir . $device->os . '.inc.php')) {

Check failure on line 289 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Cannot access property $os on array.
include $dir . $device->os . '.inc.php';

Check failure on line 290 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Cannot access property $os on array.
}
if (LibrenmsConfig::getOsSetting($device->os, 'rfc1628_compat', false)) {

Check failure on line 292 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Cannot access property $os on array.
if (is_file($dir . '/rfc1628.inc.php')) {
include $dir . '/rfc1628.inc.php';
}
}
}

private function pollLegacySensor(array $device, string $sensor_class, string $sensor_value): int|float|string|null

Check failure on line 299 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method LibreNMS\Modules\Sensors::pollLegacySensor() never returns null so it can be removed from the return type.

Check failure on line 299 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method LibreNMS\Modules\Sensors::pollLegacySensor() never returns int so it can be removed from the return type.

Check failure on line 299 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method LibreNMS\Modules\Sensors::pollLegacySensor() never returns float so it can be removed from the return type.
{
if (file_exists(LibrenmsConfig::get('install_dir') . '/includes/polling/sensors/' . $sensor_class . '/' . $device['os'] . '.inc.php')) {
require LibrenmsConfig::get('install_dir') . '/includes/polling/sensors/' . $sensor_class . '/' . $device['os'] . '.inc.php';
Expand Down Expand Up @@ -385,7 +386,7 @@
if (! is_numeric($snmp_value)) {
if ($sensor_class === 'temperature') {
// For temp sensors, try and detect fahrenheit values
if (is_string($snmp_value) && Str::endsWith($snmp_value, ['f', 'F'])) {

Check failure on line 389 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Call to static method endsWith() on an unknown class LibreNMS\Modules\Str.
$user_function = 'fahrenheit_to_celsius';
}
}
Expand Down Expand Up @@ -422,7 +423,7 @@
Log::debug("Sensor fetched value: $value\n");

// process the oid (num_oid will contain index or str2num replacement calls)
$oid = trim(YamlDiscovery::replaceValues('num_oid', $index, null, $data, []));

Check failure on line 426 in LibreNMS/Modules/Sensors.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Parameter #3 $count of static method LibreNMS\Device\YamlDiscovery::replaceValues() expects int, null given.

// process the description
$descr = trim(YamlDiscovery::replaceValues('descr', $index, null, $data, $pre_cache));
Expand Down
70 changes: 35 additions & 35 deletions LibreNMS/OS/Shared/Radlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,40 @@ public function discoverProcessors(): array
}

/**
Temperature OID

.1.3.6.1.4.1.89.53.15.1.9
.1.3.6.1.4.1.89.53.15.1.10

CPU OIDs

.1.3.6.1.4.1.89.1.6
.1.3.6.1.4.1.89.1.7
.1.3.6.1.4.1.89.1.8
.1.3.6.1.4.1.89.1.9

Memory OIDs

.1.3.6.1.4.1.89.29.11.1
.1.3.6.1.4.1.89.29.11.2

P.S. OIDs

.1.3.6.1.4.1.89.35.5.1.1.2
.1.3.6.1.4.1.89.83.1.2.1.2
.1.3.6.1.4.1.89.83.1.2.1.3
.1.3.6.1.4.1.89.83.1.2.1.4
.1.3.6.1.4.1.89.53.15.1.3
.1.3.6.1.4.1.89.53.15.1.3

Fan OIDs

.1.3.6.1.4.1.89.83.1.1.1.2
.1.3.6.1.4.1.89.83.1.1.1.3
.1.3.6.1.4.1.89.53.15.1.4
.1.3.6.1.4.1.89.53.15.1.5
.1.3.6.1.4.1.89.53.15.1.6
.1.3.6.1.4.1.89.53.15.1.7
.1.3.6.1.4.1.89.53.15.1.8
* Temperature OID
*
* .1.3.6.1.4.1.89.53.15.1.9
* .1.3.6.1.4.1.89.53.15.1.10
*
* CPU OIDs
*
* .1.3.6.1.4.1.89.1.6
* .1.3.6.1.4.1.89.1.7
* .1.3.6.1.4.1.89.1.8
* .1.3.6.1.4.1.89.1.9
*
* Memory OIDs
*
* .1.3.6.1.4.1.89.29.11.1
* .1.3.6.1.4.1.89.29.11.2
*
* P.S. OIDs
*
* .1.3.6.1.4.1.89.35.5.1.1.2
* .1.3.6.1.4.1.89.83.1.2.1.2
* .1.3.6.1.4.1.89.83.1.2.1.3
* .1.3.6.1.4.1.89.83.1.2.1.4
* .1.3.6.1.4.1.89.53.15.1.3
* .1.3.6.1.4.1.89.53.15.1.3
*
* Fan OIDs
*
* .1.3.6.1.4.1.89.83.1.1.1.2
* .1.3.6.1.4.1.89.83.1.1.1.3
* .1.3.6.1.4.1.89.53.15.1.4
* .1.3.6.1.4.1.89.53.15.1.5
* .1.3.6.1.4.1.89.53.15.1.6
* .1.3.6.1.4.1.89.53.15.1.7
* .1.3.6.1.4.1.89.53.15.1.8
*/
}