librenms / librenms-agent

LibreNMS Agent & Scripts
GNU General Public License v2.0
119 stars 189 forks source link

Application "redis" doesn't like IPv6 #553

Open frank42hh opened 1 week ago

frank42hh commented 1 week ago

The problem

Hi, this problem is independent from a specific LibreNMS version.

The redis parser script "redis.py", which can be found at https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/redis.py and is linked to https://docs.librenms.org/Extensions/Applications/#snmp-extend_56

has a little but serious bug in it.

When redis is configured to include IPv6 socket:

# grep ^bind redis.conf
bind 127.0.0.1 ::1

the parser fails with an exception. Since the exception doesn't output the original error, it just prints out a "data extracting error". After adding a function to additionally print the error itself, I got exception error: too many values to unpack (expected 2)

After checking the output of redis-cli info and comparing it to the parser code, I detected that the above "bind" line is causing the problem, because the parser expects exactly "key:value" pairs with exactly one colon in it, but the above "bind" line is output in the server section of the redis-cli output and contains 3 colons due to the ::1 listing in it. Removing IPv6 socket makes the script work again.

I'm no python coder, so I can't provide a fix for that, only a hint to what is needed. I would suggest to either change the parser to only split on the first occurrence of a colon, or skip the "bind" line altogether.

Output of ./validate.php

librenms@heimdall:~$ ./validate.php
===========================================
Component | Version
--------- | -------
LibreNMS  | 24.9.1-121-gb153b8296 (2024-11-04T16:42:51+01:00)
DB Schema | 2023_12_21_085427_create_view_port_mac_link (304)
PHP       | 8.1.26
Python    | 3.9.2
Database  | MariaDB 10.5.21-MariaDB-0+deb11u1
RRDTool   | 1.7.2
SNMP      | 5.9
===========================================

[OK]    Composer Version: 2.8.2
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[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 and column collations are correct
[OK]    Database schema correct
[OK]    MySQL and PHP time match
[WARN]  PHP version 8.2 is the minimum supported version as of October, 2024. We recommend you update PHP to a supported version (8.3 suggested) to continue to receive updates. If you do not update PHP, LibreNMS will continue to function but stop receiving bug fixes and updates.
[OK]    Active pollers found
[OK]    Dispatcher Service is enabled
[OK]    Locks are functional
[OK]    No active python wrapper pollers found
[OK]    Redis is functional
[OK]    rrdtool version ok
[OK]    Connected to rrdcached

What was the last working version of LibreNMS?

No response

Anything in the logs that might be useful for us?

No response