Port-channel member interfaces via API

Hello,

Is it possible to gather information about port-channel member interfaces via API?

Hello,
Try same ifPhysAddress and parse their ifType the one with ieee8023adLag is lag and others its members.

Hello,
I’m not sure that I understand you properly. Could you please explain more detailed?

It’s possible with port api call and postprocessing.

How exactly? For example I have stack of 2xCat9300, here is output with mac addresses -

mgm-core#sh interfaces port-ch3 | incl Hardw
  Hardware is EtherChannel, address is 0045.1d1b.4db7 (bia 0045.1d1b.4db7)
mgm-core#sh interfaces te 1/1/3 | incl Hardw 
  Hardware is Ten Gigabit Ethernet, address is 0045.1d1b.4db7 (bia 0045.1d1b.4db7)
mgm-core#sh interfaces te 2/1/3 | incl Hardw 
  Hardware is Ten Gigabit Ethernet, address is 0045.1d1b.4737 (bia 0045.1d1b.4737)
mgm-core#

I have port-channel and one of physical ports only with the same mac addresses. But second interface in this port-channel has different hw address.

And additionally looks like libre can gather information about port-channel members from nexus devices.

Hello @zombah,

Sorry for the late reply

We have tried your suggestion. However, ifType on a member interface shows ethernetCsmacd, which is expected, and on the port-channel interface, it shows as propVirtual, which also quite ok.

The only problem, for now, is to determine the member interface relationship to the parent port-channel member through API, see the example below:

API output for a port-channel interface:

{
    "status": "ok",
    "port": [
        {
            "port_id": 15583,
            "device_id": 224,
            "port_descr_type": null,
            "port_descr_descr": null,
            "port_descr_circuit": null,
            "port_descr_speed": null,
            "port_descr_notes": null,
            "ifDescr": "Port-channel4",
            "ifName": "Po4",
            "portName": null,
            "ifIndex": 5004,
            "ifSpeed": 2000000000,
            "ifSpeed_prev": 2000000000,
            "ifConnectorPresent": "false",
            "ifPromiscuousMode": "false",
            "ifHighSpeed": 2000,
            "ifHighSpeed_prev": 2000,
            "ifOperStatus": "up",
            "ifOperStatus_prev": "down",
            "ifAdminStatus": "up",
            "ifAdminStatus_prev": "up",
            "ifDuplex": null,
            "ifMtu": 1500,
            "ifType": "propVirtual",
            "ifAlias": "2960 RACK4",
            "ifPhysAddress": "9c4e20f61304",
            "ifHardType": null,
            "ifLastChange": 2608628491,
            "ifVlan": "1",
            "ifTrunk": "dot1Q",
            "ifVrf": 0,
            "counter_in": null,
            "counter_out": null,
            "ignore": 0,
            "disabled": 0,
            "detailed": 0,
            "deleted": 0,
            "pagpOperationMode": null,
            "pagpPortState": null,
            "pagpPartnerDeviceId": null,
            "pagpPartnerLearnMethod": null,
            "pagpPartnerIfIndex": null,
            "pagpPartnerGroupIfIndex": null,
            "pagpPartnerDeviceName": null,
            "pagpEthcOperationMode": null,
            "pagpDeviceId": null,
            "pagpGroupIfIndex": null,
            "ifInUcastPkts": 190105005,
            "ifInUcastPkts_prev": 190102827,
            "ifInUcastPkts_delta": 2178,
            "ifInUcastPkts_rate": 7,
            "ifOutUcastPkts": 425904779,
            "ifOutUcastPkts_prev": 425901623,
            "ifOutUcastPkts_delta": 3156,
            "ifOutUcastPkts_rate": 10,
            "ifInErrors": 0,
            "ifInErrors_prev": 0,
            "ifInErrors_delta": 0,
            "ifInErrors_rate": 0,
            "ifOutErrors": 0,
            "ifOutErrors_prev": 0,
            "ifOutErrors_delta": 0,
            "ifOutErrors_rate": 0,
            "ifInOctets": 44516338607,
            "ifInOctets_prev": 44515787827,
            "ifInOctets_delta": 550780,
            "ifInOctets_rate": 1800,
            "ifOutOctets": 71802340010,
            "ifOutOctets_prev": 71801821979,
            "ifOutOctets_delta": 518031,
            "ifOutOctets_rate": 1693,
            "poll_time": 1624888852,
            "poll_prev": 1624888546,
            "poll_period": 306
        }
    ],
    "count": 1
}

Same output for a member interface related to the port-channel 4 (from the output above):

