From e7c59dbd575ecdbb998830621e4c9a69e886496b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 3 Feb 2016 16:01:31 -0600 Subject: [PATCH 01/25] Initial Calix E7 Support --- includes/definitions.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 07550b2e3e..0b3d08490c 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -311,6 +311,16 @@ $config['os'][$os]['icon'] = 'barracuda'; $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Traffic'; +// Calix +$os = 'calix'; +$config['os'][$os]['text'] = 'Calix E7'; +$config['os'][$os]['type'] = 'network'; +$config['os'][$os]['icon'] = 'calix'; +$config['os'][$os]['over'][0]['graph'] = 'device_bits'; +$config['os'][$os]['over'][0]['text'] = 'Device Traffic'; +$config['os'][$os]['over'][1]['graph'] = 'device_processor'; +$config['os'][$os]['over'][1]['text'] = 'CPU Usage'; + // Cisco OSes $os = 'ios'; $config['os'][$os]['group'] = 'cisco'; From 937937aa09a0c186c70a8dba64975f921eee111d Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 16:10:28 -0800 Subject: [PATCH 02/25] 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 03/25] 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 4aa9838eda55a29180ae90d7929502dd7529454b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 5 Feb 2016 14:26:06 -0600 Subject: [PATCH 04/25] add discover, polling and mibs. work around empty ifDesc --- html/images/os/calix.png | Bin 0 -> 838 bytes includes/discovery/os/calix.inc.php | 6 + includes/functions.php | 2 +- includes/polling/os/calix.inc.php | 4 + mibs/CALIX-PRODUCT-MIB.my | 291 ++++++ mibs/CALIX-SMI.my | 78 ++ mibs/E7-Calix-MIB | 1361 +++++++++++++++++++++++++++ mibs/E7-TC.my | 689 ++++++++++++++ 8 files changed, 2430 insertions(+), 1 deletion(-) create mode 100644 html/images/os/calix.png create mode 100644 includes/discovery/os/calix.inc.php create mode 100644 includes/polling/os/calix.inc.php create mode 100644 mibs/CALIX-PRODUCT-MIB.my create mode 100644 mibs/CALIX-SMI.my create mode 100644 mibs/E7-Calix-MIB create mode 100644 mibs/E7-TC.my diff --git a/html/images/os/calix.png b/html/images/os/calix.png new file mode 100644 index 0000000000000000000000000000000000000000..156c0f8530b5b085ecdabee445aba51fbb22aefc GIT binary patch literal 838 zcmV-M1G)T(P)m0@F!E zK~z}7)z?jETvZeY@L$ppv{Wp$=wMMxRm38M3O=lYDeYV6BBFMq_<=|i7gdW$1;g8T znT2*Ch~UDHD7ex^3%U^dz#0fNccWcY!OBR%)NJ}ep`;Y*xVeRCI=*=`84=IwaXI(> z|L5HE$$u;({a(nkVlyVO6*uA(TKJ)i;n=@IAkT^kJcSprp+fZ%KE`Yr!@{Zwk8Z!9SGKN2U#z3AG>+tOm!O!5KDsUL<_J-zxn_j!5s;7x{JyI>~1u* zM|=G16fO*C{MyvAYo}qS~&SPH~i(r9YqC>~sz@i^YYZ5=AhNvCTsIEeBx zc#>xZje$nf0o;v)9mglT)qxvQ26S`V1#Bo|SYBlszK>V%Y@_Lml^&R@c(ZF#>0OmH znqEx<&O$d2oKJyMC10nS(CYGZ>#zrJAunTy{g&csd{onzdCcNx+=Qvr%q|;n9^1+o zj`u@gJ&t4JklOJ@>?~uLuQd~vF`P{ma9A>qLwQ!*UVA7_Y+oNDiED8z&x&1D)9V$| zTAVwwWz*z(+&?4|W4M0Hrpd2bi*xPTdqJKR&*AeS5O}kU;oU(Olk4z(YM*0$fVS}m zrn*c|1FdHF;RU=@wag^>5+7i`jJ-SPAj|2!*o8ZjSJvPc94TWs?EfZz1H=E=N?@$3 Q?*IS*07*qoM6N<$f`=K11poj5 literal 0 HcmV?d00001 diff --git a/includes/discovery/os/calix.inc.php b/includes/discovery/os/calix.inc.php new file mode 100644 index 0000000000..40ca58fdbb --- /dev/null +++ b/includes/discovery/os/calix.inc.php @@ -0,0 +1,6 @@ + Date: Fri, 5 Feb 2016 14:29:10 -0600 Subject: [PATCH 05/25] Fix oxidized versioning + groups Consilidate config fetching rather than having two fetches with the first always failing when the device has a group. --- html/pages/device/showconfig.inc.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/html/pages/device/showconfig.inc.php b/html/pages/device/showconfig.inc.php index 9e5d0b1a62..ed9219cf23 100644 --- a/html/pages/device/showconfig.inc.php +++ b/html/pages/device/showconfig.inc.php @@ -106,19 +106,13 @@ if ($_SESSION['userlevel'] >= '7') { $node_info = json_decode(file_get_contents($config['oxidized']['url'].'/node/show/'.$device['hostname'].'?format=json'), true); if ($config['oxidized']['features']['versioning'] === true && isset($_POST['config'])) { list($oid,$date,$version) = explode('|',mres($_POST['config'])); - $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group=&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group='.(is_array($node_info) ? $node_info['group'] : $device['os']).'&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); - } + $text = file_get_contents($config['oxidized']['url'].'/node/version/view?node='.$device['hostname'].'&group='.(!empty($node_info['group']) ? $node_info['group'] : '').'&oid='.$oid.'&date='.urlencode($date).'&num='.$version.'&format=text'); } else { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.$device['hostname']); - if ($text == 'node not found') { - $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(is_array($node_info) ? $node_info['group'] : $device['os']).'/'.$device['hostname']); - } + $text = file_get_contents($config['oxidized']['url'].'/node/fetch/'.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$device['hostname']); } if ($config['oxidized']['features']['versioning'] === true) { - $config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.$device['hostname'].'&format=json'), true); + $config_versions = json_decode(file_get_contents($config['oxidized']['url'].'/node/version?node_full='.(!empty($node_info['group']) ? $node_info['group'].'/' : '').$device['hostname'].'&format=json'), true); } if (is_array($node_info) || is_array($config_versions)) { From 8eda8e0bfcc43431ac49e34fd37284b6bdc6531e Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 5 Feb 2016 16:29:42 -0600 Subject: [PATCH 06/25] Fix Oxidized node reloading. --- includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index e399a10ae5..6b9075e6b7 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1324,7 +1324,7 @@ function oxidized_reload_nodes() { global $config; if ($config['oxidized']['enabled'] === TRUE && $config['oxidized']['reload_nodes'] === TRUE && isset($config['oxidized']['url'])) { - $oxidized_reload_url = $config['oxidized']['url'] . '/reload'; + $oxidized_reload_url = $config['oxidized']['url'] . '/reload?format=json'; $ch = curl_init($oxidized_reload_url); curl_setopt($ch, CURLOPT_TIMEOUT, 5); From e9fef9de2eb44eaa417ac7ef63e79d12450fdaaa Mon Sep 17 00:00:00 2001 From: pblasquez Date: Fri, 5 Feb 2016 14:58:17 -0800 Subject: [PATCH 07/25] 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 a34b95835279cd3effa22f49d142c3e0c03a0b78 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 5 Feb 2016 17:57:17 -0600 Subject: [PATCH 08/25] Add hardware and version for Netonix. --- includes/polling/os/netonix.inc.php | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 includes/polling/os/netonix.inc.php diff --git a/includes/polling/os/netonix.inc.php b/includes/polling/os/netonix.inc.php new file mode 100644 index 0000000000..bd63ed309e --- /dev/null +++ b/includes/polling/os/netonix.inc.php @@ -0,0 +1,3 @@ + Date: Fri, 5 Feb 2016 18:14:44 -0600 Subject: [PATCH 09/25] Use poll_device; List the inserted cards in "features". --- includes/polling/os/calix.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/polling/os/calix.inc.php b/includes/polling/os/calix.inc.php index 6104481897..c4e22dca44 100644 --- a/includes/polling/os/calix.inc.php +++ b/includes/polling/os/calix.inc.php @@ -1,4 +1,5 @@ Date: Mon, 8 Feb 2016 10:29:55 -0600 Subject: [PATCH 10/25] Pull card serial numbers. Unsure if this what we want. Set ifName as the primary port name. --- includes/definitions.inc.php | 1 + includes/polling/os/calix.inc.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 0b3d08490c..0d3ffc2e29 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -315,6 +315,7 @@ $config['os'][$os]['over'][0]['text'] = 'Traffic'; $os = 'calix'; $config['os'][$os]['text'] = 'Calix E7'; $config['os'][$os]['type'] = 'network'; +$config['os'][$os]['ifname'] = 1; $config['os'][$os]['icon'] = 'calix'; $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Device Traffic'; diff --git a/includes/polling/os/calix.inc.php b/includes/polling/os/calix.inc.php index c4e22dca44..638d139418 100644 --- a/includes/polling/os/calix.inc.php +++ b/includes/polling/os/calix.inc.php @@ -1,5 +1,6 @@ Date: Mon, 8 Feb 2016 13:58:03 -0600 Subject: [PATCH 11/25] Add a generic way to allow empty ifDescr on ports for an OS. --- includes/definitions.inc.php | 1 + includes/functions.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 0d3ffc2e29..7b874be862 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -316,6 +316,7 @@ $os = 'calix'; $config['os'][$os]['text'] = 'Calix E7'; $config['os'][$os]['type'] = 'network'; $config['os'][$os]['ifname'] = 1; +$config['os'][$os]['empty_ifdescr'] = 1; $config['os'][$os]['icon'] = 'calix'; $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Device Traffic'; diff --git a/includes/functions.php b/includes/functions.php index 883bccc652..f5949aae3e 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -895,7 +895,7 @@ function is_port_valid($port, $device) { } } } - if (empty($port['ifDescr']) && !$device['os'] == "calix") { + if (empty($port['ifDescr']) && !$config['os'][$device['os']]['empty_ifdescr']) { $valid = 0; } if ($device['os'] == "catos" && strstr($if, "vlan")) { From 17fe1d1f66a19d79d49f96db62c588039627b26f Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Feb 2016 15:01:25 -0600 Subject: [PATCH 12/25] I could not find cpu info in Calix MIBs. Just load in hr. --- includes/definitions.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 7b874be862..6013d2caa4 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -320,8 +320,6 @@ $config['os'][$os]['empty_ifdescr'] = 1; $config['os'][$os]['icon'] = 'calix'; $config['os'][$os]['over'][0]['graph'] = 'device_bits'; $config['os'][$os]['over'][0]['text'] = 'Device Traffic'; -$config['os'][$os]['over'][1]['graph'] = 'device_processor'; -$config['os'][$os]['over'][1]['text'] = 'CPU Usage'; // Cisco OSes $os = 'ios'; From 21c2bb312a589c1b255850298d6e6eb2f61c6ca7 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 8 Feb 2016 15:50:54 -0600 Subject: [PATCH 13/25] Do not hardcode mib path --- includes/polling/os/netonix.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/os/netonix.inc.php b/includes/polling/os/netonix.inc.php index bd63ed309e..50c1782a8b 100644 --- a/includes/polling/os/netonix.inc.php +++ b/includes/polling/os/netonix.inc.php @@ -1,3 +1,3 @@ Date: Mon, 8 Feb 2016 16:03:48 -0800 Subject: [PATCH 14/25] 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 15/25] 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; } } } From f2054d369ba36b429831981f952b0f42f076dd6e Mon Sep 17 00:00:00 2001 From: arrmo Date: Mon, 8 Feb 2016 20:15:11 -0600 Subject: [PATCH 16/25] Updates for Windows 10 --- includes/polling/os/windows.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/polling/os/windows.inc.php b/includes/polling/os/windows.inc.php index c31e1741ef..637aff1a2c 100644 --- a/includes/polling/os/windows.inc.php +++ b/includes/polling/os/windows.inc.php @@ -28,7 +28,7 @@ if (strstr($poll_device['sysDescr'], 'Intel64')) { $hardware = 'Intel x64'; } -if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.1') { +if ($poll_device['sysObjectID'] == 'enterprises.311.1.1.3.1.1') { if (strstr($poll_device['sysDescr'], 'Build Number: 1057')) { $version = 'NT 3.51 Workstation'; } @@ -81,6 +81,10 @@ if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.1') { $version = '8.1 SP1 (NT 6.2)'; } + if (strstr($poll_device['sysDescr'], 'Version 6.3 (Build 10')) { + $version = '10 (NT 6.3)'; + } + } else if ($poll_device['sysObjectID'] == '.1.3.6.1.4.1.311.1.1.3.1.2') { if (strstr($poll_device['sysDescr'], 'Build Number: 1057')) { From b0167630072d94a56eff32a125d28898821dbdc3 Mon Sep 17 00:00:00 2001 From: ohrensessel Date: Tue, 9 Feb 2016 13:27:10 +0100 Subject: [PATCH 17/25] Fix usage of single quotes, double quotes needed --- html/pages/device/edit/snmp.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/device/edit/snmp.inc.php b/html/pages/device/edit/snmp.inc.php index b77f3dcc47..b2749069a5 100644 --- a/html/pages/device/edit/snmp.inc.php +++ b/html/pages/device/edit/snmp.inc.php @@ -194,11 +194,11 @@ echo "
- '; + "; if ($config['distributed_poller'] === true) { echo ' From 1b59ae964868397089577c613c49af4ee714df02 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Feb 2016 08:01:41 -0600 Subject: [PATCH 18/25] Use $config['mibdir'] instead of $config['mib_dir'] --- includes/polling/os/netonix.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/polling/os/netonix.inc.php b/includes/polling/os/netonix.inc.php index 50c1782a8b..3b58eb81c8 100644 --- a/includes/polling/os/netonix.inc.php +++ b/includes/polling/os/netonix.inc.php @@ -1,3 +1,3 @@ Date: Tue, 9 Feb 2016 20:00:54 +0100 Subject: [PATCH 19/25] Revert "Added location_map_regex" --- AUTHORS.md | 1 - doc/Support/Configuration.md | 7 +------ includes/polling/core.inc.php | 2 +- includes/rewrites.php | 9 --------- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index ad2afab6e6..1aa5c18ff9 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -83,7 +83,6 @@ 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: diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 8070df0ce5..f37f7bc786 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -379,15 +379,10 @@ NFSen integration support. #### Location mapping -Exact Matching: ```php $config['location_map']['Under the Sink'] = "Under The Sink, The Office, London, UK"; ``` -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. +The above is an example, this will rewrite basic snmp locations so you don't need to configure full location within snmp. #### Interfaces to be ignored diff --git a/includes/polling/core.inc.php b/includes/polling/core.inc.php index 1af4e3b58f..ec23309a24 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']) || is_array($config['location_map_regex']))) { +if (!empty($poll_device['sysLocation']) && is_array($config['location_map'])) { $poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']); } diff --git a/includes/rewrites.php b/includes/rewrites.php index b4b28cd631..e2516d5c28 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -5,15 +5,6 @@ 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; - continue; - } - } - } - if (isset($config['location_map'][$location])) { $location = $config['location_map'][$location]; } From f074f25be23422d088d594a14cc2b84c2c83f2c8 Mon Sep 17 00:00:00 2001 From: Neil Lathwood Date: Tue, 9 Feb 2016 19:02:38 +0000 Subject: [PATCH 20/25] Revert "Revert "Added location_map_regex"" --- AUTHORS.md | 1 + doc/Support/Configuration.md | 7 ++++++- includes/polling/core.inc.php | 2 +- includes/rewrites.php | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) 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: 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 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']); } diff --git a/includes/rewrites.php b/includes/rewrites.php index e2516d5c28..b4b28cd631 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -5,6 +5,15 @@ 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; + continue; + } + } + } + if (isset($config['location_map'][$location])) { $location = $config['location_map'][$location]; } From 6e71661a3a4e8940c3a80caeb73d5fd68b62d981 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 9 Feb 2016 19:04:05 +0000 Subject: [PATCH 21/25] Changed continue to break --- includes/rewrites.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/rewrites.php b/includes/rewrites.php index b4b28cd631..da0623f116 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -9,7 +9,7 @@ function rewrite_location($location) { foreach ($config['location_map_regex'] as $reg => $val) { if (preg_match($reg, $location)) { $location = $val; - continue; + break; } } } From 0422d8e58901b08669743cec33851f8c8d52eec3 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Feb 2016 13:31:36 -0600 Subject: [PATCH 22/25] Add fanspeed,temp, and voltage for Netonix switches. --- .../sensors/fanspeeds/netonix.inc.php | 17 +++++++++++++++++ .../sensors/temperatures/netonix.inc.php | 17 +++++++++++++++++ .../discovery/sensors/voltages/netonix.inc.php | 18 ++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 includes/discovery/sensors/fanspeeds/netonix.inc.php create mode 100644 includes/discovery/sensors/temperatures/netonix.inc.php create mode 100644 includes/discovery/sensors/voltages/netonix.inc.php diff --git a/includes/discovery/sensors/fanspeeds/netonix.inc.php b/includes/discovery/sensors/fanspeeds/netonix.inc.php new file mode 100644 index 0000000000..0a4a942d86 --- /dev/null +++ b/includes/discovery/sensors/fanspeeds/netonix.inc.php @@ -0,0 +1,17 @@ + $entry) { + if (is_numeric($entry['fanSpeed']) && is_numeric($index)) { + $descr = $index; + $oid = '.1.3.6.1.4.1.46242.2.1.2.'.$index; + $current = $entry['fanSpeed']; + discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $device['os'], $descr, '1', '1', null, null, null, null, $current); + } + } + } +}//end if diff --git a/includes/discovery/sensors/temperatures/netonix.inc.php b/includes/discovery/sensors/temperatures/netonix.inc.php new file mode 100644 index 0000000000..fbaf910eca --- /dev/null +++ b/includes/discovery/sensors/temperatures/netonix.inc.php @@ -0,0 +1,17 @@ + $entry) { + if (is_numeric($entry['temp']) && is_numeric($index) && $entry['temp'] > '0') { + $descr = $entry['tempDescription']; + $oid = '.1.3.6.1.4.1.46242.3.1.3.'.$index; + $current = $entry['temp']; + discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $device['os'], $descr, '1', '1', null, null, null, null, $current); + } + } + } +}//end if diff --git a/includes/discovery/sensors/voltages/netonix.inc.php b/includes/discovery/sensors/voltages/netonix.inc.php new file mode 100644 index 0000000000..f800df6e9a --- /dev/null +++ b/includes/discovery/sensors/voltages/netonix.inc.php @@ -0,0 +1,18 @@ + $entry) { + if (is_numeric($entry['voltage']) && is_numeric($index) && $entry['voltage'] > '0') { + $descr = $entry['voltageDescription']; + $oid = '.1.3.6.1.4.1.46242.4.1.3.'.$index; + $current = $entry['voltage']; + $divisor = 100; + discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $device['os'], $descr, $divisor, '1', null, null, null, null, $current); + } + } + } +}//end if From f45bceecba55821e6f4dbaea0d593410ea9bfeb6 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Feb 2016 13:36:44 -0600 Subject: [PATCH 23/25] The fanspeed is frequently 0 rpm. --- includes/discovery/sensors/fanspeeds/netonix.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/sensors/fanspeeds/netonix.inc.php b/includes/discovery/sensors/fanspeeds/netonix.inc.php index 0a4a942d86..b2882d0b58 100644 --- a/includes/discovery/sensors/fanspeeds/netonix.inc.php +++ b/includes/discovery/sensors/fanspeeds/netonix.inc.php @@ -10,7 +10,7 @@ if ($device['os'] == 'netonix') { $descr = $index; $oid = '.1.3.6.1.4.1.46242.2.1.2.'.$index; $current = $entry['fanSpeed']; - discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $device['os'], $descr, '1', '1', null, null, null, null, $current); + discover_sensor($valid['sensor'], 'fanspeed', $device, $oid, $index, $device['os'], $descr, '1', '1', '0', '0', null, null, $current); } } } From e3ec42c06d5aaa4fb632d89c9eff46eda4eca95b Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Feb 2016 14:20:36 -0600 Subject: [PATCH 24/25] Deal with 0 value for sensor data better. Issue #2883 --- html/pages/device/overview/generic/sensor.inc.php | 2 +- includes/polling/functions.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/html/pages/device/overview/generic/sensor.inc.php b/html/pages/device/overview/generic/sensor.inc.php index ef4288e7c8..c93660b6fe 100644 --- a/html/pages/device/overview/generic/sensor.inc.php +++ b/html/pages/device/overview/generic/sensor.inc.php @@ -12,7 +12,7 @@ if (count($sensors)) { echo ' '; foreach ($sensors as $sensor) { - if (empty($sensor['sensor_current'])) { + if (!isset($sensor['sensor_current'])) { $sensor['sensor_current'] = 'NaN'; } diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index d1fcf196e3..fdd9aa3d73 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -83,7 +83,7 @@ function poll_sensor($device, $class, $unit) { $sensor_value = 0; } - if ($sensor['sensor_divisor']) { + if ($sensor['sensor_divisor'] && $sensor_value !== 0) { $sensor_value = ($sensor_value / $sensor['sensor_divisor']); } From 8849cee3f4d0f444190f30f8ec2df84d65c62326 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 9 Feb 2016 15:42:46 -0600 Subject: [PATCH 25/25] Missed this while fixing sensor data with 0 values. --- html/includes/table/sensors.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/includes/table/sensors.inc.php b/html/includes/table/sensors.inc.php index 62fd73b64f..5bf9641936 100644 --- a/html/includes/table/sensors.inc.php +++ b/html/includes/table/sensors.inc.php @@ -47,7 +47,7 @@ if ($rowCount != -1) { $sql = "SELECT * $sql"; foreach (dbFetchRows($sql, $param) as $sensor) { - if (empty($sensor['sensor_current'])) { + if (!isset($sensor['sensor_current'])) { $sensor['sensor_current'] = 'NaN'; } else {