From 821a797ac90602fd03290b7879c17bdf0933af65 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 16 Dec 2015 20:56:58 +0000 Subject: [PATCH 01/27] Moved system polling module to core to centralise some snmpget calls --- doc/Support/Poller Support.md | 1 - includes/defaults.inc.php | 1 - includes/polling/core.inc.php | 124 +++++++++++++++++ includes/polling/functions.inc.php | 3 + includes/polling/os/avaya-ers.inc.php | 4 +- includes/polling/os/datacom.inc.php | 2 +- includes/polling/os/dlink.inc.php | 2 +- includes/polling/os/engenius.inc.php | 4 +- includes/polling/os/ibmnos.inc.php | 2 +- includes/polling/os/infinity.inc.php | 2 +- includes/polling/os/merakimr.inc.php | 2 +- includes/polling/os/merakims.inc.php | 2 +- includes/polling/os/merakimx.inc.php | 2 +- includes/polling/os/pbn.inc.php | 2 +- includes/polling/os/pulse.inc.php | 2 +- includes/polling/os/vyatta.inc.php | 2 +- .../polling/processors/powerconnect.inc.php | 2 +- includes/polling/system.inc.php | 125 ------------------ 18 files changed, 142 insertions(+), 142 deletions(-) create mode 100644 includes/polling/core.inc.php diff --git a/doc/Support/Poller Support.md b/doc/Support/Poller Support.md index 616698630..ad99c4219 100644 --- a/doc/Support/Poller Support.md +++ b/doc/Support/Poller Support.md @@ -39,7 +39,6 @@ disable it for one device then you can do this within the WebUI -> Settings -> M ```php $config['poller_modules']['unix-agent'] = 0; -$config['poller_modules']['system'] = 1; $config['poller_modules']['os'] = 1; $config['poller_modules']['ipmi'] = 1; $config['poller_modules']['sensors'] = 1; diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 407402746..7e820d111 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -662,7 +662,6 @@ $config['warn']['ifdown'] = true; // List of poller modules. Need to be in the array to be // considered for execution. $config['poller_modules']['unix-agent'] = 0; -$config['poller_modules']['system'] = 1; $config['poller_modules']['os'] = 1; $config['poller_modules']['ipmi'] = 1; $config['poller_modules']['sensors'] = 1; diff --git a/includes/polling/core.inc.php b/includes/polling/core.inc.php new file mode 100644 index 000000000..b7d3af08b --- /dev/null +++ b/includes/polling/core.inc.php @@ -0,0 +1,124 @@ + $uptime && is_numeric($snmp_uptime)) { + $uptime = $snmp_uptime; + d_echo('hrSystemUptime or sysUpTime looks like to have rolled, using snmpEngineTime instead'); +} + +if (is_numeric($uptime)) { + if ($uptime < $device['uptime']) { + log_event('Device rebooted after '.formatUptime($device['uptime']), $device, 'reboot', $device['uptime']); + } + + $uptime_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/uptime.rrd'; + + if (!is_file($uptime_rrd)) { + rrdtool_create($uptime_rrd, 'DS:uptime:GAUGE:600:0:U '.$config['rrd_rra']); + } + + $fields = array( + 'uptime' => $uptime, + ); + + rrdtool_update($uptime_rrd, $fields); + + $graphs['uptime'] = true; + + echo 'Uptime: '.formatUptime($uptime)."\n"; + + $update_array['uptime'] = $uptime; +}//end if + +$poll_device['sysLocation'] = str_replace('"', '', $poll_device['sysLocation']); + +// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS +$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'])) { + $poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']); +} + +$poll_device['sysContact'] = str_replace('"', '', $poll_device['sysContact']); + +// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS +$poll_device['sysContact'] = trim($poll_device['sysContact'], '\\'); + + +foreach (array('sysLocation', 'sysContact') as $elem) { + if ($poll_device[$elem] == 'not set') { + $poll_device[$elem] = ''; + } +} + +// Save results of various polled values to the database +foreach (array('sysContact', 'sysObjectID', 'sysName', 'sysDescr') as $elem) { + if ($poll_device[$elem] && $poll_device[$elem] != $device[$elem]) { + $update_array[$elem] = $poll_device[$elem]; + log_event("$elem -> ".$poll_device[$elem], $device, 'system'); + } +} + +if ($poll_device['sysLocation'] && $device['location'] != $poll_device['sysLocation'] && $device['override_sysLocation'] == 0) { + $update_array['location'] = $poll_device['sysLocation']; + log_event('Location -> '.$poll_device['sysLocation'], $device, 'system'); +} + +if ($config['geoloc']['latlng'] === true) { + location_to_latlng($device); +} diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 72332250e..501c8dd78 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -201,6 +201,9 @@ function poll_device($device, $options) { $graphs = array(); $oldgraphs = array(); + // we always want the core module to be included + include 'includes/polling/core.inc.php'; + if ($options['m']) { foreach (explode(',', $options['m']) as $module) { if (is_file('includes/polling/'.$module.'.inc.php')) { diff --git a/includes/polling/os/avaya-ers.inc.php b/includes/polling/os/avaya-ers.inc.php index 163c82c18..97afaab5b 100644 --- a/includes/polling/os/avaya-ers.inc.php +++ b/includes/polling/os/avaya-ers.inc.php @@ -2,7 +2,7 @@ echo 'Doing Nortel/Avaya ERS '; -$sysObjectID = snmp_get($device, 'sysObjectID.0', '-Oqvn'); +$sysObjectID = $poll_device['sysObjectID']; // Try multiple ways of getting firmware version $version = snmp_get($device, 'SNMPv2-SMI::enterprises.2272.1.1.7.0', '-Oqvn'); @@ -17,7 +17,7 @@ if ($version == '') { } // Get hardware details -$sysDescr = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Oqvn'); +$sysDescr = $poll_device['sysDescr']; $details = explode(' ', $sysDescr); $details = str_replace('ERS-', 'Ethernet Routing Switch ', $details); diff --git a/includes/polling/os/datacom.inc.php b/includes/polling/os/datacom.inc.php index 9d2d5aea3..ebf0bf538 100644 --- a/includes/polling/os/datacom.inc.php +++ b/includes/polling/os/datacom.inc.php @@ -1,5 +1,5 @@ $uptime && is_numeric($snmp_uptime)) { - $uptime = $snmp_uptime; - d_echo('hrSystemUptime or sysUpTime looks like to have rolled, using snmpEngineTime instead'); -} - -if (is_numeric($uptime)) { - if ($uptime < $device['uptime']) { - log_event('Device rebooted after '.formatUptime($device['uptime']), $device, 'reboot', $device['uptime']); - } - - $uptime_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/uptime.rrd'; - - if (!is_file($uptime_rrd)) { - rrdtool_create($uptime_rrd, 'DS:uptime:GAUGE:600:0:U '.$config['rrd_rra']); - } - - $fields = array( - 'uptime' => $uptime, - ); - - rrdtool_update($uptime_rrd, $fields); - - $graphs['uptime'] = true; - - echo 'Uptime: '.formatUptime($uptime)."\n"; - - $update_array['uptime'] = $uptime; -}//end if - -$poll_device['sysLocation'] = str_replace('"', '', $poll_device['sysLocation']); - -// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS -$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'])) { - $poll_device['sysLocation'] = rewrite_location($poll_device['sysLocation']); -} - -$poll_device['sysContact'] = str_replace('"', '', $poll_device['sysContact']); - -// Remove leading & trailing backslashes added by VyOS/Vyatta/EdgeOS -$poll_device['sysContact'] = trim($poll_device['sysContact'], '\\'); - - -foreach (array('sysLocation', 'sysContact') as $elem) { - if ($poll_device[$elem] == 'not set') { - $poll_device[$elem] = ''; - } -} - -// Save results of various polled values to the database -foreach (array('sysContact', 'sysObjectID', 'sysName', 'sysDescr') as $elem) { - if ($poll_device[$elem] && $poll_device[$elem] != $device[$elem]) { - $update_array[$elem] = $poll_device[$elem]; - log_event("$elem -> ".$poll_device[$elem], $device, 'system'); - } -} - -if ($poll_device['sysLocation'] && $device['location'] != $poll_device['sysLocation'] && $device['override_sysLocation'] == 0) { - $update_array['location'] = $poll_device['sysLocation']; - log_event('Location -> '.$poll_device['sysLocation'], $device, 'system'); -} - -if ($config['geoloc']['latlng'] === true) { - location_to_latlng($device); -} From 93e76a2b5a878bf1d883a30dfaeeb4c689c9d702 Mon Sep 17 00:00:00 2001 From: Jurrian van Iersel Date: Sat, 9 Jan 2016 14:20:57 +0100 Subject: [PATCH 02/27] Added username support for libvirt over SSH --- doc/Support/Configuration.md | 1 + includes/defaults.inc.php | 2 ++ includes/discovery/libvirt-vminfo.inc.php | 11 ++++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index c3ae17adf..3dca0c8ec 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -488,6 +488,7 @@ This array can be used to filter out syslog messages that you don't want to be s ```php $config['enable_libvirt'] = 1; $config['libvirt_protocols'] = array("qemu+ssh","xen+ssh"); +$config['libvirt_username'] = 'root'; ``` Enable this to switch on support for libvirt along with `libvirt_protocols` to indicate how you connect to libvirt. You also need to: diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index f16e58487..5dd4c7226 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -640,6 +640,8 @@ $config['libvirt_protocols'] = array( 'qemu+ssh', 'xen+ssh', ); +// Use different username for libvirt over SSH +$config['libvirt_username'] = null; // Mechanisms used, add or remove if not using this on any of your machines. // Hardcoded ASN descriptions $config['astext'][65332] = 'Cymru FullBogon Feed'; diff --git a/includes/discovery/libvirt-vminfo.inc.php b/includes/discovery/libvirt-vminfo.inc.php index 8825bf7b4..9c3ae45cb 100644 --- a/includes/discovery/libvirt-vminfo.inc.php +++ b/includes/discovery/libvirt-vminfo.inc.php @@ -9,18 +9,23 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') { $ssh_ok = 0; + $userHostname = $device['hostname']; + if (!is_null($config['libvirt_username'])) { + $userHostname = $config['libvirt_username'].'@'.$userHostname; + } + foreach ($config['libvirt_protocols'] as $method) { if (strstr($method, 'qemu')) { - $uri = $method.'://'.$device['hostname'].'/system'; + $uri = $method.'://'.$userHostname.'/system'; } else { - $uri = $method.'://'.$device['hostname']; + $uri = $method.'://'.$userHostname; } if (strstr($method, 'ssh') && !$ssh_ok) { // Check if we are using SSH if we can log in without password - without blocking the discovery // Also automatically add the host key so discovery doesn't block on the yes/no question, and run echo so we don't get stuck in a remote shell ;-) - exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$device['hostname'].' echo -e', $out, $ret); + exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$userHostname.' echo -e', $out, $ret); if ($ret != 255) { $ssh_ok = 1; } From 31243b2acf8fca79cbf2594e5d947e36aee0f46e Mon Sep 17 00:00:00 2001 From: Jurrian van Iersel Date: Sat, 9 Jan 2016 14:38:37 +0100 Subject: [PATCH 03/27] 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 0945ba8ec..83929477a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -78,6 +78,7 @@ LibreNMS contributors: - D. Britz (flatterlight) - Tobias Herrmann (Mightea) - Nicolas Guillaumin (nguillaumin) +- Jurrian van Iersel (jviersel) [1]: http://observium.org/ "Observium web site" Observium was written by: From 31bb1f6ff4c90a6607e5071ef7dd1016a4d10892 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 14 Jan 2016 13:38:10 +1000 Subject: [PATCH 04/27] MIB-based polling: attempt to support more SNMP counter types --- doc/Extensions/MIB-based-polling.md | 5 +++-- includes/snmp.inc.php | 13 +++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index 8358c44e7..0909aacfb 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -69,8 +69,9 @@ The components involved in MIB-based polling are: - During discovery, relevant MIBs are parsed using `snmptranslate`, and the data returned is used to populate a database which guides the poller in - what to store. At the moment, only OIDs with Unsigned32 and Counter64 - data types are parsed. + what to store. At the moment, only OIDs of INTEGER, Integer32, Unsigned32, + Counter32, and Counter64 data types are parsed, and negative values are + untested. - Devices may be excluded from MIB polling by changing the setting in the device edit screen: diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 6d1c32238..45e483a48 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -1040,22 +1040,19 @@ function oid_rrd_type($oid, $mibdef) case 'INTEGER': case 'Integer32': - // FIXME - return false; + return 'GAUGE:600:U:U'; case 'Counter32': - // FIXME - return false; - case 'Counter64': return 'COUNTER:600:0:U'; + case 'Gauge32': case 'Unsigned32': - return 'GAUGE:600:U:U'; + return 'GAUGE:600:0:U'; + } return false; - } // oid_rrd_type @@ -1124,7 +1121,7 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs) foreach ($oids as $index => $array) { foreach ($array as $obj => $val) { // build up the device_oid row for saving into the database - $numvalue = preg_match('/^\d+$/', $val) ? $val : null; + $numvalue = is_numeric($val) ? $val + 0 : 0; $deviceoids[] = array( 'device_id' => $device['device_id'], 'oid' => $mibdef[$obj]['oid'].".".$index, From 1baeb36e12c75222a7131be3680753e41fdf8d60 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 14 Jan 2016 13:40:37 +1000 Subject: [PATCH 05/27] Add Gauge32 --- doc/Extensions/MIB-based-polling.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index 0909aacfb..d23d207dd 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -69,9 +69,9 @@ The components involved in MIB-based polling are: - During discovery, relevant MIBs are parsed using `snmptranslate`, and the data returned is used to populate a database which guides the poller in - what to store. At the moment, only OIDs of INTEGER, Integer32, Unsigned32, - Counter32, and Counter64 data types are parsed, and negative values are - untested. + what to store. At the moment, only OIDs of INTEGER, Integer32, Gauge32, + Unsigned32, Counter32, and Counter64 data types are parsed, and negative + values are untested. - Devices may be excluded from MIB polling by changing the setting in the device edit screen: From 62cd6e8e7a0905edcddfe9af7b108f2c651a30ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Birger=20J=2E=20Nord=C3=B8lum?= Date: Mon, 11 Jan 2016 10:54:14 +0100 Subject: [PATCH 06/27] Tweaked .gitignore --- .gitignore | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 8c57c5ce4..0a6dbb3cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,21 @@ +# Ignore all dotfiles # +####################### +.* +!/.gitignore +!/.editorconfig +!/.scrutinizer.yml + + +# Others # +########## +*.swp +Thumbs.db config.php -.index -junk -logs -patches -rrd html/plugins/* !html/plugins/Test/ +junk +logs nbproject -.alerts.lock -.ircbot.alert -.metadata_never_index -*.swp +patches +rrd -# OS generated files # -###################### -.DS_Store -.DS_Store? -.Spotlight-V100 -.Trashes -Thumbs.db From 0d15244c2e092f24f2bc7b956c58434acab67920 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Thu, 14 Jan 2016 19:05:39 +0100 Subject: [PATCH 07/27] Fix Cisco Temp Disco MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Existing disco was broken and did not work on the install’s I tested on. --- .../temperatures/cisco-envmon.inc.php | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/includes/discovery/temperatures/cisco-envmon.inc.php b/includes/discovery/temperatures/cisco-envmon.inc.php index 15b7577aa..74408318d 100644 --- a/includes/discovery/temperatures/cisco-envmon.inc.php +++ b/includes/discovery/temperatures/cisco-envmon.inc.php @@ -1,31 +1,22 @@ + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ -// FIXME - dbFacile and fewer SNMP_GETs -if (dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ? AND `sensor_class` = 'temperature' AND (`sensor_type` = 'cisco-entity-sensor' OR `sensor_type` = 'entity-sensor')", array($device['device_id'])) == '0' && ($device['os_group'] == 'cisco')) { - echo 'CISCO-ENVMON-MIB: '; - $oids = snmp_walk($device, '.1.3.6.1.4.1.9.9.13.1.3.1.2', '-Osqn', 'CISCO-ENVMON-MIB'); - $oids = str_replace('.1.3.6.1.4.1.9.9.13.1.3.1.2.', '', $oids); - $oids = trim($oids); - foreach (explode("\n", $oids) as $data) { - $data = trim($data); - if ($data) { - list($index) = explode(' ', $data); - $oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$index"; - $descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$index"; - $descr = snmp_get($device, $descr_oid, '-Oqv', 'CISCO-ENVMON-MIB'); - $temperature = snmp_get($device, $oid, '-Oqv', 'CISCO-ENVMON-MIB'); - if (!strstr($descr, 'No') && !strstr($temperature, 'No') && $temperature != '' && $descr != '') { - $descr = str_replace('"', '', $descr); - $descr = str_replace('temperature', '', $descr); - $descr = str_replace('temperature', '', $descr); - $descr = trim($descr); - - if (!is_numeric($temperature)) { - $temperature = stristr($temperature, ' degrees', true); - } - - discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, 'cisco', $descr, '1', '1', null, null, null, null, $temperature); - } +if ($device['os_group'] == 'cisco') { + $temp = snmpwalk_cache_multi_oid($device, 'ciscoEnvMonTemperatureStatusTable', array(), 'CISCO-ENVMON-MIB'); + if (is_array($temp)) { + $cur_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.'; + foreach ($temp as $index => $entry) { + $descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']); + discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid.$index, $index, 'cisco', $descr, '1', '1', null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], null, $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index); } - }//end foreach -}//end if + } +} From 81cb935735e107eb62f927828de2c5b70dd8dab4 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 14 Jan 2016 20:09:18 +0100 Subject: [PATCH 08/27] Added polling of wifi clients for HP MSM --- includes/polling/wifi.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/polling/wifi.inc.php b/includes/polling/wifi.inc.php index 73d9c693e..30803f2a1 100644 --- a/includes/polling/wifi.inc.php +++ b/includes/polling/wifi.inc.php @@ -43,6 +43,12 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall' || $device['ty echo (($wificlients1 + 0).' clients on dot11Radio0, '.($wificlients2 + 0)." clients on dot11Radio1\n"); } + if ($device['os'] == 'hpmsm') { + echo 'Checking HP MSM Wireless clients... '; + $wificlients1 = snmp_get($device, '.1.3.6.1.4.1.8744.5.25.1.7.2.0', '-OUqnv'); + echo $wificlients1." clients\n"; + } + // MikroTik RouterOS if ($device['os'] == 'routeros') { // Check inventory for wireless card in device. Valid types be here: From a8b476d58f966f313e4fb86bf166422b0228ac68 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Thu, 14 Jan 2016 21:20:38 +0100 Subject: [PATCH 09/27] Added support for hardware, serial, firmware for HP MSM --- includes/polling/os/hpmsm.inc.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 includes/polling/os/hpmsm.inc.php diff --git a/includes/polling/os/hpmsm.inc.php b/includes/polling/os/hpmsm.inc.php new file mode 100644 index 000000000..9d41c038a --- /dev/null +++ b/includes/polling/os/hpmsm.inc.php @@ -0,0 +1,17 @@ + + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. Please see LICENSE.txt at the top level of + * the source code distribution for details. + */ + +$sysdescr = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Ovq'); +preg_match_all('/^(MSM\d{3})|Serial number ([\S]+)|Firmware version (\d+\.\d+\.\d+\.\d+-\d+)/', $sysdescr, $matches); +$hardware = $matches[1][0]; +$serial = $matches[2][1]; +$version = $matches[3][2]; From 6f06b74f433b677154a1bccdd255922c2bb65a37 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Fri, 15 Jan 2016 12:06:28 +0100 Subject: [PATCH 10/27] Use the sysDescr we've already polled in the core module --- includes/polling/os/hpmsm.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/polling/os/hpmsm.inc.php b/includes/polling/os/hpmsm.inc.php index 9d41c038a..585db128c 100644 --- a/includes/polling/os/hpmsm.inc.php +++ b/includes/polling/os/hpmsm.inc.php @@ -10,8 +10,7 @@ * the source code distribution for details. */ -$sysdescr = snmp_get($device, 'SNMPv2-MIB::sysDescr.0', '-Ovq'); -preg_match_all('/^(MSM\d{3})|Serial number ([\S]+)|Firmware version (\d+\.\d+\.\d+\.\d+-\d+)/', $sysdescr, $matches); +preg_match_all('/^(MSM\d{3})|Serial number ([\S]+)|Firmware version (\d+\.\d+\.\d+\.\d+-\d+)/', $poll_device['sysDescr'], $matches); $hardware = $matches[1][0]; $serial = $matches[2][1]; $version = $matches[3][2]; From 94ab3141f8785258d0dca9d06a557261792324b2 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 15 Jan 2016 10:32:48 -0600 Subject: [PATCH 11/27] Clarify Oxidized Groups Documentation Break groups out into their own section. Show how to specify credentials for groups in Oxidized. Issue #2464 --- doc/Extensions/Oxidized.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index 6bb7c2bf4..de0170013 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -31,14 +31,6 @@ You can set a default group that devices will fall back to with: $config['oxidized']['default_group'] = 'default'; ``` -To return a group to Oxidized you can do this by matching a regex for either hostname or location. The order is hostname is matched first, if nothing is found then location is attempted. -The first match found will be used. To match on the device hostnames that contain 'lon-sw' or if the location contains 'London' then you would place the following within config.php: - -```php -$config['oxidized']['group']['hostname'][] = array('regex' => '/^lon-sw/', 'group' => 'london-switches'); -$config['oxidized']['group']['location'][] = array('regex' => '/london/', 'group' => 'london-switches'); -``` - ### Feeding Oxidized Oxidized has support for feeding devices into it via an API call, support for Oxidized has been added to the LibreNMS API. A sample config for Oxidized is provided below. @@ -60,6 +52,27 @@ You will need to configure default credentials for your devices, LibreNMS doesn' X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed' ``` +### Using Groups + +To return a group to Oxidized you can do this by matching a regex for either hostname or location. The order is hostname is matched first, if nothing is found then location is attempted. +The first match found will be used. To match on the device hostnames that contain 'lon-sw' or if the location contains 'London' then you would place the following within config.php: + +```php +$config['oxidized']['group']['hostname'][] = array('regex' => '/^lon-sw/', 'group' => 'london-switches'); +$config['oxidized']['group']['location'][] = array('regex' => '/london/', 'group' => 'london-switches'); +``` + +If you need to, you can specify credentials for groups by using the following in your oxidized config: + +```bash +groups: + : + username: + password: +``` + +### Miscellaneous + If you have devices which you do not wish to appear in Oxidized then you can edit those devices in Device -> Edit -> Misc and enable "Exclude from Oxidized?" It's also possible to exclude certain device types and OS' from being output via the API. This is currently only possible via config.php: From 838e189cde4277199ad918431d08c58345660539 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Fri, 15 Jan 2016 21:37:12 +0100 Subject: [PATCH 12/27] Provide more alert rule examples #2506 --- doc/Extensions/Alerting.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/Extensions/Alerting.md b/doc/Extensions/Alerting.md index f9ff0951d..02d1958e9 100644 --- a/doc/Extensions/Alerting.md +++ b/doc/Extensions/Alerting.md @@ -81,6 +81,12 @@ Alert when: - Any port changes: `%ports.ifOperStatus != 'up'` - Root-directory gets too full: `%storage.storage_descr = '/' && %storage.storage_perc >= '75'` - Any storage gets fuller than the 'warning': `%storage.storage_perc >= %storage_perc_warn` +- If device is a server and the used storage is above the warning level, but ignore /boot partitions: `%storage.storage_perc > %storage.storage_perc_warn && %devices.type = "server" && %storage.storage_descr !~ "/boot"` +- VMware LAG is not using "Source ip address hash" load balancing: `%devices.os = "vmware" && %ports.ifType = "ieee8023adLag" && %ports.ifDescr !~ "Link Aggregation @, load balancing algorithm: Source ip address hash"` +- Syslog, authentication failure during the last 5m: `%syslog.timestamp >= %macros.past_5m && %syslog.msg ~ "@authentication failure@"` +- High memory usage: `%macros.device_up = "1" && %mempools.mempool_perc >= "90" && %mempools.mempool_descr = "Virtual@"` +- High CPU usage(per core usage, not overall): `%macros.device_up = "1" && %processors.processor_usage >= "90"` +- High port usage, where description is not client & ifType is not softwareLoopback: `%macros.port_usage_perc >= "80" && %port.port_descr_type != "client" && %ports.ifType != "softwareLoopback"` # Templates From 9c0854a5461e46b641d4bb3888d595c3e556a076 Mon Sep 17 00:00:00 2001 From: Mike Rostermund Date: Sat, 16 Jan 2016 13:58:47 +0100 Subject: [PATCH 13/27] Added group mapping in sample config for Oxidized for groups --- doc/Extensions/Oxidized.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index de0170013..aa8ca5113 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -48,6 +48,7 @@ You will need to configure default credentials for your devices, LibreNMS doesn' map: name: hostname model: os + group: group headers: X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed' ``` @@ -62,7 +63,7 @@ $config['oxidized']['group']['hostname'][] = array('regex' => '/^lon-sw/', 'grou $config['oxidized']['group']['location'][] = array('regex' => '/london/', 'group' => 'london-switches'); ``` -If you need to, you can specify credentials for groups by using the following in your oxidized config: +If you need to, you can specify credentials for groups by using the following in your Oxidized config: ```bash groups: From 2a097dd8037ece915a62f44e51827d88bcc5d09f Mon Sep 17 00:00:00 2001 From: laf Date: Sat, 16 Jan 2016 20:02:42 +0000 Subject: [PATCH 14/27] Fix uptime issues for devices that fail with additional uptime snmp queries --- includes/polling/core.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/polling/core.inc.php b/includes/polling/core.inc.php index aa48a0832..c6f5399a4 100644 --- a/includes/polling/core.inc.php +++ b/includes/polling/core.inc.php @@ -14,7 +14,7 @@ unset($poll_device); -$snmpdata = snmp_get_multi($device, 'sysUpTime.0 sysLocation.0 sysContact.0 sysName.0 sysDescr.0 sysObjectID.0 snmpEngineTime.0 hrSystemUptime.0', '-OQnUs', 'SNMPv2-MIB:HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB'); +$snmpdata = snmp_get_multi($device, 'sysUpTime.0 sysLocation.0 sysContact.0 sysName.0 sysDescr.0 sysObjectID.0', '-OQnUs', 'SNMPv2-MIB:HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB'); $poll_device = $snmpdata[0]; $poll_device['sysName'] = strtolower($poll_device['sysName']); @@ -25,8 +25,10 @@ if (!empty($agent_data['uptime'])) { } if (empty($uptime)) { - $snmp_uptime = (integer) $poll_device['snmpEngineTime']; - $hrSystemUptime = $poll_device['hrSystemUptime']; + $snmp_data = snmp_get_multi($device, 'snmpEngineTime.0 hrSystemUptime.0', '-OQnUs', 'HOST-RESOURCES-MIB:SNMP-FRAMEWORK-MIB'); + $uptime_data = $snmp_data[0]; + $snmp_uptime = (integer) $uptime_data['snmpEngineTime']; + $hrSystemUptime = $uptime_data['hrSystemUptime']; if (!empty($hrSystemUptime) && !strpos($hrSystemUptime, 'No') && ($device['os'] != 'windows')) { echo 'Using hrSystemUptime ('.$hrSystemUptime.")\n"; $agent_uptime = $uptime; From 771fc342fde2e2d4a904d545fd36c9703125ec0c Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 17 Jan 2016 12:13:45 +1000 Subject: [PATCH 15/27] Clear $graph_array after graph is printed --- html/includes/print-graphrow.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/includes/print-graphrow.inc.php b/html/includes/print-graphrow.inc.php index 9b98a8039..a35107b94 100644 --- a/html/includes/print-graphrow.inc.php +++ b/html/includes/print-graphrow.inc.php @@ -76,3 +76,4 @@ foreach ($periods as $period) { echo ""; } } +unset($graph_array); From a11cc7c021d9674e24b0fe9bcdfa991bd9b26b4c Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 17 Jan 2016 12:35:10 +1000 Subject: [PATCH 16/27] Add CISCO-AAA-SESSION-MIB from ftp://ftp.cisco.com/pub/mibs/v2/CISCO-AAA-SESSION-MIB.my --- mibs/CISCO-AAA-SESSION-MIB | 494 +++++++++++++++++++++++++++++++++++++ 1 file changed, 494 insertions(+) create mode 100644 mibs/CISCO-AAA-SESSION-MIB diff --git a/mibs/CISCO-AAA-SESSION-MIB b/mibs/CISCO-AAA-SESSION-MIB new file mode 100644 index 000000000..fc947a267 --- /dev/null +++ b/mibs/CISCO-AAA-SESSION-MIB @@ -0,0 +1,494 @@ +-- ***************************************************************** +-- CISCO-AAA-SESSION-MIB.my: Cisco AAA Session MIB +-- +-- November 1999, Ed Richardson +-- +-- Copyright (c) 1999, 2000, 2002, 2006 by cisco Systems, Inc. +-- All rights reserved. +-- ***************************************************************** +-- + + +CISCO-AAA-SESSION-MIB DEFINITIONS ::= BEGIN + +IMPORTS + MODULE-IDENTITY, + OBJECT-TYPE, + Counter32, + Gauge32, + IpAddress, + Unsigned32 + FROM SNMPv2-SMI + MODULE-COMPLIANCE, + OBJECT-GROUP + FROM SNMPv2-CONF + DisplayString, + TruthValue, + TEXTUAL-CONVENTION, + RowPointer + FROM SNMPv2-TC + InterfaceIndexOrZero + FROM IF-MIB + ciscoMgmt + FROM CISCO-SMI; + + +ciscoAAASessionMIB MODULE-IDENTITY + LAST-UPDATED "200603210000Z" + ORGANIZATION "Cisco Systems, Inc." + CONTACT-INFO + " Cisco Systems + Customer Service + + Postal: 170 W. Tasman Drive + San Jose, CA 95134 + USA + + Tel: +1 800 553-NETS + + E-mail: cs-aaa@cisco.com" + DESCRIPTION + "This MIB module provides data for accounting sessions + based on Authentication, Authorization, Accounting + (AAA) protocols. + + + References: + RFC 2139 RADIUS Accounting + The TACACS+ Protocol Version 1.78, Internet Draft + + + " + REVISION "200603210000Z" + DESCRIPTION + "Added the casnNasPort and casnVaiIfIndex objects to the + casnActiveTable. + " + REVISION "200204110000Z" + DESCRIPTION + "Imported Unsigned32 from SNMPv2-SMI instead of CISCO-TC + " + REVISION "9911160000Z" + DESCRIPTION + "Initial version + " + ::= { ciscoMgmt 150 } + + +-- +-- Textual Conventions +-- + +-- +-- Call Identifier textual convention +-- +CctCallId ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "Represents a Call Identifier. + The call identifier is used as an unique identifier for an + call within the system. + + A zero value indicates no call ID. + " + SYNTAX Unsigned32 + + + +-- +-- Session Identifier textual convention +-- +CasnSessionId ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "Represents an Accounting Session Identifier. + The session identifier is used as an unique identifier for + a session within the system. + " + SYNTAX Unsigned32 (1..4294967295) + + + +-- AAA Session MIB objects definitions + +casnMIBObjects OBJECT IDENTIFIER ::= { ciscoAAASessionMIB 1 } + + +-- The AAA Session MIB consists of the following groups +-- [1] AAA Session Active Group (casnActive) +-- [2] AAA Session General Group (casnGeneral) + +casnActive OBJECT IDENTIFIER ::= { casnMIBObjects 1 } +casnGeneral OBJECT IDENTIFIER ::= { casnMIBObjects 2 } + + + +--********************************************************************** +-- AAA Session Active Group +--********************************************************************** +-- +-- + +-- +-- Active Table +-- + +casnActiveTableEntries OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Number of entries currently in casnActiveTable + " + ::= { casnActive 1 } + + +casnActiveTableHighWaterMark OBJECT-TYPE + SYNTAX Gauge32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Maximum number of entries present in casnActiveTable + since last system re-initialization. + + This corresponds to the maximum value reported by + casnActiveTableEntries. + " + ::= { casnActive 2 } + + +casnActiveTable OBJECT-TYPE + SYNTAX SEQUENCE OF CasnActiveEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This table contains entries for active AAA accounting + sessions in the system. + " + ::= { casnActive 3 } + +casnActiveEntry OBJECT-TYPE + SYNTAX CasnActiveEntry + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The information regarding a single accounting session. + + Entries are created when a new accounting session + is begun. + + Entries are removed when the accounting session + is ended. + + Initiating termination of a session with the object + casnDisconnect will cause removal of the entry when + the session completes termination. + " + INDEX { casnSessionId } + ::= { casnActiveTable 1 } + + +CasnActiveEntry ::= + SEQUENCE { + casnSessionId CasnSessionId, + casnUserId DisplayString, + casnIpAddr IpAddress, + casnIdleTime Gauge32, + casnDisconnect TruthValue, + casnCallTrackerId CctCallId, + casnNasPort RowPointer, + casnVaiIfIndex InterfaceIndexOrZero + } + + +casnSessionId OBJECT-TYPE + SYNTAX CasnSessionId + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "This is the session identification used by the + accounting protocol. + + This value is unique to a session within the system, + even if multiple accounting protocols are in use. + + The value of this object corresponds to these + accounting protocol attributes. + RADIUS: attribute 44, Acct-Session-Id + TACACS+: attribute 'task_id' + " + ::= { casnActiveEntry 1 } + + +casnUserId OBJECT-TYPE + SYNTAX DisplayString(SIZE(0..255)) + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The User login ID or zero length string if unavailable. + + The value of this object corresponds to these + accounting protocol attributes. + RADIUS: attribute 1, User-Name + TACACS+: attribute 'user' + " + ::= { casnActiveEntry 2 } + + +casnIpAddr OBJECT-TYPE + SYNTAX IpAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The IP address of the session or 0.0.0.0 if not + applicable or unavailable. + + RADIUS: attribute 8, Framed-IP-Address + TACACS+: attribute 'addr' + " + ::= { casnActiveEntry 3 } + + +casnIdleTime OBJECT-TYPE + SYNTAX Gauge32 + UNITS "seconds" + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The elapsed time that this session has been idle. + + This is the time since the last user-level data has been + received or transmitted. Protocol level handshaking + associated with the call is considered to be idle for + this object. + " + ::= { casnActiveEntry 4 } + + +casnDisconnect OBJECT-TYPE + SYNTAX TruthValue + MAX-ACCESS read-write + STATUS current + DESCRIPTION + "This object is used to terminate this session. + + Setting the value to true(1) will initiate termination + of this session. + + The entry will be removed once the session has completed + termination. + + Once this object has been set to true(1), the session + termination process can not be cancelled by setting the + value false(2). + " + ::= { casnActiveEntry 5 } + + +casnCallTrackerId OBJECT-TYPE + SYNTAX CctCallId + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of this object is the entry index in the + CISCO-CALL-TRACKER-MIB cctActiveTable of the call + corresponding to this accounting session. + + Using the value of this object to query the + cctActiveTable will provide more detailed data regarding + the session represented by this casnActiveEntry. + " + ::= { casnActiveEntry 6 } + + +casnNasPort OBJECT-TYPE + SYNTAX RowPointer + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The value of this object identifies a particular + conceptual row associated with the session identified by + casnSessionId. The conceptual row that this object points + to represents a port that is used to transport a session. + + If the port transporting the session cannot be determined, + the value of this object will be zeroDotZero. + + For example, suppose a session is established using an ATM + PVC. If the ifIndex of the ATM interface is 7, and the + VPI/VCI values of the PVC are 1, 100 respectively, then + the value of this object might be as follows: + + casnNasPort.15 = atmVclAdminStatus.7.1.100 + ^ ^ ^ ^ + | | | | + casnSessionId --+ | | | + ifIndex -------------------------+ | | + atmVclVpi ---------------------------+ | + atmVclVci ------------------------------+ + + where atmVclAdminStatus is the first accessible object + of the atmVclTable of the ATM-MIB. + " + ::= { casnActiveEntry 7 } + + +casnVaiIfIndex OBJECT-TYPE + SYNTAX InterfaceIndexOrZero + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The ifIndex of the Virtual Access Interface (VAI) + that is associated with the PPP session. + + This interface may not be represented in the IF-MIB in + which case the value of this object will be zero. + " + ::= { casnActiveEntry 8 } + + + +--********************************************************************** +-- AAA Session General Group +--********************************************************************** +-- +-- + +casnTotalSessions OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total number of sessions since last system + re-initialization. + + This value includes all sessions currently in the + casnActiveTable and all previous sessions whether + terminated via casnDisconnect or via other + mechanisms. + " + ::= { casnGeneral 1 } + + +casnDisconnectedSessions OBJECT-TYPE + SYNTAX Counter32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "Total number of sessions which have been disconnected using + casnDisconnect since last system re-initialization. + + This value includes any sessions still in the + casnActiveTable with a casnDisconnect value of true(1) and + all previous sessions which terminated as a result of + setting casnDisconnect. + " + ::= { casnGeneral 2 } + + + +--********************************************************************** +-- Notifications +--********************************************************************** +casnMIBNotificationPrefix OBJECT IDENTIFIER ::= + { ciscoAAASessionMIB 2 } +casnMIBNotifications OBJECT IDENTIFIER ::= + { casnMIBNotificationPrefix 1 } + + + +casnMIBConformance OBJECT IDENTIFIER ::= + { ciscoAAASessionMIB 3 } +casnMIBCompliances OBJECT IDENTIFIER ::= + { casnMIBConformance 1 } +casnMIBGroups OBJECT IDENTIFIER ::= + { casnMIBConformance 2 } + +-- compliance statements + +casnMIBCompliance MODULE-COMPLIANCE + STATUS deprecated + DESCRIPTION + "The compliance statement for entities which + implement the CISCO AAA Session MIB" + MODULE -- this module + MANDATORY-GROUPS + { casnActiveGroup, + casnGeneralGroup + } + + OBJECT casnDisconnect + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + + ::= { casnMIBCompliances 1 } + + +casnMIBComplianceRev1 MODULE-COMPLIANCE + STATUS current + DESCRIPTION + "The compliance statement for entities which + implement the CISCO AAA Session MIB" + MODULE -- this module + MANDATORY-GROUPS + { casnActiveGroup, + casnGeneralGroup, + casnActiveGroupSup1 + } + + OBJECT casnDisconnect + MIN-ACCESS read-only + DESCRIPTION + "Write access is not required." + + ::= { casnMIBCompliances 2 } + + + +-- units of conformance + + +casnActiveGroup OBJECT-GROUP + OBJECTS { + casnActiveTableEntries, + casnActiveTableHighWaterMark, + casnUserId, + casnIpAddr, + casnIdleTime, + casnDisconnect, + casnCallTrackerId + } + STATUS current + DESCRIPTION + "A collection of objects providing the + AAA session information. + " + ::= { casnMIBGroups 1 } + + +casnGeneralGroup OBJECT-GROUP + OBJECTS { + casnTotalSessions, + casnDisconnectedSessions + } + STATUS current + DESCRIPTION + "A collection of objects providing the + AAA session information. + " + ::= { casnMIBGroups 2 } + + +casnActiveGroupSup1 OBJECT-GROUP + OBJECTS { + casnNasPort, + casnVaiIfIndex + } + STATUS current + DESCRIPTION + "A collection of objects that supplements + the casnActiveGroup. + " + ::= { casnMIBGroups 3 } +END From 6baea97717f81e42e805f24ee40ac3d7ff8b0a61 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 17 Jan 2016 13:32:17 +1000 Subject: [PATCH 17/27] Poll CISCO-AAA-SESSION-MIB for IOS & RouterOS --- includes/discovery/os/ios.inc.php | 5 +++++ includes/discovery/os/routeros.inc.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/includes/discovery/os/ios.inc.php b/includes/discovery/os/ios.inc.php index 1cdaa1aa5..731d68bf0 100644 --- a/includes/discovery/os/ios.inc.php +++ b/includes/discovery/os/ios.inc.php @@ -21,6 +21,11 @@ if (empty($os)) { if (strstr($sysDescr, 'IOS XR')) { $os = 'iosxr'; } + + $extra_mibs = array( + "ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB", + ); + register_mibs($device, $extra_mibs, "includes/discovery/os/ios.inc.php"); } // Fallback case diff --git a/includes/discovery/os/routeros.inc.php b/includes/discovery/os/routeros.inc.php index 5e35eb7f7..a5e407cd5 100644 --- a/includes/discovery/os/routeros.inc.php +++ b/includes/discovery/os/routeros.inc.php @@ -18,4 +18,10 @@ if (!$os) { if ($sysDescr == 'RB260GS') { $os = 'routeros'; } + + // poll Cisco AAA MIB + $extra_mibs = array( + "ciscoAAASessionMIB" => "CISCO-AAA-SESSION-MIB", + ); + register_mibs($device, $extra_mibs, "includes/discovery/os/routeros.inc.php"); } From 9e9f5f787f63c4acacfd14ea0ff926f9ec9d111c Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 17 Jan 2016 13:57:34 +1000 Subject: [PATCH 18/27] Fix short name generation Should only replace first occurrence of prefix in the string. Also only strips the prefix if it saves more than 2 characters. This fixes a bug where, e.g., 'casnDisconnect' would be shortened to 'asnDisonnet'. --- includes/snmp.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 6d1c32238..d2f3c2323 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -1189,8 +1189,10 @@ function load_mibdefs($module, $name) // add shortname to each element $prefix = longest_matching_prefix($name, $object_types); - foreach ($result as $mib => $m) { - $result[$mib]['shortname'] = str_replace($prefix, '', $m['object_type']); + if (strlen($prefix) > 2) { + foreach ($result as $mib => $m) { + $result[$mib]['shortname'] = preg_replace("/^$prefix/", '', $m['object_type'], 1); + } } d_print_r($result); From fc6a4b7076321fb7c30750ae2c35a5a85f083241 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Sun, 17 Jan 2016 14:05:37 +1000 Subject: [PATCH 19/27] Include shortname in all cases --- includes/snmp.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index d2f3c2323..8a7cb8069 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -1189,10 +1189,13 @@ function load_mibdefs($module, $name) // add shortname to each element $prefix = longest_matching_prefix($name, $object_types); - if (strlen($prefix) > 2) { - foreach ($result as $mib => $m) { + foreach ($result as $mib => $m) { + if (strlen($prefix) > 2) { $result[$mib]['shortname'] = preg_replace("/^$prefix/", '', $m['object_type'], 1); } + else { + $result[$mib]['shortname'] = $m['object_type']; + } } d_print_r($result); From d0f0e055fb19c0661522367d36a94098ac9e56eb Mon Sep 17 00:00:00 2001 From: Jurrian van Iersel Date: Sun, 17 Jan 2016 15:42:03 +0100 Subject: [PATCH 20/27] Update defaults.inc.php --- includes/defaults.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 5dd4c7226..f16e58487 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -640,8 +640,6 @@ $config['libvirt_protocols'] = array( 'qemu+ssh', 'xen+ssh', ); -// Use different username for libvirt over SSH -$config['libvirt_username'] = null; // Mechanisms used, add or remove if not using this on any of your machines. // Hardcoded ASN descriptions $config['astext'][65332] = 'Cymru FullBogon Feed'; From a1c5a9dbeb50762c8b3283c167f146279e5cba27 Mon Sep 17 00:00:00 2001 From: Jurrian van Iersel Date: Sun, 17 Jan 2016 15:42:31 +0100 Subject: [PATCH 21/27] Update libvirt-vminfo.inc.php --- includes/discovery/libvirt-vminfo.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/discovery/libvirt-vminfo.inc.php b/includes/discovery/libvirt-vminfo.inc.php index 9c3ae45cb..aced6467c 100644 --- a/includes/discovery/libvirt-vminfo.inc.php +++ b/includes/discovery/libvirt-vminfo.inc.php @@ -10,7 +10,7 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') { $ssh_ok = 0; $userHostname = $device['hostname']; - if (!is_null($config['libvirt_username'])) { + if (isset($config['libvirt_username'])) { $userHostname = $config['libvirt_username'].'@'.$userHostname; } From b757f4023bfe242273e6b58cf328049539c96b10 Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 17 Jan 2016 15:46:33 +0000 Subject: [PATCH 22/27] Added missing column to perf_times table --- sql-schema/089.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 sql-schema/089.sql diff --git a/sql-schema/089.sql b/sql-schema/089.sql new file mode 100644 index 000000000..faeaea353 --- /dev/null +++ b/sql-schema/089.sql @@ -0,0 +1 @@ +ALTER TABLE `perf_times` ADD `poller` VARCHAR( 255 ) NOT NULL ; From 207ff3e006a079e2d4a9ea071ec06ff3e3016b90 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sun, 17 Jan 2016 16:50:45 +0100 Subject: [PATCH 23/27] Set device_type for PowerVault --- includes/definitions.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 5e30d2bd7..27b5284a5 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -772,11 +772,11 @@ $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'; -// $config['os'][$os]['over'][2]['graph'] = "device_mempool"; -// $config['os'][$os]['over'][2]['text'] = "Memory Usage"; + $os = 'powervault'; -$config['os'][$os]['text'] = 'Dell PowerVault'; -$config['os'][$os]['icon'] = 'dell'; +$config['os'][$os]['text'] = 'Dell PowerVault'; +$config['os'][$os]['icon'] = 'dell'; +$config['os'][$os]['type'] = 'storage'; $os = 'equallogic'; $config['os'][$os]['text'] = 'Dell EqualLogic'; From c91a7081cc709a8820e46b59a41bc255f7ced3a5 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sun, 17 Jan 2016 17:47:26 +0100 Subject: [PATCH 24/27] Basic commit --- doc/Extensions/Oxidized.md | 8 ++++++++ includes/defaults.inc.php | 3 ++- includes/functions.php | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index aa8ca5113..7f7d2ebf5 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -53,6 +53,14 @@ You will need to configure default credentials for your devices, LibreNMS doesn' X-Auth-Token: '01582bf94c03104ecb7953dsadsadwed' ``` +LibreNMS is able to reload the Oxidized list of nodes, each time a device is added to LibreNMS. +To do so, add the following to your config.php. + +```php +$config['oxidized']['reload_nodes'] = TRUE; + +``` + ### Using Groups To return a group to Oxidized you can do this by matching a regex for either hostname or location. The order is hostname is matched first, if nothing is found then location is attempted. diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index c71b39442..eeb9b5da3 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -471,8 +471,9 @@ $config['rancid_ignorecomments'] = 0; // $config['collectd_dir'] = '/var/lib/collectd/rrd'; // $config['smokeping']['dir'] = "/var/lib/smokeping/"; $config['smokeping']['pings'] = 20; -// $config['oxidized']['enabled'] = FALSE;//Set to TRUE +$config['oxidized']['enabled'] = FALSE;//Set to TRUE // $config['oxidized']['url'] = 'http://127.0.0.1:8888';// Set the Oxidized rest URL +$config['oxidized']['reload_nodes'] = FALSE;//Set to TRUE, check documentation // NFSen RRD dir. $config['nfsen_enable'] = 0; // $config['nfsen_split_char'] = "_"; diff --git a/includes/functions.php b/includes/functions.php index bb128bd13..c9d842b9a 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -580,6 +580,7 @@ function createHost($host, $community = NULL, $snmpver, $port = 161, $transport if (host_exists($host) === false) { $device_id = dbInsert($device, 'devices'); if ($device_id) { + oxidized_reload_nodes(); return($device_id); } else { @@ -1302,3 +1303,20 @@ function warn_innodb_buffer($innodb_buffer) { $output .= 'Config proposal: "innodb_buffer_pool_size = '.pow(2,ceil(log(($innodb_buffer['used'] / 1024 / 1024),2))).'M"'.PHP_EOL; return $output; } + +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'; + $ch = curl_init($oxidized_reload_url); + + curl_setopt($ch, CURLOPT_TIMEOUT, 5); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_exec($ch); + curl_close($ch); + } +} From 4581366bf487f7d5cce79e819f9d6d9525ae6c71 Mon Sep 17 00:00:00 2001 From: Rosiak Date: Sun, 17 Jan 2016 19:19:56 +0100 Subject: [PATCH 25/27] Add WebUI settings --- doc/Extensions/Oxidized.md | 2 +- html/pages/settings/external.inc.php | 4 ++++ includes/defaults.inc.php | 4 ++-- sql-schema/090.sql | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 sql-schema/090.sql diff --git a/doc/Extensions/Oxidized.md b/doc/Extensions/Oxidized.md index 7f7d2ebf5..23153780b 100644 --- a/doc/Extensions/Oxidized.md +++ b/doc/Extensions/Oxidized.md @@ -54,7 +54,7 @@ You will need to configure default credentials for your devices, LibreNMS doesn' ``` LibreNMS is able to reload the Oxidized list of nodes, each time a device is added to LibreNMS. -To do so, add the following to your config.php. +To do so, edit the option in Global Settings>External Settings>Oxidized Integration or add the following to your config.php. ```php $config['oxidized']['reload_nodes'] = TRUE; diff --git a/html/pages/settings/external.inc.php b/html/pages/settings/external.inc.php index ccade1add..fe89d4645 100644 --- a/html/pages/settings/external.inc.php +++ b/html/pages/settings/external.inc.php @@ -25,6 +25,10 @@ $oxidized_conf = array( 'descr' => 'Set the default group returned', 'type' => 'text', ), + array('name' => 'oxidized.reload_nodes', + 'descr' => 'Reload Oxidized nodes list, each time a device is added', + 'type' => 'checkbox', + ), ); $unixagent_conf = array( diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index eeb9b5da3..39701fd39 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -471,9 +471,9 @@ $config['rancid_ignorecomments'] = 0; // $config['collectd_dir'] = '/var/lib/collectd/rrd'; // $config['smokeping']['dir'] = "/var/lib/smokeping/"; $config['smokeping']['pings'] = 20; -$config['oxidized']['enabled'] = FALSE;//Set to TRUE +// $config['oxidized']['enabled'] = FALSE;//Set to TRUE // $config['oxidized']['url'] = 'http://127.0.0.1:8888';// Set the Oxidized rest URL -$config['oxidized']['reload_nodes'] = FALSE;//Set to TRUE, check documentation +// $config['oxidized']['reload_nodes'] = FALSE;//Set to TRUE, check documentation // NFSen RRD dir. $config['nfsen_enable'] = 0; // $config['nfsen_split_char'] = "_"; diff --git a/sql-schema/090.sql b/sql-schema/090.sql new file mode 100644 index 000000000..dc08f0c67 --- /dev/null +++ b/sql-schema/090.sql @@ -0,0 +1 @@ +INSERT INTO config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('oxidized.reload_nodes','false','false','Reload Oxidized nodes list, each time a device is added','external',0,'oxidized',0,'0','0'); \ No newline at end of file From e48b48546ccff19b768413edb2e142565767d13d Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 17 Jan 2016 19:43:33 +0000 Subject: [PATCH 26/27] Updated overview graphs for QNAP devices --- includes/definitions.inc.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 27b5284a5..802796785 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -164,10 +164,16 @@ $config['os'][$os]['over'][2]['graph'] = 'device_storage'; $config['os'][$os]['over'][2]['text'] = 'Storage Usage'; $os = 'qnap'; -$config['os'][$os]['type'] = 'storage'; -$config['os'][$os]['group'] = 'unix'; -$config['os'][$os]['text'] = 'QNAP TurboNAS'; -$config['os'][$os]['ifXmcbc'] = 1; +$config['os'][$os]['type'] = 'storage'; +$config['os'][$os]['group'] = 'unix'; +$config['os'][$os]['text'] = 'QNAP TurboNAS'; +$config['os'][$os]['ifXmcbc'] = 1; +$config['os'][$os]['over'][0]['graph'] = 'device_processor'; +$config['os'][$os]['over'][0]['text'] = 'Processor Usage'; +$config['os'][$os]['over'][1]['graph'] = 'device_mempool'; +$config['os'][$os]['over'][1]['text'] = 'Memory Usage'; +$config['os'][$os]['over'][2]['graph'] = 'device_storage'; +$config['os'][$os]['over'][2]['text'] = 'Storage Usage'; $os = 'netapp'; $config['os'][$os]['type'] = 'storage'; From cfc3728ded469265d187184afe6229c6e038435a Mon Sep 17 00:00:00 2001 From: laf Date: Sun, 17 Jan 2016 19:56:19 +0000 Subject: [PATCH 27/27] Removed Observium text, not needed --- includes/definitions.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 802796785..26f58e992 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -1,6 +1,5 @@