{
    "status": "ok",
    "port": [
        {
            "port_id": 15598,
            "device_id": 224,
            "port_descr_type": null,
            "port_descr_descr": null,
            "port_descr_circuit": null,
            "port_descr_speed": null,
            "port_descr_notes": null,
            "ifDescr": "GigabitEthernet1/0/4",
            "ifName": "Gi1/0/4",
            "portName": null,
            "ifIndex": 10104,
            "ifSpeed": 1000000000,
            "ifSpeed_prev": 1000000000,
            "ifConnectorPresent": "true",
            "ifPromiscuousMode": "false",
            "ifHighSpeed": 1000,
            "ifHighSpeed_prev": 1000,
            "ifOperStatus": "up",
            "ifOperStatus_prev": "down",
            "ifAdminStatus": "up",
            "ifAdminStatus_prev": "up",
            "ifDuplex": "fullDuplex",
            "ifMtu": 1500,
            "ifType": "ethernetCsmacd",
            "ifAlias": "GigabitEthernet1/0/4",
            "ifPhysAddress": "9c4e20f61304",
            "ifHardType": null,
            "ifLastChange": 2608628290,
            "ifVlan": "",
            "ifTrunk": null,
            "ifVrf": 0,
            "counter_in": null,
            "counter_out": null,
            "ignore": 0,
            "disabled": 0,
            "detailed": 0,
            "deleted": 0,
            "pagpOperationMode": null,
            "pagpPortState": null,
            "pagpPartnerDeviceId": null,
            "pagpPartnerLearnMethod": null,
            "pagpPartnerIfIndex": null,
            "pagpPartnerGroupIfIndex": null,
            "pagpPartnerDeviceName": null,
            "pagpEthcOperationMode": null,
            "pagpDeviceId": null,
            "pagpGroupIfIndex": null,
            "ifInUcastPkts": 123770903,
            "ifInUcastPkts_prev": 123770520,
            "ifInUcastPkts_delta": 383,
            "ifInUcastPkts_rate": 1,
            "ifOutUcastPkts": 220635490,
            "ifOutUcastPkts_prev": 220633175,
            "ifOutUcastPkts_delta": 2315,
            "ifOutUcastPkts_rate": 8,
            "ifInErrors": 0,
            "ifInErrors_prev": 0,
            "ifInErrors_delta": 0,
            "ifInErrors_rate": 0,
            "ifOutErrors": 0,
            "ifOutErrors_prev": 0,
            "ifOutErrors_delta": 0,
            "ifOutErrors_rate": 0,
            "ifInOctets": 27447771009,
            "ifInOctets_prev": 27447697175,
            "ifInOctets_delta": 73834,
            "ifInOctets_rate": 254,
            "ifOutOctets": 40272822606,
            "ifOutOctets_prev": 40272391837,
            "ifOutOctets_delta": 430769,
            "ifOutOctets_rate": 1480,
            "poll_time": 1624889143,
            "poll_prev": 1624888852,
            "poll_period": 291
        }
    ],
    "count": 1
}

Is there a way to get this relationship information using API?

@zombah here is how the correlation looks from SQL perspective:

 MariaDB [librenms]> select ifIndex from ports where device_id=224 and ifName='Po4';
+---------+
| ifIndex |
+---------+
|    5004 |
+---------+
1 row in set (0.00 sec)

MariaDB [librenms]> select * from ports_stack where device_id=224 and port_id_high=5004;
+-----------+--------------+-------------+---------------+
| device_id | port_id_high | port_id_low | ifStackStatus |
+-----------+--------------+-------------+---------------+
|       224 |         5004 |       10104 | active        |
|       224 |         5004 |       10604 | active        |
+-----------+--------------+-------------+---------------+
2 rows in set (0.00 sec)

MariaDB [librenms]> select ifName from ports where device_id=224 and ifIndex=10104;
+---------+
| ifName  |
+---------+
| Gi1/0/4 |
+---------+
1 row in set (0.00 sec)

MariaDB [librenms]> select ifName from ports where device_id=224 and ifIndex=10604;
+---------+
| ifName  |
+---------+
| Gi2/0/4 |
+---------+
1 row in set (0.25 sec)

Let me know if I need to provide more details.

Looks like get_port_stack endpoint answers our questions however it would be great if you can give some hint how to query this endpoint based on port_id_high column.

Thank you in advance

Hello, As you can see ifPhysAddress is same, so you can try figure relation using it.
I didn’t know get_port_stack exist, this endpoint look like best method for LAG members, as i understand it port_id_high is LAG port and port_id_low it’s members.
You can get full list’s list_devices, get_port_stack and get_all_ports then join them same way you do for sql and query resulting dict specific device and port.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.