Librenms traphandler error

Hi,

I have been investigating receiving traps in librenms, so far traps from my ups seem to be working correctly. However, I have added a Juniper router and now I am seeing a few errors in the librenms log

it really looks like the IP.php is not able to parse the Hex-STRING correctly… it’s grabbing more from oid than it’s supposed to…

Unknown bgp peer handling bgpBackwardTransition trap
and
production.ERROR: Could not parse into IP: 920010504003900000000000000000084 {“exception”:" object] (LibreNMS\Exceptions\InvalidIpException(code: 0): Could not parse into IP: 920010504003900000000000000000084 at /opt/librenms/LibreNMS/Util/IP.php:70)
[stacktrace]

#0 /opt/librenms/LibreNMS/Snmptrap/Handlers/JnxBgpM2BackwardTransition.php(51): LibreNMS\Util\IP::fromHexString(‘920010504003900…’)

#1 /opt/librenms/LibreNMS/Snmptrap/Dispatcher.php(49): LibreNMS\Snmptrap\Handlers\JnxBgpM2BackwardTransition->handle(Object(App\Models\Device), Object(LibreNMS\Snmptrap\Trap))

#2 /opt/librenms/snmptrap.php(28): LibreNMS\Snmptrap\Dispatcher::handle(Object(LibreNMS\Snmptrap\Trap))

#3 {main}
"}

in my snmptrapd log I see the following as well:

DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1043803230) 120 days, 19:27:12.30 SNMPv2-MIB::snmpTrapOID.0 = OID: BGP4-V2-MIB-JUNIPER::jnxBgpM2BackwardTransition BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLocalAddrType.0.ipv6."…9… …9…" = INTEGER: ipv6(2) BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLocalAddr.0.ipv6."…9… …9…" = Hex-STRING: 20 01 05 04 00 39 00 00 00 00 00 00 00 00 00 10 BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddrType.0.ipv6."…9… …9…" = INTEGER: ipv6(2) BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerRemoteAddr.0.ipv6."…9… …9…" = Hex-STRING: 20 01 05 04 00 39 00 00 00 00 00 00 00 00 00 84 BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLastErrorReceived.0.ipv6."…9… …9…" = Hex-STRING: 00 00 BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerLastErrorReceivedText.0.ipv6."…9… …9…" = STRING: BGP4-V2-MIB-JUNIPER::jnxBgpM2PeerState.0.ipv6."…9… …9…" = INTEGER: connect(2) SNMPv2-MIB::snmpTrapEnterprise.0 = OID: JUNIPER-CHASSIS-DEFINES-MIB::jnxProductNameMX480
Jan 15 14:51:32 netmon.tor snmptrapd[12589]: In IP.php line 70:
Jan 15 14:51:32 netmon.tor snmptrapd[12589]: Could not parse into IP: 920010504003900000000000000000084

any help would be appreciated.

thanks.

What options are you running with snmptrapd? I think I fixed this by adding -Ob to the startup for snmptrapd.

right now I am using the default “-Lsd”

You might try adding -Ob, it changes the formatting when parsing the mib. It switches the indexes only display numerically, which I believe fixes the problem. I’m going off memory, so I could be wrong.

Looks like -Ob fixed the IP.php issue

the librenms.log does keep showing an occasional message though:

production.ERROR: Unknown bgp peer handling bgpBackwardTransition trap:

Not sure what that’s about, I’m not seeing that in my environment.

I’ll investigate further, I marked the -Ob as the solution since that resolved the trap not getting processed correctly.

thanks again!

1 Like

I found the issue after reading the trap handler source code:

seems like I had a conflicting MIB loaded and it wasn’t matching this line in the trap handler:
$state_oid = $trap->findOid(‘BGP4-MIB::bgpPeerState’);

I removed the offending MIB file and now the trap is being translated with the correct MIB