Allow port name in URL

Similar to Allow device url by hostname by murrant · Pull Request #11831 · librenms/librenms, I’d like to enable links to use the port name rather than the internal port ID.

This is to enable linking to specific ports/interfaces from our DCIM (Netbox) that holds all our devices/interfaces, without needing to sync LibreNMS specific device/interface IDs into it.

Ex, for sw5.contoso.com port ge-0/2/0, allowing both:
https://librenms.contoso.com/device/device=43/tab=port/port=502/
And
https://librenms.contoso.com/device/device=sw5.contoso.com/tab=port/port=ge-0%2F2%2F0/

I’m happy to try to create a PR but would need some guidance on what all places to tweak :slight_smile:, the PR for the hostname has a few small tweaks, for the port page would it just be attempting to resolve the ID here from a name? librenms/includes/html/pages/device/port.inc.php at 20e88e6cf4e9df1398be456a16df9c6349156311 · librenms/librenms · GitHub

Thanks!

Hi,
Ports usually use slashes in their names, so they are not url friendly.
Possible with remaping slashes and maybe any other url not friendly stuff to something else like minus maybe…

Any concerns with using the standard URL encoding mechanism that I showed in my example? URLs with slashes and such for data rather than a path is a solved problem. A slash would simply be encoded as %2F so it’s more url friendly. (And a dash/minus is also used in interface names…)

I’m not super familiar with PHP/the framework LibreNMS uses, so maybe I’m missing something?

Thanks!

Yeah probably this will work