Unable to see neighbors via NAPALM.

435 views
Skip to first unread message

João Lucas B. Macedo

unread,
Sep 8, 2020, 12:39:32 AM9/8/20
to NetBox
Hi guys. I have some Huawei boxes and use NAPALM to access them via Netbox, but some information does not show up on the web UI. If I go on my CentOS server's CLI and use NetBox python venv I can get the device's neighbors list via NAPALM, but it doesn't show up on the web interface. At the same way, there is no information on the Environment frame in the STATUS tab.


--
João Lucas Macedo
Telecom Engineer.

Brian Candler

unread,
Sep 8, 2020, 2:00:53 AM9/8/20
to NetBox
IIRC:

You need to create a "Platform" such as "Huawei OS" (sorry I don't know what Huawei call their router OS)

In the "Platform" definition you need to set the NAPALM driver name

Then in each applicable "Device" you need to select the correct "Platform"

João Lucas B. Macedo

unread,
Sep 8, 2020, 5:27:10 AM9/8/20
to Brian Candler, NetBox
That's not the case. I already have NAPALM fully functional and the platform definition as well. 
But looks like NetBox is failing to handle the get_lldp_neighbors() method information and showing it on the tab. But, however, if I go to mynetbox.com/api/device/(...) it actually pulls the lldp neighborhood via napalm, then I realized that the problem may be the handling of the information pulled. 

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/87306da4-b951-455c-beac-7cfaf66cb033o%40googlegroups.com.

Michael Mastro

unread,
Oct 29, 2020, 3:34:53 PM10/29/20
to NetBox
Has this been resolved?  I'm having the same exact issue except its for all of my device types: eos, iOS, Junos, iox-xr

João Lucas B. Macedo

unread,
Oct 29, 2020, 4:25:46 PM10/29/20
to Michael Mastro, NetBox
Same thing.
The web interface tab shows nothing, but if I use the URL http://netbox/api/dcim/devices/XXX/napalm/?method=get_lldp_neighbors it shows the neighbors properly.

Brian Candler

unread,
Oct 31, 2020, 10:43:17 AM10/31/20
to NetBox
It won't show anything unless the interfaces names returned by get_lldp_neighbors *exactly* match how you've named the interfaces in Netbox.

For example, here's what I get from a Mikrotik RB4011iGS+RM:

{"get_lldp_neighbors":{"bridge1/ether5":[{"hostname":"gw1.home.example.net","port":"bridge1/ether3"}]}}


However, since the local interface is called "ether5" in Netbox, and not "bridge1/ether5", nothing is shown in the GUI.

If I rename the local interface "ether5" to "bridge1/ether5", then the neighbor is displayed in the UI:



It's red, because the cable model says that the remote interface is called "ether3", whereas LLDP says the remote interface is called "bridge1/ether3".  If I then go to the remote device and rename "ether3" to "bridge1/ether3" then refresh the original LLDP screen, it becomes green.

I do think it would be helpful if the Netbox LLDP table listed local interfaces which have been discovered, but don't match any known interfaces on the device.

Regards,

Brian.

Brian Candler

unread,
Oct 31, 2020, 11:18:34 AM10/31/20
to NetBox
(Aside: the Javascript in Netbox calls get_lldp_neighbors_detail, not get_lldp_neighbors)

Here is a proof-of-concept hack which will show you LLDP neighbors which don't correspond to any known interface.  It simply adds them to the end of the table, in a random order, and they are shown in blue (class "info" - the code to do that was already there).

--- a/netbox/templates/dcim/device_lldp_neighbors.html
+++ b/netbox/templates/dcim/device_lldp_neighbors.html
@@ -18,7 +18,7 @@
                     <th>LLDP Interface</th>
                 </tr>
             </thead>
-            <tbody>
+            <tbody id="_interfaces">
                 {% for iface in interfaces %}
                     <tr id="{{ iface.name }}">
                         <td>{{ iface }}</td>
@@ -57,7 +57,13 @@ $(document).ready(function() {
         success: function(json) {
             $.each(json['get_lldp_neighbors_detail'], function(iface, neighbors) {
                 var neighbor = neighbors[0];
-                var row = $('#' + iface.split(".")[0].replace(/([\/:])/g, "\\$1"));
+                var iface_clean = iface.split(".")[0].replace(/([\/:])/g, "\\$1");
+                var row = $('#' + iface_clean);
+
+                if (row.length == 0) {
+                        row = $('<tr id="' + iface_clean + '"><td>' + iface + '</td><td colspan="2">-</td><td class="device"></td><td class="interface"></td></tr>');
+                        row.appendTo('tbody#_interfaces');
+                }

                 // Glean configured hostnames/interfaces from the DOM
                 var configured_device = row.children('td.configured_device').attr('data');

If someone wants to improve this and submit it as a PR, please feel free.  It probably ought to sort the interfaces first.

Regards,

Brian.

João Lucas B. Macedo

unread,
Oct 31, 2020, 11:54:06 AM10/31/20
to Brian Candler, NetBox
I've noticed this issue about matching interface names, but even on my Huawei switches, and matching interface names it doesn't show the neighborhood. 

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.

João Lucas B. Macedo

unread,
Oct 31, 2020, 12:09:12 PM10/31/20
to Brian Candler, NetBox
Maybe it would be nice to compare with the interface list brought by get_facts method.

Brian Candler

unread,
Oct 31, 2020, 12:11:56 PM10/31/20
to NetBox
Can you try the patch and see if it makes a difference?  It may be a case of exactly what constitutes a match.

João Lucas B. Macedo

unread,
Oct 31, 2020, 12:15:16 PM10/31/20
to Brian Candler, NetBox
Sorry, what you mean by patch? 
Can you be more specific?

On Sat, Oct 31, 2020, 13:11 Brian Candler <b.ca...@pobox.com> wrote:
Can you try the patch and see if it makes a difference?  It may be a case of exactly what constitutes a match.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.

Brian Candler

unread,
Oct 31, 2020, 12:16:33 PM10/31/20
to NetBox
On Saturday, 31 October 2020 16:09:12 UTC, João Lucas B. Macedo wrote:
Maybe it would be nice to compare with the interface list brought by get_facts method.

Maybe, but that probably ought to be a separate tab (distinct from LLDP) because the information doesn't necessarily agree with lldp.

Here's what my Mikrotik gives for method=get_facts:

{"get_facts":{"uptime":96238,"vendor":"MikroTik","model":"RB4011iGS+","hostname":"gw2.home.example.net","fqdn":"","os_version":"6.47.7 (stable)","serial_number":"XXXXXXXXXXXX","interface_list":["bridge1","ether1","ether2","ether3","ether4","ether5","ether6","ether7","ether8","ether9","ether10","pppoe-out2","sfp-sfpplus1","vlan250","vlan253","vlan254","vlan255","vlan256","vrrp253v4","vrrp254v4","vrrp255v4","vrrp256v4"]}}

The interface name there is "ether5", whereas the lldp result calls it "bridge1/ether5"

Brian Candler

unread,
Oct 31, 2020, 12:17:38 PM10/31/20
to NetBox
The patch I just posted to this thread an hour ago.

João Lucas B. Macedo

unread,
Oct 31, 2020, 12:47:26 PM10/31/20
to Brian Candler, NetBox
I'm sorry Brian, I'm not very familiar. How can I proceed with the patch? Should I change a file in the NetBox directory?

Anyway, I didn't know NetBox uses "get_lldp_neighbors_detail". That is exactly the case with Huawei devices. The NAPALM driver for Huawei does not implement this method.
My Mikrotik devices on NetBox behave just as you said if the interface names match.
Problem solved for now...
Don't you think it would be more productive if NetBox did not try to match configured interface names with the data shown by NAPALM, at least in a first glance? Then the user would check both information and compare, but NetBox would always show the interfaces and its neighbors as NAPALM brings it.


Em sáb., 31 de out. de 2020 às 13:17, Brian Candler <b.ca...@pobox.com> escreveu:
The patch I just posted to this thread an hour ago.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.

Brian Candler

unread,
Oct 31, 2020, 4:05:29 PM10/31/20
to NetBox
On Saturday, 31 October 2020 16:47:26 UTC, João Lucas B. Macedo wrote:
I'm sorry Brian, I'm not very familiar. How can I proceed with the patch? Should I change a file in the NetBox directory?

Yes, /opt/netbox/netbox/templates/dcim/device_lldp_neighbors.html

Replace it with this one:

Anyway, I didn't know NetBox uses "get_lldp_neighbors_detail". That is exactly the case with Huawei devices. The NAPALM driver for Huawei does not implement this method.

Sounds like a bug in the Huawei driver.

However, as far as I can see, Netbox only uses the "remote_system_name" and "remote_port" attributes.  Comparing the responses for those two calls:

{
    "get_lldp_neighbors_detail": {
        "bridge1/ether5": [
            {
                "parent_interface": "ether5",
                "remote_chassis_id": "XX:XX:XX:XX:XX:XX",
                "remote_system_name": "gw1.home.example.net",
                "remote_port": "bridge1/ether3",
                "remote_port_description": "",
                "remote_system_description": "MikroTik RouterOS 6.47.7 (stable) RB960PGS",
                "remote_system_capab": [
                    "bridge",
                    "router"
                ],
                "remote_system_enable_capab": [
                    "bridge",
                    "router"
                ]
            }
        ]
    }
}

vs.

{
    "get_lldp_neighbors": {
        "bridge1/ether5": [
            {
                "hostname": "gw1.home.example.net",
                "port": "bridge1/ether3"
            }
        ]
    }
}
 
I think if I change the Javascript to call get_lldp_neighbors instead of get_lldp_neighbors_detail, and change

                var neighbor_host = neighbor['remote_system_name'] || ""; // sanitize hostname if it's null to avoid breaking the split func
                var neighbor_port = neighbor['remote_port'] || ""; // sanitize port if it's null to avoid breaking the split func

to use "hostname" and "port" instead, it may work.

I've just tested that and it seems OK, so I've made that change as well to the code which you'll get from

Brian Candler

unread,
Oct 31, 2020, 4:05:57 PM10/31/20
to NetBox
Note: restart netbox after replacing this file.

João Lucas B. Macedo

unread,
Oct 31, 2020, 8:23:00 PM10/31/20
to Brian Candler, NetBox
Thank you very much. I'll try as soon as possible. 

On Sat, Oct 31, 2020, 17:05 Brian Candler <b.ca...@pobox.com> wrote:
Note: restart netbox after replacing this file.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.

Michael Mastro

unread,
Nov 2, 2020, 9:31:10 AM11/2/20
to NetBox
Yea I just ran a manual call and got the full interface name.  In my Arista device, the lldp neighbor output shows the interface as "Et1/4" which is what I had in Netbox.  I then took Brian's suggestion, and noticed that the NAPALM output is Ethernet1/4.  I changed it to this but still get nothing unfortunately.

It would be nice if netbox could go into the box, see which interfaces are up and populate that in the list of interfaces for said device.

Michael Mastro

unread,
Nov 2, 2020, 9:37:13 AM11/2/20
to NetBox
While the output is not exactly great (doesn't show full hostname - cuts it off after a period), this temp fix DOES show something.  Thank you for this. 

Is this a bug of some sort though because I changed the interfaces to match exactly as what's returned with a manual call, and I still got nothing prior to replacing the above file.

Brian Candler

unread,
Nov 2, 2020, 11:54:36 AM11/2/20
to NetBox
On Monday, 2 November 2020 14:37:13 UTC, Michael Mastro wrote:
While the output is not exactly great (doesn't show full hostname - cuts it off after a period), this temp fix DOES show something.  Thank you for this. 

Is this a bug of some sort though because I changed the interfaces to match exactly as what's returned with a manual call, and I still got nothing prior to replacing the above file.


The change I made did something else as well: it changed "get_lldp_neighbors_detail" to "get_lldp_neighbors".  If the Arista plugin for Napalm only supports the latter and not the former, then you wouldn't have seen anything before, even if the interface names match.

You can test this by using this version of the file:

It includes the fix to show unknown interfaces, but still uses get_lldp_neighbors_detail.
Reply all
Reply to author
Forward
0 new messages