Get Port/Interface Type (RJ45/SFP) via API call? Are these infos even stored somewhere?

So I’d like the API to answer me if Port x is an SFP slot or a RJ45 port.

The endpoint devices/{device}/ports/{port} only gives back the field “ifType” which is “ethernetCsmacd” for both types.
There could be a hacky way to query the resources/sensors endpoint and find out if a port has a db value - but i think that wouldn’t be true for a port that either was never up, or never had a transceiver inserted.

Also I’m not sure how SFP ports with RJ-45 SFPs would be displayed.

Does anyone have an idea? Is this possible? Does the device even return the type via SNMP?
It should be possible with ifMauType https://www.iana.org/assignments/ianamau-mib/ianamau-mib

No immediate answers, but working with what is already available, have you had a look at the inventory API? Inventory - LibreNMS Docs

Depending on your model/vendor you can sniff enough info sometimes - for example a Cisco C9300 with C9300-NM-8X module:

RJ45 port - cevPortBaseTEther:

        {
            "entPhysical_id": 2041,
            "device_id": 58,
            "entPhysicalIndex": 1064,
            "entPhysicalDescr": "Gi1\/0\/3",
            "entPhysicalClass": "port",
            "entPhysicalName": "Gi1\/0\/3",
            "entPhysicalHardwareRev": "",
            "entPhysicalFirmwareRev": "",
            "entPhysicalSoftwareRev": "",
            "entPhysicalAlias": "",
            "entPhysicalAssetID": "",
            "entPhysicalIsFRU": "false",
            "entPhysicalModelName": "",
            "entPhysicalVendorType": "cevPortBaseTEther",
            "entPhysicalSerialNum": "",
            "entPhysicalContainedIn": 1060,
            "entPhysicalParentRelPos": 2,
            "entPhysicalMfgName": "",
            "ifIndex": 11
        },

An SFP slot cevContainerSFP:

            "entPhysical_id": 2064,
            "device_id": 58,
            "entPhysicalIndex": 1087,
            "entPhysicalDescr": "Te1\/1\/1 Container",
            "entPhysicalClass": "container",
            "entPhysicalName": "Te1\/1\/1 Container",
            "entPhysicalHardwareRev": "",
            "entPhysicalFirmwareRev": "",
            "entPhysicalSoftwareRev": "",
            "entPhysicalAlias": "",
            "entPhysicalAssetID": "",
            "entPhysicalIsFRU": "false",
            "entPhysicalModelName": "",
            "entPhysicalVendorType": "cevContainerSFP",
            "entPhysicalSerialNum": "",
            "entPhysicalContainedIn": 1086,
            "entPhysicalParentRelPos": 0,
            "entPhysicalMfgName": "",
            "ifIndex": 0
        },

What is in that SFP slot cevSFPH10GBCU1M

            "entPhysical_id": 3045,
            "device_id": 58,
            "entPhysicalIndex": 1095,
            "entPhysicalDescr": "SFP-10GBase-CX1",
            "entPhysicalClass": "port",
            "entPhysicalName": "Te1\/1\/1",
            "entPhysicalHardwareRev": "V02",
            "entPhysicalFirmwareRev": "",
            "entPhysicalSoftwareRev": "",
            "entPhysicalAlias": "",
            "entPhysicalAssetID": "",
            "entPhysicalIsFRU": "true",
            "entPhysicalModelName": "SFP-H10GB-CU1M",
            "entPhysicalVendorType": "cevSFPH10GBCU1M",
            "entPhysicalSerialNum": "Gxxxxxxx-1",
            "entPhysicalContainedIn": 1087,
            "entPhysicalParentRelPos": 1,
            "entPhysicalMfgName": "FS",
            "ifIndex": 37
        },

Granted you have to know what you’re looking at - to your point, this is a 10Gbit RJ45 port in an SFP slot cevSFP10GSR:

        {
            "entPhysical_id": 4081,
            "device_id": 58,
            "entPhysicalIndex": 1127,
            "entPhysicalDescr": "SFP-10GBase-SR",
            "entPhysicalClass": "port",
            "entPhysicalName": "Te1\/1\/8",
            "entPhysicalHardwareRev": "V03",
            "entPhysicalFirmwareRev": "",
            "entPhysicalSoftwareRev": "",
            "entPhysicalAlias": "",
            "entPhysicalAssetID": "",
            "entPhysicalIsFRU": "true",
            "entPhysicalModelName": "SFP-10G-SR",
            "entPhysicalVendorType": "cevSFP10GSR",
            "entPhysicalSerialNum": "F2010380208",
            "entPhysicalContainedIn": 1094,
            "entPhysicalParentRelPos": 1,
            "entPhysicalMfgName": "FS",
            "ifIndex": 44
        },

This seems to be reasonable, unfortunately I won’t come around to test it the next few days.

Thanks alot, I’ll add a comment once I tested it!

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