Serial numbers for stacked equipments

Hi guys,

I am trying to get serial numbers of stacked equipments via API.
If I call : curl https://librenms/api/v0/devices/10.30.10.1

It returns the serial of only the first unit of the stack :
“serial”: “FOC3710W11S”

Also, if I try : curl https://librenms/api/v0/inventory/10.30.10.1

It returns :
“entPhysicalSerialNum”: “”

However, on the UI, tab ‘inventory’, I have what I need :
Capture%20d%E2%80%99%C3%A9cran%20de%202018-04-03%2016-08-03

Any ideas ?

Thanks by advance.

As per the API docs https://docs.librenms.org/#API/Inventory/

Retrieve the inventory for a device. If you call this without any parameters then you will only get part of the inventory. This is because a lot of devices nest each component, for instance you may initially have the chassis, within this the ports - 1 being an sfp cage, then the sfp itself. The way this API call is designed is to enable a recursive lookup. The first call will retrieve the root entry, included within this response will be entPhysicalIndex, you can then call for entPhysicalContainedIn which will then return the next layer of results.

Hi laf, and thank you for your response.

I had read the documentation before posting the first message.
I have spent a couple of days trying harder after your response, but I am still stuck.

curl librenms/api/v0/inventory/10.30.10.253
{
“status”: “ok”,
“inventory”: [
{
“entPhysical_id”: “72668”,
“device_id”: “1470”,
“entPhysicalIndex”: “1”,
“entPhysicalDescr”: “Catalyst 37xx Switch Stack”,
“entPhysicalClass”: “stack”,
“entPhysicalName”: “Cat37xx Stacking”,
“entPhysicalHardwareRev”: “”,
“entPhysicalFirmwareRev”: “”,
“entPhysicalSoftwareRev”: “”,
“entPhysicalAlias”: “”,
“entPhysicalAssetID”: “”,
“entPhysicalIsFRU”: “false”,
“entPhysicalModelName”: “”,
“entPhysicalVendorType”: “cevStackCat37xx”,
“entPhysicalSerialNum”: “”,
“entPhysicalContainedIn”: “0”,
“entPhysicalParentRelPos”: “-1”,
“entPhysicalMfgName”: “”,
“ifIndex”: null
}
],
“count”: 1
}%

Ok, now, following the example of the documentation, I try :
curl librenms/api/v0/inventory/10.30.10.253?entPhysicalContainedIn=72668
{
“status”: “ok”,
“inventory”: [],
“count”: 0
}%

Or may be :
curl librenms/api/v0/inventory/10.30.10.253?entPhysicalContainedIn=1470
{
“status”: “ok”,
“inventory”: [],
“count”: 0
}%

I must miss something…
If you could give an example, that would be very apreciated.

Thank you guys.

You need to pass the entPhysicalIndex value returned in the first api call

1 Like

Thank you so much, it works perfectly.
I feel so ashamed…