From 937937aa09a0c186c70a8dba64975f921eee111d Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 16:10:28 -0800 Subject: [PATCH 1/5] Update core.inc.php --- includes/polling/core.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/core.inc.php b/includes/polling/core.inc.php index ec23309a24..1af4e3b58f 100644 --- a/includes/polling/core.inc.php +++ b/includes/polling/core.inc.php @@ -85,7 +85,7 @@ $poll_device['sysLocation'] = str_replace('"', '', $poll_device['sysLocation']); $poll_device['sysLocation'] = trim($poll_device['sysLocation'], '\\'); // Rewrite sysLocation if there is a mapping array (database too?) -if (!empty($poll_device['sysLocation']) && is_array($config['location_map'])) { +if (!empty($poll_device['sysLocation']) && (is_array($config['location_map']) || is_array($config['location_map_regex']))) { $poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']); } From cf5b6ba12156251e7f6870884f368d97b125853d Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 16:11:38 -0800 Subject: [PATCH 2/5] Update rewrites.php --- includes/rewrites.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/rewrites.php b/includes/rewrites.php index e2516d5c28..7be24032b1 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -5,6 +5,14 @@ function rewrite_location($location) { // FIXME -- also check the database for rewrites? global $config, $debug; + if (is_array($config['location_map_regex'])) { + foreach ($config['location_map_regex'] as $reg => $val) { + if (preg_match($reg, $location)) { + $location = $val; + } + } + } + if (isset($config['location_map'][$location])) { $location = $config['location_map'][$location]; } From e9fef9de2eb44eaa417ac7ef63e79d12450fdaaa Mon Sep 17 00:00:00 2001 From: pblasquez Date: Fri, 5 Feb 2016 14:58:17 -0800 Subject: [PATCH 3/5] Update AUTHORS.md I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md. --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 1aa5c18ff9..ad2afab6e6 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -83,6 +83,7 @@ LibreNMS contributors: - Maximilian Wilhelm (BarbarossaTM) - Jameson Finney (JamesonFinney) - John Wells (jbwiv) +- Paul Blasquez (pblasquez) [1]: http://observium.org/ "Observium web site" Observium was written by: From 3ee30fae7c8bb6fd4016011f1ab2f2854aacad3e Mon Sep 17 00:00:00 2001 From: pblasquez Date: Mon, 8 Feb 2016 16:03:48 -0800 Subject: [PATCH 4/5] Update Configuration.md --- doc/Support/Configuration.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index f37f7bc786..8070df0ce5 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -379,10 +379,15 @@ NFSen integration support. #### Location mapping +Exact Matching: ```php $config['location_map']['Under the Sink'] = "Under The Sink, The Office, London, UK"; ``` -The above is an example, this will rewrite basic snmp locations so you don't need to configure full location within snmp. +Regex Matching: +```php +$config['location_map']['/Sink/'] = "Under The Sink, The Office, London, UK"; +``` +The above are examples, these will rewrite device snmp locations so you don't need to configure full location within snmp. #### Interfaces to be ignored From 1b97bf069fc1f643229d1d12edd56c7950499117 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Mon, 8 Feb 2016 16:09:16 -0800 Subject: [PATCH 5/5] Update rewrites.php --- includes/rewrites.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/rewrites.php b/includes/rewrites.php index 7be24032b1..b4b28cd631 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -9,6 +9,7 @@ function rewrite_location($location) { foreach ($config['location_map_regex'] as $reg => $val) { if (preg_match($reg, $location)) { $location = $val; + continue; } } }