From b54ed80bfcd6cfb581c9f794da48409b56e83e4d Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 7 Dec 2015 01:51:26 +0000 Subject: [PATCH 01/17] Stop realtime graph page from auto refreshing --- html/pages/device/port/realtime.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html/pages/device/port/realtime.inc.php b/html/pages/device/port/realtime.inc.php index 41311917fd..7b282066e4 100644 --- a/html/pages/device/port/realtime.inc.php +++ b/html/pages/device/port/realtime.inc.php @@ -1,5 +1,7 @@ Date: Mon, 7 Dec 2015 02:22:44 +0000 Subject: [PATCH 02/17] Updated device_by_id_cache() to convert IP column --- includes/common.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/common.php b/includes/common.php index d74a512a9d..04c681aaf1 100644 --- a/includes/common.php +++ b/includes/common.php @@ -315,6 +315,7 @@ function device_by_id_cache($device_id, $refresh = '0') { } else { $device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device_id)); + $device['ip'] = inet6_ntop($device['ip']); $cache['devices']['id'][$device_id] = $device; } return $device; From 427c4f07c65a5a548e80654329f2b3d9662cb130 Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 Jan 2016 22:37:38 +0000 Subject: [PATCH 03/17] Added ability to ignore device sensors from entity mib --- includes/discovery/functions.inc.php | 28 +++++++++++++++++++ .../discovery/sensors/entity-sensor.inc.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index b03ac9048b..755f5b5e7c 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -710,3 +710,31 @@ function discover_process_ipv6(&$valid, $ifIndex, $ipv6_address, $ipv6_prefixlen }//end if }//end discover_process_ipv6() + +/* + * Check entity sensors to be excluded + * + * @param string value to check + * @param array device + * + * @return bool true if sensor is valid + * false if sensor is invalid +*/ +function check_entity_sensor($string, $device) { + global $config; + $valid = true; + $string = strtolower($string); + if (is_array($config['bad_entity_sensor_regex'])) { + $fringe = $config['bad_entity_sensor_regex']; + if (is_array($config['os'][$device['os']]['bad_entity_sensor_regex'])) { + $fringe = array_merge($config['bad_entity_sensor_regex'],$config['os'][$device['os']]['bad_entity_sensor_regex']); + } + foreach ($fringe as $bad) { + if (preg_match($bad . "i", $string)) { + $valid = false; + d_echo("Ignored entity sensor: $bad : $string"); + } + } + } + return $valid; +} diff --git a/includes/discovery/sensors/entity-sensor.inc.php b/includes/discovery/sensors/entity-sensor.inc.php index b81c997849..edf621b33c 100644 --- a/includes/discovery/sensors/entity-sensor.inc.php +++ b/includes/discovery/sensors/entity-sensor.inc.php @@ -50,7 +50,7 @@ if (is_array($oids)) { $descr = rewrite_entity_descr($descr); } - $thisisnotbullshit = true; + $thisisnotbullshit = check_entity_sensor($descr, $device); $type = $entitysensor[$entry['entPhySensorType']]; From d8c4916f6be3c1a1a5a6ce9470d2fe19222eebeb Mon Sep 17 00:00:00 2001 From: laf Date: Mon, 25 Jan 2016 22:59:11 +0000 Subject: [PATCH 04/17] Added docs information on using the new config options --- doc/Support/Configuration.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 15be9ed6c3..17248c0b46 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -406,6 +406,17 @@ Entries defined in `rewrite_if` are being replaced completely. Entries defined in `rewrite_if_regexp` only replace the match. Matches are compared case-insensitive. +#### Entity sensors to be ignored + +Some devices register bogus sensors as they are returned via SNMP but either don't exist or just don't return data. +This allows you to ignore those based on the descr field in the database. You can either ignore globally or on a per +os basis. + +```php +$config['bad_entity_sensor_regex'][] = '/Physical id [0-9]+/'; +$config['os']['cisco']['bad_entity_sensor_regex'] = '/Physical id [0-9]+/'; +``` + #### Storage configuration ```php From 3560a39b5249629b4135ad92b5b662f4f479a9da Mon Sep 17 00:00:00 2001 From: laf Date: Thu, 28 Jan 2016 09:38:31 +0000 Subject: [PATCH 05/17] Updated thisisnotbullshit variable --- includes/discovery/sensors/entity-sensor.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/discovery/sensors/entity-sensor.inc.php b/includes/discovery/sensors/entity-sensor.inc.php index edf621b33c..3a7de2e6a4 100644 --- a/includes/discovery/sensors/entity-sensor.inc.php +++ b/includes/discovery/sensors/entity-sensor.inc.php @@ -50,7 +50,7 @@ if (is_array($oids)) { $descr = rewrite_entity_descr($descr); } - $thisisnotbullshit = check_entity_sensor($descr, $device); + $valid = check_entity_sensor($descr, $device); $type = $entitysensor[$entry['entPhySensorType']]; @@ -103,16 +103,16 @@ if (is_array($oids)) { if ($type == 'temperature') { if ($current > '200') { - $thisisnotbullshit = false; + $valid = false; } $descr = preg_replace('/[T|t]emperature[|s]/', '', $descr); } // echo($descr . "|" . $index . "|" .$current . "|" . $multiplier . "|" . $divisor ."|" . $entry['entPhySensorScale'] . "|" . $entry['entPhySensorPrecision'] . "\n"); if ($current == '-127') { - $thisisnotbullshit = false; + $valid = false; } - if ($thisisnotbullshit && dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE device_id = ? AND `sensor_class` = ? AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ?", array($device['device_id'], $type, $index)) == '0') { + if ($valid && dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE device_id = ? AND `sensor_class` = ? AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ?", array($device['device_id'], $type, $index)) == '0') { // Check to make sure we've not already seen this sensor via cisco's entity sensor mib discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, null, null, null, null, $current); } From bc018d3609aa5c975e84895a548434af40d5dada Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 2 Feb 2016 13:18:12 +0000 Subject: [PATCH 06/17] Removed devloping doc as none of the info is current --- doc/General/Developing-for-LibreNMS.md | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 doc/General/Developing-for-LibreNMS.md diff --git a/doc/General/Developing-for-LibreNMS.md b/doc/General/Developing-for-LibreNMS.md deleted file mode 100644 index 3a63348208..0000000000 --- a/doc/General/Developing-for-LibreNMS.md +++ /dev/null @@ -1,20 +0,0 @@ -Developing for LibreNMS has never been easier. - -Thanks to [Wes Kennedy](https://twitter.com/livearchivist), there is -now a vagrant file that will allow you to install a virtual machine -that has LibreNMS already running on it! - -To get started, you can just copy the script from `/contrib/dev_init`, -or you can enter the following commands into your shell: - -``` -mkdir -p dev/librenms && cd $_ -curl -O http://wkennedy.co/uploads/librenms/Vagrantfile -curl -O http://wkennedy.co/uploads/librenms/bootstrap.sh -chmod +x bootstrap.sh -vagrant up -``` - -This may take a few minutes and requires you to already have Vagrant -installed. If you don't have Vagrant installed, it's easy to setup. -See the [installation instructions here](http://docs.vagrantup.com/v2/installation/). \ No newline at end of file From 4ebc2b1f337f770389e2fd9b9e43f27ec0241a97 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Wed, 3 Feb 2016 06:41:20 +1000 Subject: [PATCH 07/17] - Modified code to use graph generation functions instead of calling overlib directly. The graph generation functions check for the status of 'web_mouseover'. --- html/pages/device/routing/bgp.inc.php | 17 +++++++++++--- html/pages/routing/bgp.inc.php | 32 +++++++++++++++++++-------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/html/pages/device/routing/bgp.inc.php b/html/pages/device/routing/bgp.inc.php index 17f0629a02..e994313433 100644 --- a/html/pages/device/routing/bgp.inc.php +++ b/html/pages/device/routing/bgp.inc.php @@ -200,10 +200,21 @@ foreach (dbFetchRows('SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b $peer['bgpPeerIdentifier'] = Net_IPv6::compress($peer['bgpPeerIdentifier']); } + // display overlib graphs + $graph_array = array(); + $graph_array['type'] = 'bgp_updates'; + $graph_array['id'] = $peer['bgpPeer_id']; + $graph_array['to'] = $config['time']['now']; + $graph_array['from'] = $config['time']['day']; + $graph_array['height'] = '110'; + $graph_array['width'] = $width; - $graph_type = 'bgp_updates'; - $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; - $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer['bgpPeerIdentifier'].''; + // Peer Address + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '500'; + $overlib_link = "device/device=".$peer['device_id']."/tab=routing/proto=bgp/"; + $peeraddresslink = "".overlib_link(NULL, $peer['bgpPeerIdentifier'], generate_graph_tag($graph_array_zoom), NULL).""; echo ' '; diff --git a/html/pages/routing/bgp.inc.php b/html/pages/routing/bgp.inc.php index d70555c030..e7450aac92 100644 --- a/html/pages/routing/bgp.inc.php +++ b/html/pages/routing/bgp.inc.php @@ -256,20 +256,12 @@ else { unset($peername); } - // display overlib graphs - $graph_type = 'bgp_updates'; - $local_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150&&afi=ipv4&safi=unicast'; if (filter_var($peer['bgpLocalAddr'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { $peer_ip = Net_IPv6::compress($peer['bgpLocalAddr']); } else { $peer_ip = $peer['bgpLocalAddr']; } - - $localaddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ip.''; - - $graph_type = 'bgp_updates'; - $peer_daily_url = 'graph.php?id='.$peer['bgpPeer_id'].'&type='.$graph_type.'&from='.$config['time']['day'].'&to='.$config['time']['now'].'&width=500&height=150'; if (filter_var($peer['bgpPeerIdentifier'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false) { $peer_ident = Net_IPv6::compress($peer['bgpPeerIdentifier']); } @@ -277,7 +269,29 @@ else { $peer_ident = $peer['bgpPeerIdentifier']; } - $peeraddresslink = "', LEFT".$config['overlib_defaults'].');" onmouseout="return nd();">'.$peer_ident.''; + // display overlib graphs + $graph_array = array(); + $graph_array['type'] = 'bgp_updates'; + $graph_array['id'] = $peer['bgpPeer_id']; + $graph_array['to'] = $config['time']['now']; + $graph_array['from'] = $config['time']['day']; + $graph_array['height'] = '110'; + $graph_array['width'] = $width; + + // Peer Address + $graph_array_zoom = $graph_array; + $graph_array_zoom['height'] = '150'; + $graph_array_zoom['width'] = '500'; + $overlib_link = "device/device=".$peer['device_id']."/tab=routing/proto=bgp/"; + $peeraddresslink = "".overlib_link($overlib_link, $peer_ident, generate_graph_tag($graph_array_zoom), NULL).""; + + // Local Address + $graph_array['afi'] = 'ipv4'; + $graph_array['safi'] = 'unicast'; + $graph_array_zoom['afi'] = 'ipv4'; + $graph_array_zoom['safi'] = 'unicast'; + $overlib_link = "device/device=".$peer['device_id']."/tab=routing/proto=bgp/"; + $localaddresslink = "".overlib_link($overlib_link, $peer_ip, generate_graph_tag($graph_array_zoom), NULL).""; echo ''; From 1b6662448faf84ca5eaa7a6fc689b89f1999efd6 Mon Sep 17 00:00:00 2001 From: awlx Date: Wed, 3 Feb 2016 10:19:07 +0100 Subject: [PATCH 08/17] Added configuration examples and descriptions for mib based poller --- doc/Extensions/MIB-based-polling.md | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index d23d207dd6..5f73ff7485 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -144,6 +144,59 @@ graph. can follow the above process, then use the resultant data collected by LibreNMS in the RRD files or the database tables `device_oids` +## Configuration + +### Discovery + +You need to add your desired MIBs to `/opt/librenms/mibs` folder. Afterwards you need to register your MIBs to the discovery function. + +#### Example +`/opt/librenms/includes/discovery/os/f5.inc.php` + +``` + "F5-BIGIP-LOCAL-MIB", + ); + +### Actual registering of the MIB +register_mibs($device, $f5_mibs, "includes/discovery/os/f5.inc.php"); + +``` + +The important thing is the array $f5_mibs where you define which parts (ltmVirtualServStatEntry) of the MIB (F5-BIGIP-LOCAL-MIB) you are going to add. The registering is also important, otherwise poller cannot make use of the MIB. + +### Poller + +Next step is to add the MIBs to the poller. + +#### Example +`/opt/librenms/includes/polling/os/f5.inc.php` + +``` + "F5-BIGIP-LOCAL-MIB", +); + +### Poll those MIBs +poll_mibs($f5_mibs, $device, $graphs); +``` + +You define the MIBs which you want to poll here and start the actual polling with `poll_mibs()`. + ## TODO ## From 2a51cf723cd7fbfeb8051055aa23757c5fc64ad5 Mon Sep 17 00:00:00 2001 From: awlx Date: Wed, 3 Feb 2016 10:24:17 +0100 Subject: [PATCH 09/17] To make it complete added config.php step --- doc/Extensions/MIB-based-polling.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index 5f73ff7485..b59f848883 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -145,6 +145,8 @@ graph. LibreNMS in the RRD files or the database tables `device_oids` ## Configuration +### Main Configuration +In `/opt/librenms/config.php` add `$config['poller_modules']['mib'] = 1;` ### Discovery From 45917efd0f5434c4bd4c9ad0597a62694cc45a5e Mon Sep 17 00:00:00 2001 From: awlx Date: Wed, 3 Feb 2016 10:34:07 +0100 Subject: [PATCH 10/17] Removed no longer necessary poller section --- doc/Extensions/MIB-based-polling.md | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index b59f848883..cc95151531 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -177,29 +177,6 @@ register_mibs($device, $f5_mibs, "includes/discovery/os/f5.inc.php"); The important thing is the array $f5_mibs where you define which parts (ltmVirtualServStatEntry) of the MIB (F5-BIGIP-LOCAL-MIB) you are going to add. The registering is also important, otherwise poller cannot make use of the MIB. -### Poller - -Next step is to add the MIBs to the poller. - -#### Example -`/opt/librenms/includes/polling/os/f5.inc.php` - -``` - "F5-BIGIP-LOCAL-MIB", -); - -### Poll those MIBs -poll_mibs($f5_mibs, $device, $graphs); -``` - -You define the MIBs which you want to poll here and start the actual polling with `poll_mibs()`. - - ## TODO ## What's not included in MIB-based polling at present? These may be present in From 4ff92481e46a2d13a06016e9445e260466f3c7c1 Mon Sep 17 00:00:00 2001 From: Aaron Daniels Date: Thu, 4 Feb 2016 16:34:56 +1000 Subject: [PATCH 11/17] - Quote the SNMP v2c community, v3 is already quoted. - Change the snmpver to double quotes for consistency. --- includes/snmp.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 7f806d8677..d2d485998e 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -776,8 +776,8 @@ function snmp_gen_auth(&$device) { } } else if ($device['snmpver'] === 'v2c' or $device['snmpver'] === 'v1') { - $cmd = ' -'.$device['snmpver']; - $cmd .= ' -c '.$device['community']; + $cmd = " -".$device['snmpver']; + $cmd .= " -c '".$device['community']."'"; } else { if ($debug) { From e397860257fad8dc79405c4315129e9a63fc8c7b Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 18:09:09 -0800 Subject: [PATCH 12/17] Update ajax_dash.php --- html/ajax_dash.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/ajax_dash.php b/html/ajax_dash.php index d2e2b0a622..0ffc580679 100644 --- a/html/ajax_dash.php +++ b/html/ajax_dash.php @@ -55,5 +55,5 @@ $response = array( 'html' => $output, 'title' => $title, ); - +header('Content-type: application/json'); echo _json_encode($response); From ab6a608bdb29d711dc1e1ef398d7bb6ac9047524 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 18:09:47 -0800 Subject: [PATCH 13/17] Update ajax_table.php --- html/ajax_table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/ajax_table.php b/html/ajax_table.php index f16cc2da97..c3513a68a8 100644 --- a/html/ajax_table.php +++ b/html/ajax_table.php @@ -36,6 +36,7 @@ $response = array(); if (isset($id)) { if (file_exists("includes/table/$id.inc.php")) { + header('Content-type: application/json'); include_once "includes/table/$id.inc.php"; } } From d62ad2eb029dfc095fb0f443ad1e33f561104f23 Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 18:16:36 -0800 Subject: [PATCH 14/17] Update ajax_search.php --- html/ajax_search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/ajax_search.php b/html/ajax_search.php index e9ddad36f5..cb8d012a33 100644 --- a/html/ajax_search.php +++ b/html/ajax_search.php @@ -19,7 +19,7 @@ $bgp = array(); if (isset($_REQUEST['search'])) { $search = mres($_REQUEST['search']); - + header('Content-type: application/json'); if (strlen($search) > 0) { $found = 0; From 1b4dfd2fc6d7db200c55c66ce0585fb3c5a6d59d Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 18:18:40 -0800 Subject: [PATCH 15/17] Update ajax_rulesuggest.php --- html/ajax_rulesuggest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/ajax_rulesuggest.php b/html/ajax_rulesuggest.php index cee773a2fc..850658939a 100644 --- a/html/ajax_rulesuggest.php +++ b/html/ajax_rulesuggest.php @@ -62,7 +62,7 @@ function levsort($base, $obj) { } - +header('Content-type: application/json'); $obj = array(array('name' => 'Error: No suggestions found.')); $term = array(); $current = false; From e8f773b0101fddc7f8985edad62d3d3cda1342da Mon Sep 17 00:00:00 2001 From: pblasquez Date: Thu, 4 Feb 2016 18:23:49 -0800 Subject: [PATCH 16/17] Update ajax_form.php --- html/ajax_form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/html/ajax_form.php b/html/ajax_form.php index 999a43a4dc..3851d5b4f2 100644 --- a/html/ajax_form.php +++ b/html/ajax_form.php @@ -29,6 +29,7 @@ if (!$_SESSION['authenticated']) { if (preg_match('/^[a-zA-Z0-9\-]+$/', $_POST['type']) == 1) { if (file_exists('includes/forms/'.$_POST['type'].'.inc.php')) { + header('Content-type: application/json'); include_once 'includes/forms/'.$_POST['type'].'.inc.php'; } } From be225148ca9f4a48e6f07b4c8857c8652b8591dd Mon Sep 17 00:00:00 2001 From: Mark Schouten Date: Fri, 5 Feb 2016 14:50:27 +0100 Subject: [PATCH 17/17] There was one more include that screwed up the Ceph graphs --- html/pages/device/apps/ceph.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/html/pages/device/apps/ceph.inc.php b/html/pages/device/apps/ceph.inc.php index 50dedc8c48..9ad7536516 100644 --- a/html/pages/device/apps/ceph.inc.php +++ b/html/pages/device/apps/ceph.inc.php @@ -17,9 +17,9 @@ foreach ($graphs as $key => $text) { if ($key == "ceph_poolstats") { foreach (glob($rrddir."/app-ceph-".$app['app_id']."-pool-*") as $rrd_filename) { - $graph_array['to'] = $config['time']['now']; - $graph_array['id'] = $app['app_id']; if (preg_match("/.*-pool-(.+)\.rrd$/", $rrd_filename, $pools)) { + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; $pool = $pools[1]; echo '

'.$pool.' Reads/Writes

'; $graph_array['type'] = 'application_ceph_pool_io'; @@ -29,6 +29,8 @@ foreach ($graphs as $key => $text) { include 'includes/print-graphrow.inc.php'; echo ''; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; echo '

'.$pool.' IOPS

'; $graph_array['type'] = 'application_ceph_pool_iops'; $graph_array['pool'] = $pool;