API response for PORTS

Tags: #<Tag:0x00007f3b8b346e58>

Hi,

At the moment API call to “/api/v0/devices/:hostname/ports” returns ifName which is great but not much use if you are parsing this data and have no idea what it is. Would be nice to have ifDesc or / and ifAlias added (maybe even port id) e.g:

{
“status”: “ok”,
“ports”: [
{
“ifName”: “GigabitEthernet2/0.101”,
"ifDesc": "Customer ABC" ,
"port_id": (int)
}
],
}%

Thank you.

https://docs.librenms.org/API/Ports/

/api/v0/ports/:portid
?

{
  "status": "ok",
  "message": "",
  "port": [
    {
      "port_id": "323",
      "device_id": "55",
      "port_descr_type": null,
      "port_descr_descr": null,
      "port_descr_circuit": null,
      "port_descr_speed": null,
      "port_descr_notes": null,
      "ifDescr": "GigabitEthernet0/0/0",
      "ifName": "Gi0/0/0",
      "portName": null,
      "ifIndex": "1",
      "ifSpeed": "1000000000",
      "ifConnectorPresent": "true",
      "ifPromiscuousMode": "false",
      "ifHighSpeed": "1000",
      "ifOperStatus": "up",
      "ifOperStatus_prev": null,
      "ifAdminStatus": "up",
      "ifAdminStatus_prev": null,
      "ifDuplex": "fullDuplex",
      "ifMtu": "1560",
      "ifType": "ethernetCsmacd",
      "ifAlias": "ASR Interconnect Trunk",
      "ifPhysAddress": "84bf20853e00",
      "ifHardType": null,
      "ifLastChange": "42407358",
      "ifVlan": "",
      "ifTrunk": "",
      "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": "128518576",
      "ifInUcastPkts_prev": "128517284",
      "ifInUcastPkts_delta": "1292",
      "ifInUcastPkts_rate": "4",
      "ifOutUcastPkts": "128510560",
      "ifOutUcastPkts_prev": "128509268",
      "ifOutUcastPkts_delta": "1292",
      "ifOutUcastPkts_rate": "4",
      "ifInErrors": "0",
      "ifInErrors_prev": "0",
      "ifInErrors_delta": "0",
      "ifInErrors_rate": "0",
      "ifOutErrors": "0",
      "ifOutErrors_prev": "0",
      "ifOutErrors_delta": "0",
      "ifOutErrors_rate": "0",
      "ifInOctets": "12827393730",
      "ifInOctets_prev": "12827276736",
      "ifInOctets_delta": "116994",
      "ifInOctets_rate": "387",
      "ifOutOctets": "14957481766",
      "ifOutOctets_prev": "14957301765",
      "ifOutOctets_delta": "180001",
      "ifOutOctets_rate": "596",
      "poll_time": "1483779150",
      "poll_prev": "1483778848",
      "poll_period": "302"
    }
  ]
}

That’s a response to completely different API route, I’m looking for host specific ports, not all :wink:

i mean:

/api/v0/devices/:hostname/ports?columns=ifName%2Cport_id%2Cport_descr_descr

Use the Port API in it

Now u got your output

Sorry that im not that clear :slight_smile:

1 Like

By the way, you wan ifAlias, not ifDescr… ifDescr is the hardware supplied description of the port. ifAlias is user editable.

But yes, you need two api calls I think, one to get the port id you are interested in, and another get the info about that port.

Yep, that’s done it :slight_smile:

what SpinperVegeta suggested works :slight_smile: which is just what I’ve been looking for. Shame it’s a long URL request :stuck_out_tongue: