Error discovering sensors module

I recently upgraded to PHP8.1 and I’m getting an error when running discovery against a Raspberry Pi running OSMC.

State: Error discovering sensors module for TypeError: current(): Argument #1 ($array) must be of type array, null given in /opt/librenms/includes/discovery/sensors/state/
Stack trace:
#0 /opt/librenms/includes/discovery/sensors/state/ current()
#1 /opt/librenms/includes/discovery/ include('...')
#2 /opt/librenms/includes/discovery/ sensors()
#3 /opt/librenms/includes/discovery/ include('...')
#4 /opt/librenms/discovery.php(118): discover_device()
#5 {main}  
current(): Argument #1 ($array) must be of type array, null given {"exception":"[object] (TypeError(code: 0): current(): Argument #1 ($array) must be of type array, null given at /opt/librenms/includes/discovery/sensors/state/"} 

Output of vaildate:

Component | Version
--------- | -------
LibreNMS  | 22.9.0-6-g5b432ddc0
DB Schema | 2022_09_03_091314_update_ports_adsl_table_with_defaults (246)
PHP       | 8.1.10
Python    | 3.9.2
Database  | MariaDB 10.5.15-MariaDB-0+deb11u1
RRDTool   | 1.7.2
SNMP      | 5.9

[OK]    Composer Version: 2.4.2
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database Schema is current
[OK]    SQL Server meets minimum requirements
[OK]    lower_case_table_names is enabled
[OK]    MySQL engine is optimal
[OK]    Database schema correct
[OK]    MySQl and PHP time match
[OK]    Active pollers found
[OK]    Dispatcher Service not detected
[OK]    Locks are functional
[OK]    Python poller wrapper is polling
[OK]    Redis is unavailable
[OK]    rrdtool version ok
[OK]    Connected to rrdcached

Let me know if you need anymore output.


Created Error discovering sensors module · Issue #14395 · librenms/librenms · GitHub

Thanks for reporting, someone else using ups-nut already reported this and it was fixed. Fix ups nut PHP 8.1 issue by murrant · Pull Request #14392 · librenms/librenms · GitHub

I believe this is a different issue but inside the same files.

The one you link to shows:

#0 /opt/librenms/includes/discovery/sensors/state/ current()

My error lists:

#0 /opt/librenms/includes/discovery/sensors/state/ current()

I ran and updated to latest and the error remains. I also tried applying PR 14392 manually and it throws an error which I’m thinking is because it’s already merged to master:

Checking patch includes/discovery/sensors/state/
error: while searching for:
    foreach ($sensors as $index => $sensor) {
        $sensor_oid = 9 + $index;
        $oid = '.' . strval($sensor_oid);
        $value = current($pre_cache['ups_nut_sensors']['ups-nut.' . $sensor_oid]);

        if (! empty($value) or $value == '0') {
            $state_name = $sensor['state_name'];
            $descr = $sensor['descr'];
            $states = [

error: patch failed: includes/discovery/sensors/state/
error: includes/discovery/sensors/state/ patch does not apply

Is there anything else I can provide in order to get this fixed?

Seems like someone copied the error… sorry, didn’t look close enough.

No worries. I tested out PR 14400 and the error is no longer present in the eventlog or when running discovery. Thanks!

1 Like

Merged now, thanks for testing.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.