allow to search a device by its hostname #958

merged 2 commits into from May 11, 2015


None yet

4 participants


search by hostname if ID was not found
it also permits to add a quick search for a device in most modern browsers ;)
( http://nmsinstall//device/device=dev-hostname/ )

@f0o f0o self-assigned this May 10, 2015
f0o commented May 10, 2015

We already have this with http://librenms/devices/hostname=.../ - it's a real search and doesnt require the correct hostname but any portion of it will do the job.


ha indeed, I did not know about this search
however, it still adds a few clicks (for example I use this patch to access ports page directly too)
the idea here is to come directly on the right device on the right page to save from a searching step
so not sure if you find this relevant or not ;)

laf commented May 10, 2015

I can see why you would want to do this, quick access to the device itself by url. It seems like one of those features few might use. It doesn't take us back in anyway so I'd vote to add it.

f0o commented May 11, 2015

It probably doesnt do any harm.

I'd like to change the code a little bit however:

diff --git a/html/pages/ b/html/pages/
index 9dcf277..0e2c166 100644
--- a/html/pages/
+++ b/html/pages/
@@ -6,10 +6,8 @@ if ($vars['tab'] == "port" && is_numeric($vars['device']) && port_permitted($var
   $permit_ports = 1;

-$device  = device_by_id_cache($vars['device']);
-if (!$device) {
+if (!is_numeric($vars['device'])) {
   $vars['device'] = device_by_name($vars['device']);
-  $device  = device_by_id_cache($vars['device']);

 if (device_permitted($vars['device']) || $check_device == $vars['device'])
@@ -25,6 +23,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])

   $select[$tab] = "active";

+  $device  = device_by_id_cache($vars['device']);
   $attribs = get_dev_attribs($device['device_id']);

   $entity_state = get_dev_entity_state($device['device_id']);

+1 from me after @f0o's change added

@f0o f0o merged commit a585022 into librenms:master May 11, 2015

1 check passed

Scrutinizer No new issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment