Custom link Conditionals in the Device UI

Given the below config.php configuration for device ui custom links: $config['html']['device']['links'][] = ['url' => '<insert-url>{{ $device[\'sysName\'] }}', 'title' => 'Open-AudIT'];

Example based on the sysname or OS I would like to provide a different url

  • OS APC Management Module AOS would generate a url of {{ $device[‘sysName’] }}.ini
  • OS Opengear would generate a url of {{ $device[‘sysName’] }}.xml
  • All other OS would generate a url of { $device[‘sysName’] }}.cfg

I am playing with shorthand conditionals in php, and I tried the below with no luck:

$config['html']['device']['links'][] = ['url' => 'https://gitlab.example.com/config-backups/{{ $device[\'sysName\'] }}' . ($device[\'osname\'] == 'Opengear') ? '.xml' : (($device[\'osname\'] == 'APC Management Module AOS') ? '.ini' : '.cfg'), 'title' => 'Config Backups'];

Any help is appreciated!

Thanks!

That will never work :wink:
Why not just link to the folder that contains the backup… or you know, use Oxidized. Oxidized - LibreNMS Docs

I could use Oxidized, I’ll have to see what that gets me compared to current workflow.

Right now I have Ansible scheduled backups to gitlab along with Ansible backups for scheduled changes grouping all device configs to one commit linking to the Jira ticket for the schedule change. That all works well.

I guess oxidized should be able to still track commits for that adhoc / change process, and I can handover daily backups to oxidized.

My other options is to just remove or standardize config extensions when backing up.