ARP discovery broken on Juniper devices #4559

Closed
worton opened this Issue Sep 23, 2016 · 3 comments

Projects

None yet

2 participants

@worton
worton commented Sep 23, 2016

ARP discovery is broken on my Juniper MX and EX devices since this was merged:
4367

Apparently Juniper doesn't like the new mib being used?

# /usr/bin/snmpbulkwalk -v2c -c 'comm' -Oq -m IP-MIB -M /opt/librenms/mibs -t 2 udp:router:161 ipNetToPhysicalPhysAddress
IP-MIB::ipNetToPhysicalPhysAddress No Such Object available on this agent at this OID

# /usr/bin/snmpbulkwalk -v2c -c 'comm' -Oq -m IP-MIB -M /opt/librenms/mibs -t 2 udp:router:161 ipNetToMediaPhysAddress | head
IP-MIB::ipNetToMediaPhysAddress.18.10.0.0.4 2:0:0:0:0:4
IP-MIB::ipNetToMediaPhysAddress.18.128.0.0.1 2:0:0:0:0:4
... (looks ok) ...

Happens on Juniper MX80 verions:
--- JUNOS 12.3R6.6 built 2014-03-13 06:58:30 UTC
and Juniper EX4550 and EX4200 versions:
--- JUNOS 12.3R10.2 built 2015-06-25 15:28:10 UTC
--- JUNOS 12.3R9.4 built 2015-02-12 11:08:41 UTC

However Juniper MX version
--- JUNOS 13.3R6.5 built 2015-03-26 18:50:34 UTC
seems ok.

So is there a way to hit the older MIB table if the newer one fails? It's going to be awhile before I can get all my Juniper devices to JUNOS 13 or higher.

@laf
Member
laf commented Sep 25, 2016

Please post the output of:

./discovery.php -h HOSTNAME -d -m arp-table

Also, please ensure you don't delete the information we ask for in issues.

@worton
worton commented Sep 27, 2016
$ ./discovery.php -h switchname.domain.com -d -m arp-table
LibreNMS Discovery
Version info:
Commit SHA: dc26f097b06aa3836a540ce6743d8f33b3dc9ea0
DB Schema: 138
PHP: 5.3.3
MySQL: 5.1.73
RRDTool: 1.4.8
SNMP: NET-SNMP version: 5.5

DEBUG!
SQL[SELECT version FROM `dbSchema` ORDER BY version DESC LIMIT 1]
SQL[SELECT revision FROM `dbSchema`]
DB Schema already up to date.
SQL[SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 AND `hostname` LIKE 'switchname.domain.com' ORDER BY device_id DESC]
SQL[SELECT * FROM devices_attribs WHERE `device_id` = '277']
switchname.domain.com 277 junos
#### Load disco module arp-table ####
SNMP[/usr/bin/snmpbulkwalk -v2c -c COMMUNITY -Oq -m IP-MIB -M /opt/librenms/mibs -t 2 udp:HOSTNAME:161 ipNetToPhysicalPhysAddress]
IP-MIB::ipNetToPhysicalPhysAddress No Such Object available on this agent at this OID

SQL[SELECT * from ipv4_mac AS M, ports as I WHERE M.port_id = I.port_id and I.device_id = '277']


>> Runtime for discovery module 'arp-table': 0.083 seconds
#### Unload disco module arp-table ####

SQL[SELECT attrib_value FROM devices_attribs WHERE `device_id` = '277' AND `attrib_type` = 'poll_mib' ]
SQL[UPDATE `devices` set `last_discovered` =NOW(),`type` ='network',`last_discovered_timetaken` ='0.084' WHERE `device_id` = '277']
Discovered in 0.084 seconds

SQL[INSERT INTO `perf_times` (`type`,`doing`,`start`,`duration`,`devices`)  VALUES ('discover','switchname.domain.com','1474995825.9775','0.115','1')]
./discovery.php switchname.domain.com 2016-09-27 17:03:46 - 1 devices discovered in 0.115 secs
MySQL: Cell[1/0s] Row[4/0s] Rows[2/0s] Column[0/0s] Update[1/0.01s] Insert[1/0s] Delete[0/0s]
@laf laf added a commit that referenced this issue Oct 4, 2016
@f0o @laf f0o + laf fix: Fall back to ipNetToMediaPhysAddress when ipNetToPhysicalPhysAdd…
…ress not available #4559
638f610
@worton
worton commented Oct 7, 2016 edited

Thanks! The old MIB reports values without the ipv4/ipv6 field like this:
IP-MIB::ipNetToMediaPhysAddress.18.128.0.0.1 2:0:0:0:0:4

versus the new one which is:
IP-MIB::ipNetToPhysicalPhysAddress.18.ipv4."128.0.0.1" 2:0:0:0:0:4

So if I add this it works for me. Just not sure if this is the cleanest way to do it; seems like it'd be good to find a way to munge it outside the foreach loop.

--- a/includes/discovery/arp-table.inc.php
+++ b/includes/discovery/arp-table.inc.php
@@ -21,7 +21,12 @@ foreach ($vrfs_lite_cisco as $vrf) {
     $ipNetToPhysical_data = str_replace('"', '', trim($ipNetToPhysical_data));
     foreach (explode("\n", $ipNetToPhysical_data) as $data) {
         list($oid, $mac) = explode(' ', $data);
-        list($if, $ipv, $first, $second, $third, $fourth) = explode('.', $oid);
+        if ($arp_oid == 'ipNetToPhysicalPhysAddress') {
+            list($if, $ipv, $first, $second, $third, $fourth) = explode('.', $oid);
+        } else {
+            $ipv = 'ipv4';
+            list($if, $first, $second, $third, $fourth) = explode('.', $oid);
+        }
         $ip = $first.'.'.$second.'.'.$third.'.'.$fourth;
         if ($ip != '...' && $ipv === 'ipv4' && $mac != '0:0:0:0:0:0') {
             $interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $if));
@laf laf closed this in #5048 Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment