Component Version
LibreNMS 1.33-358-gbdf02f1
DB Schema 230
PHP 7.0.22-0ubuntu0.16.04.1
MySQL 10.0.31-MariaDB-0ubuntu0.16.04.2
RRDTool 1.5.5
SNMP NET-SNMP 5.7.3
I was trying to create an alert rule with “OR” in it (config.php), hence the macro definition, similar to this:
$config['alert']['macros']['rule']['test1'] = '%macros.port_down = "1" && (
( %devices.sysName = "Switch1" && ( %ports.ifName = "2:18" || %ports.ifName = "2:23" ) )
)';
Yes, Extreme XOS switches have port names with colons in it
Running the “Capture->Poller” to debug/test, you can see that:
#### Load poller module ports ####
Caching Oids: SNMP[/usr/bin/snmpbulkwalk -v2c -c COMMUNITY -OQUs -m IF-MIB -M /opt/librenms/mibs udp:HOSTNAME:161 ifXEntry]
ifName.1001 = 1:1
ifName.1002 = 1:2
etc.
but I noticed that the SQL query cuts off everything starting at the colon:
SQL[SELECT * FROM ports,devices WHERE (( devices.device_id = ports.device_id ) && ports.device_id = '49') && ((((ports.ifOperStatus = "down" && ports.ifAdminStatus != "down" && ((ports.deleted = 0 && ports.ignore = 0 && ports.disabled = 0)))) = "1" && (
( devices.sysName = "Switch1" && ( ports.ifName = "2" || ports.ifName = "2" ) )
)) = 1 )]
The “Capture->Alert” still shows things correctly, though:
Alert rule: %macros.test1 = 1
Alert query: SELECT * FROM ports,devices WHERE (( devices.device_id = ports.device_id ) && ports.device_id = ?) && ((((ports.ifOperStatus = "down" && ports.ifAdminStatus != "down" && ((ports.deleted = 0 && ports.ignore = 0 && ports.disabled = 0)))) = "1" && (
( devices.sysName = "Switch1" && ( ports.ifName = "2:18" || ports.ifName = "2:23" ) )
)) = 1 )
Rule match: no match
I haven’t found out “why” yet - I dimly remember the colon being some separator in the interface description string between keywords like “Peer” or “Transit”, but that memory dates back to Observium times - and we’re talking about ifName, not ifDescr here.
As a workaround I’m currently using ifIndex (1001,1002,2023,2018, etc.) in the expression, but it would be awesome if ifName could be fixed. Or if someone could point me at where the function is that rewrites the SQL query, I could try my hand at a fix - I just haven’t found where that happens (cursory glances…)
Thanks,
Frank