From 84863586b5fa0b416e958a8a5e9a56309e82325d Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 17 Nov 2015 02:20:23 -0800 Subject: [PATCH 01/10] rrdtune code --- html/includes/table/edit-ports.inc.php | 23 ++++++++++++++--------- html/pages/device/edit/ports.inc.php | 9 ++++++++- includes/polling/ports.inc.php | 13 +++++++++++++ includes/rrdtool.inc.php | 16 +++++++++++++++- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/html/includes/table/edit-ports.inc.php b/html/includes/table/edit-ports.inc.php index d4ccba8a5..625ac5e75 100644 --- a/html/includes/table/edit-ports.inc.php +++ b/html/includes/table/edit-ports.inc.php @@ -54,17 +54,22 @@ foreach (dbFetchRows($sql, $param) as $port) { $isportbad = ($port['ifOperStatus'] == 'down' && $port['ifAdminStatus'] != 'down') ? 1 : 0; $dowecare = ($port['ignore'] == 0 && $port['disabled'] == 0) ? $isportbad : !$isportbad; $outofsync = $dowecare ? " class='red'" : ''; + $checked = ''; + if (get_dev_attrib($device_id, 'ifName_tune:'.$port['ifName']) == "true") { + $checked = 'checked'; + } $response[] = array( - 'ifIndex' => $port['ifIndex'], - 'ifName' => $port['label'], - 'ifAdminStatus' => $port['ifAdminStatus'], - 'ifOperStatus' => ''.$port['ifOperStatus'].'', - 'disabled' => ' - ', - 'ignore' => ' - ', - 'ifAlias' => '
' + 'ifIndex' => $port['ifIndex'], + 'ifName' => $port['label'], + 'ifAdminStatus' => $port['ifAdminStatus'], + 'ifOperStatus' => ''.$port['ifOperStatus'].'', + 'disabled' => ' + ', + 'ignore' => ' + ', + 'port_tune' => '', + 'ifAlias' => '
', ); }//end foreach diff --git a/html/pages/device/edit/ports.inc.php b/html/pages/device/edit/ports.inc.php index 37cccb9d2..2e14cbb46 100644 --- a/html/pages/device/edit/ports.inc.php +++ b/html/pages/device/edit/ports.inc.php @@ -5,7 +5,7 @@ '> -
+
@@ -15,6 +15,7 @@ + @@ -23,6 +24,7 @@ diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 784fecfd9..0ab72a57d 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -315,6 +315,7 @@ foreach ($ports as $port) { } // Update IF-MIB data + $tune_port = false; foreach ($data_oids as $oid) { if ($oid == 'ifAlias') { @@ -334,6 +335,15 @@ foreach ($ports as $port) { } } else if ($port[$oid] != $this_port[$oid]) { + $port_tune = get_dev_attrib($device, 'ifName_tune:'.$port['ifName']); + $device_tune = get_dev_attrib($device,'device_rrdtool_tune'); + if ($port_tune == "true" || + ($device_tune == "true" && $port_tune != 'false') || + ($config['rrdtool']['tune'] == "true" && $port_tune != 'false' && $device_tune != 'false')) { + if ($oid == 'ifSpeed') { + $tune_port = true; + } + } $port['update'][$oid] = $this_port[$oid]; log_event($oid.': '.$port[$oid].' -> '.$this_port[$oid], $device, 'interface', $port['port_id']); if ($debug) { @@ -477,6 +487,9 @@ foreach ($ports as $port) { 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts'], ); + if ($tune_port === true) { + rrdtool_tune('port',$rrdfile,$this_port['ifSpeed']); + } rrdtool_update("$rrdfile", $fields); // End Update IF-MIB // Update PAgP diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 3c35cec22..32c2040a1 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -166,7 +166,7 @@ function rrdtool_graph($graph_file, $options) { function rrdtool($command, $filename, $options) { global $config, $debug, $rrd_pipes, $console_color; - if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || $command != "create")) { + if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || ($command != "create" && $command != 'tune'))) { if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { $filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename); $filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename); @@ -294,3 +294,17 @@ function rrdtool_escape($string, $maxlength=null){ return $result.' '; } + +function rrdtool_tune($type, $filename, $max) { + if ($type === 'port') { + if ($max < 10000000) { + return false; + } + $max = $max / 8; + $fields = array( +'INOCTETS','OUTOCTETS','INERRORS','OUTERRORS','INUCASTPKTS','OUTUCASTPKTS','INNUCASTPKTS','OUTNUCASTPKTS','INDISCARDS','OUTDISCARDS','INUNKNOWNPROTOS','INBROADCASTPKTS','OUTBROADCASTPKTS','INMULTICASTPKTS','OUTMULTICASTPKTS' +); + $options = "--maxium " . implode(":$max --maximum ", $fields). ":$max"; + rrdtool('tune', $filename, $options); + } +} From 253b27d403d7075e056a0ecfc91caf7d919c33a0 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 17 Nov 2015 05:14:41 -0800 Subject: [PATCH 02/10] More updates to tune rrdfiles --- html/js/librenms.js | 46 +++++++++++++++------------- html/pages/device/edit/misc.inc.php | 18 +++++++---- html/pages/settings/external.inc.php | 12 ++++++++ includes/polling/ports.inc.php | 2 +- includes/rrdtool.inc.php | 4 +-- scripts/tune_port.php | 34 ++++++++++++++++++++ sql-schema/077.sql | 1 + 7 files changed, 87 insertions(+), 30 deletions(-) create mode 100755 scripts/tune_port.php create mode 100644 sql-schema/077.sql diff --git a/html/js/librenms.js b/html/js/librenms.js index 3df1fc533..82df6b7aa 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -1,28 +1,32 @@ +function override_config(event, state, tmp_this) { + event.preventDefault(); + var $this = tmp_this; + var attrib = $this.data('attrib'); + var device_id = $this.data('device_id'); + $.ajax({ + type: 'POST', + url: 'ajax_form.php', + data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state }, + dataType: 'json', + success: function(data) { + if (data.status == 'ok') { + toastr.success(data.message); + } + else { + toastr.error(data.message); + } + }, + error: function() { + toastr.error('Could not set this override'); + } + }); +} + $(document).ready(function() { // Device override ajax calls $("[name='override_config']").bootstrapSwitch('offColor','danger'); $('input[name="override_config"]').on('switchChange.bootstrapSwitch', function(event, state) { - event.preventDefault(); - var $this = $(this); - var attrib = $this.data('attrib'); - var device_id = $this.data('device_id'); - $.ajax({ - type: 'POST', - url: 'ajax_form.php', - data: { type: 'override-config', device_id: device_id, attrib: attrib, state: state }, - dataType: 'json', - success: function(data) { - if (data.status == 'ok') { - toastr.success(data.message); - } - else { - toastr.error(data.message); - } - }, - error: function() { - toastr.error('Could not set this override'); - } - }); + override_config(event,state,$(this)); }); // Device override for text inputs diff --git a/html/pages/device/edit/misc.inc.php b/html/pages/device/edit/misc.inc.php index d1731ecdf..b46932a15 100644 --- a/html/pages/device/edit/misc.inc.php +++ b/html/pages/device/edit/misc.inc.php @@ -3,23 +3,29 @@ echo '
- -
+ +
'.dynamic_override_config('checkbox','override_icmp_disable', $device).'
- -
+ +
'.dynamic_override_config('checkbox','override_Oxidized_disable', $device).'
- -
+ +
'.dynamic_override_config('text','override_Unixagent_port', $device).'
+
+ +
+ '.dynamic_override_config('checkbox','override_rrdtool_tune', $device).' +
+
'; diff --git a/html/pages/settings/external.inc.php b/html/pages/settings/external.inc.php index 5459ed67e..b5b4661cd 100644 --- a/html/pages/settings/external.inc.php +++ b/html/pages/settings/external.inc.php @@ -34,6 +34,17 @@ $unixagent_conf = array( ), ); +$rrdtool_conf = array( + array('name' => 'rrdtool', + 'descr' => 'Path to rrdtool binary', + 'type' => 'text', + ), + array('name' => 'rrdtool.tune', + 'descr' => 'Tune all rrd port files to use max values', + 'type' => 'checkbox', + ), +); + echo '
@@ -41,6 +52,7 @@ echo ' echo generate_dynamic_config_panel('Oxidized integration',true,$config_groups,$oxidized_conf); echo generate_dynamic_config_panel('Unix-agent integration',true,$config_groups,$unixagent_conf); +echo generate_dynamic_config_panel('RRDTool Setup',true,$config_groups,$rrdtool_conf); echo ' diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 0ab72a57d..d0301bff5 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -336,7 +336,7 @@ foreach ($ports as $port) { } else if ($port[$oid] != $this_port[$oid]) { $port_tune = get_dev_attrib($device, 'ifName_tune:'.$port['ifName']); - $device_tune = get_dev_attrib($device,'device_rrdtool_tune'); + $device_tune = get_dev_attrib($device,'override_rrdtool_tune'); if ($port_tune == "true" || ($device_tune == "true" && $port_tune != 'false') || ($config['rrdtool']['tune'] == "true" && $port_tune != 'false' && $device_tune != 'false')) { diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 32c2040a1..b319bf80f 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -166,7 +166,7 @@ function rrdtool_graph($graph_file, $options) { function rrdtool($command, $filename, $options) { global $config, $debug, $rrd_pipes, $console_color; - if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || ($command != "create" && $command != 'tune'))) { + if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || ($command != "create" && $command != "tune"))) { if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { $filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename); $filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename); @@ -304,7 +304,7 @@ function rrdtool_tune($type, $filename, $max) { $fields = array( 'INOCTETS','OUTOCTETS','INERRORS','OUTERRORS','INUCASTPKTS','OUTUCASTPKTS','INNUCASTPKTS','OUTNUCASTPKTS','INDISCARDS','OUTDISCARDS','INUNKNOWNPROTOS','INBROADCASTPKTS','OUTBROADCASTPKTS','INMULTICASTPKTS','OUTMULTICASTPKTS' ); - $options = "--maxium " . implode(":$max --maximum ", $fields). ":$max"; + $options = "--maximum " . implode(":$max --maximum ", $fields). ":$max"; rrdtool('tune', $filename, $options); } } diff --git a/scripts/tune_port.php b/scripts/tune_port.php new file mode 100755 index 000000000..061817283 --- /dev/null +++ b/scripts/tune_port.php @@ -0,0 +1,34 @@ +#!/usr/bin/env php + Device(s) to match\n"; + echo "-p Port(s) to match using ifName\n"; + echo "\n"; + +} + +echo "TEST $hosts and $ports\n"; +$debug=1; + +foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` WHERE `hostname` LIKE ?", array('%'.$hosts.'%')) as $device) { + echo "Found hostname " . $device['hostname'].".......\n"; + foreach (dbFetchRows("SELECT `ifIndex`,`ifName`,`ifSpeed` FROM `ports` WHERE `ifName` LIKE ? AND `device_id` = ?", array('%'.$ports.'%',$device['device_id'])) as $port) { + echo "Tuning port " . $port['ifName'].".......\n"; + $host_rrd = $config['rrd_dir'].'/'.$device['hostname']; + $rrdfile = $host_rrd.'/port-'.safename($port['ifIndex'].'.rrd'); + rrdtool_tune('port',$rrdfile,$port['ifSpeed']); + } +} + diff --git a/sql-schema/077.sql b/sql-schema/077.sql new file mode 100644 index 000000000..30bbf95fb --- /dev/null +++ b/sql-schema/077.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 ('rrdtool','/usr/bin/rrdtool','/usr/bin/rrdtool','Path to rrdtool','external',0,'rrdtool',0,'0','0'), ('rrdtool.tune','false','false','Auto tune maximum value for rrd port files','external',0,'rrdtool',0,'0','0'); From 52e0be911b5420de402e9d30d5fdaa8cbcf977ac Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 17 Nov 2015 05:38:45 -0800 Subject: [PATCH 03/10] More updates --- html/pages/settings/external.inc.php | 2 +- includes/polling/ports.inc.php | 3 ++- scripts/tune_port.php | 3 --- sql-schema/077.sql | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/html/pages/settings/external.inc.php b/html/pages/settings/external.inc.php index b5b4661cd..a912ce403 100644 --- a/html/pages/settings/external.inc.php +++ b/html/pages/settings/external.inc.php @@ -39,7 +39,7 @@ $rrdtool_conf = array( 'descr' => 'Path to rrdtool binary', 'type' => 'text', ), - array('name' => 'rrdtool.tune', + array('name' => 'rrdtool_tune', 'descr' => 'Tune all rrd port files to use max values', 'type' => 'checkbox', ), diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index d0301bff5..640dcd05b 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -339,7 +339,7 @@ foreach ($ports as $port) { $device_tune = get_dev_attrib($device,'override_rrdtool_tune'); if ($port_tune == "true" || ($device_tune == "true" && $port_tune != 'false') || - ($config['rrdtool']['tune'] == "true" && $port_tune != 'false' && $device_tune != 'false')) { + ($config['rrdtool_tune'] == "true" && $port_tune != 'false' && $device_tune != 'false')) { if ($oid == 'ifSpeed') { $tune_port = true; } @@ -487,6 +487,7 @@ foreach ($ports as $port) { 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts'], ); + echo "TEST $tune_port END \n"; if ($tune_port === true) { rrdtool_tune('port',$rrdfile,$this_port['ifSpeed']); } diff --git a/scripts/tune_port.php b/scripts/tune_port.php index 061817283..c38f41dd0 100755 --- a/scripts/tune_port.php +++ b/scripts/tune_port.php @@ -19,9 +19,6 @@ if (empty($hosts) && empty($ports)) { } -echo "TEST $hosts and $ports\n"; -$debug=1; - foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` WHERE `hostname` LIKE ?", array('%'.$hosts.'%')) as $device) { echo "Found hostname " . $device['hostname'].".......\n"; foreach (dbFetchRows("SELECT `ifIndex`,`ifName`,`ifSpeed` FROM `ports` WHERE `ifName` LIKE ? AND `device_id` = ?", array('%'.$ports.'%',$device['device_id'])) as $port) { diff --git a/sql-schema/077.sql b/sql-schema/077.sql index 30bbf95fb..b4106e952 100644 --- a/sql-schema/077.sql +++ b/sql-schema/077.sql @@ -1 +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 ('rrdtool','/usr/bin/rrdtool','/usr/bin/rrdtool','Path to rrdtool','external',0,'rrdtool',0,'0','0'), ('rrdtool.tune','false','false','Auto tune maximum value for rrd port files','external',0,'rrdtool',0,'0','0'); +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 ('rrdtool','/usr/bin/rrdtool','/usr/bin/rrdtool','Path to rrdtool','external',0,'rrdtool',0,'0','0'), ('rrdtool_tune','false','false','Auto tune maximum value for rrd port files','external',0,'rrdtool',0,'0','0'); From 1591f9ca6d8dc750cccb47db8949daa3703d7a6f Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 18 Nov 2015 21:39:53 +0000 Subject: [PATCH 04/10] Added rrdtool_pipe_open :( --- scripts/tune_port.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/tune_port.php b/scripts/tune_port.php index c38f41dd0..495c2ad82 100755 --- a/scripts/tune_port.php +++ b/scripts/tune_port.php @@ -5,6 +5,7 @@ require 'includes/defaults.inc.php'; require 'config.php'; require 'includes/definitions.inc.php'; require 'includes/functions.php'; +rrdtool_pipe_open($rrd_process, $rrd_pipes); $options = getopt('h:p:'); From c000676a2afd3a62fdfadcb5e8c981f0ab5b33f0 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 18 Nov 2015 21:52:32 +0000 Subject: [PATCH 05/10] Some more updates for rrdtool tune --- doc/Extensions/RRDTune.md | 21 +++++++++++++++++++++ doc/Support/FAQ.md | 8 ++++++++ scripts/tune_port.php | 4 ++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 doc/Extensions/RRDTune.md diff --git a/doc/Extensions/RRDTune.md b/doc/Extensions/RRDTune.md new file mode 100644 index 000000000..7ee7095d2 --- /dev/null +++ b/doc/Extensions/RRDTune.md @@ -0,0 +1,21 @@ +# RRDTune? + +When we create rrd files for ports, we currently do so with a max value of 12500000000 (100G). Because of this if a device sends us bad data back then it can appear as though +a 100M port is doing 40G+ which is impossible. To counter this you can enable the rrdtool tune option which will fix the max value to the interfaces physical speed (minimum of 10M). + +To enable this you can do so in three ways! + + - Globally under Global Settings -> External Settings -> RRDTool Setup + - For the actual device, Edit Device -> Misc + - For each port, Edit Device -> Port Settings + +Now when a port interface speed changes (this can happen because of a physical change or just because the device has mis-reported) the max value is set. If you don't want to wait until +a port speed changes then you can run the included script: + +script/tune_port.php -h -p + +Wildcards are supported using *, i.e: + +script/tune_port.php -h local* -p eth* + +This script will then perform the rrdtool tune on each port found using the provided ifSpeed for that port. diff --git a/doc/Support/FAQ.md b/doc/Support/FAQ.md index d7317db4f..d6da5de50 100644 --- a/doc/Support/FAQ.md +++ b/doc/Support/FAQ.md @@ -12,6 +12,7 @@ - [How do I debug the discovery process?](#faq11) - [How do I debug the poller process?](#faq12) - [Why do I get a lot apache or rrdtool zombies in my process list?](#faq14) + - [Why do I see traffic spikes in my graphs?](#faq15) ### Developing - [How do I add support for a new OS?](#faq8) @@ -94,6 +95,13 @@ Please see the [Poller Support](http://docs.librenms.org/Support/Poller Support) If this is related to your web service for LibreNMS then this has been tracked down to an issue within php which the developers aren't fixing. We have implemented a work around which means you shouldn't be seeing this. If you are, please report this in [issue 443](https://github.com/librenms/librenms/issues/443). +#### Why do I see traffic spikes in my graphs? + +This occurs either when a counter resets or the device sends back bogus data making it look like a counter reset. We have enabled support for setting a maximum value for rrd files for ports. +Before this all rrd files were set to 100G max values, now you can enable support to limit this to the actual port speed. + +rrdtool tune will change the max value when the interface speed is detected as being changed (min value will be set for anything 10M or over) or when you run the included script (scripts/tune_port.php). + #### How do I add support for a new OS? The easiest way to show you how to do that is to link to an existing pull request that has been merged in on [GitHub](https://github.com/librenms/librenms/pull/352/files) diff --git a/scripts/tune_port.php b/scripts/tune_port.php index 495c2ad82..2798469cc 100755 --- a/scripts/tune_port.php +++ b/scripts/tune_port.php @@ -9,8 +9,8 @@ rrdtool_pipe_open($rrd_process, $rrd_pipes); $options = getopt('h:p:'); -$hosts = $options['h']; -$ports = $options['p']; +$hosts = str_replace('*', '%', mres($options['h'])); +$ports = str_replace('*', '%', mres($options['p'])); if (empty($hosts) && empty($ports)) { From 46b2fd7d1f2c263ec97d67ce6be00a038ffa08c2 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 18 Nov 2015 21:54:07 +0000 Subject: [PATCH 06/10] Removed debug --- includes/polling/ports.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 640dcd05b..017cc7085 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -487,7 +487,6 @@ foreach ($ports as $port) { 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts'], ); - echo "TEST $tune_port END \n"; if ($tune_port === true) { rrdtool_tune('port',$rrdfile,$this_port['ifSpeed']); } From 78a688fc47365b63240dc61f9f066cc71a6ba56f Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 1 Dec 2015 21:53:12 +0000 Subject: [PATCH 07/10] Updated rrdtool call for tune command --- includes/rrdtool.inc.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index b319bf80f..1077aa912 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -166,7 +166,11 @@ function rrdtool_graph($graph_file, $options) { function rrdtool($command, $filename, $options) { global $config, $debug, $rrd_pipes, $console_color; - if ($config['rrdcached'] && ($config['rrdtool_version'] >= 1.5 || ($command != "create" && $command != "tune"))) { + if ($config['rrdcached'] && + ($config['rrdtool_version'] >= 1.5.5 || + ($config['rrdtool_version'] >= 1.5 && $command != "tune") || + ($command != "create" && $command != "tune")) + ) { if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { $filename = str_replace($config['rrd_dir'].'/', './'.$config['rrdcached_dir'].'/', $filename); $filename = str_replace($config['rrd_dir'], './'.$config['rrdcached_dir'].'/', $filename); From 55d3242bd601adfe3d7891a5ff7057e48837cde7 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 2 Dec 2015 19:21:01 +0000 Subject: [PATCH 08/10] Updated version checking in rrdtool() function --- includes/rrdtool.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 1077aa912..551bad9d9 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -167,8 +167,8 @@ function rrdtool($command, $filename, $options) { global $config, $debug, $rrd_pipes, $console_color; if ($config['rrdcached'] && - ($config['rrdtool_version'] >= 1.5.5 || - ($config['rrdtool_version'] >= 1.5 && $command != "tune") || + (version_compare($config['rrdtool_version'], '1.5.5', '>=') || + (version_compare($config['rrdtool_version'], '1.5', '>=') && $command != "tune") || ($command != "create" && $command != "tune")) ) { if (isset($config['rrdcached_dir']) && $config['rrdcached_dir'] !== false) { From e75fc4b8b1ee53d0517022c9339342ab5277b899 Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 8 Dec 2015 13:53:38 +0000 Subject: [PATCH 09/10] Future proofed --- includes/rrdtool.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 551bad9d9..c29d9bbc4 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -307,8 +307,8 @@ function rrdtool_tune($type, $filename, $max) { $max = $max / 8; $fields = array( 'INOCTETS','OUTOCTETS','INERRORS','OUTERRORS','INUCASTPKTS','OUTUCASTPKTS','INNUCASTPKTS','OUTNUCASTPKTS','INDISCARDS','OUTDISCARDS','INUNKNOWNPROTOS','INBROADCASTPKTS','OUTBROADCASTPKTS','INMULTICASTPKTS','OUTMULTICASTPKTS' -); - $options = "--maximum " . implode(":$max --maximum ", $fields). ":$max"; - rrdtool('tune', $filename, $options); + ); } + $options = "--maximum " . implode(":$max --maximum ", $fields). ":$max"; + rrdtool('tune', $filename, $options); } From 48fab365920b153f4c6d36546205f03ca3d7cb4e Mon Sep 17 00:00:00 2001 From: laf Date: Tue, 8 Dec 2015 15:17:53 +0000 Subject: [PATCH 10/10] Check that $fields has value --- includes/rrdtool.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index c29d9bbc4..956649744 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -300,6 +300,7 @@ function rrdtool_escape($string, $maxlength=null){ } function rrdtool_tune($type, $filename, $max) { + $fields = array(); if ($type === 'port') { if ($max < 10000000) { return false; @@ -309,6 +310,8 @@ function rrdtool_tune($type, $filename, $max) { 'INOCTETS','OUTOCTETS','INERRORS','OUTERRORS','INUCASTPKTS','OUTUCASTPKTS','INNUCASTPKTS','OUTNUCASTPKTS','INDISCARDS','OUTDISCARDS','INUNKNOWNPROTOS','INBROADCASTPKTS','OUTBROADCASTPKTS','INMULTICASTPKTS','OUTMULTICASTPKTS' ); } - $options = "--maximum " . implode(":$max --maximum ", $fields). ":$max"; - rrdtool('tune', $filename, $options); + if (count($fields) > 0) { + $options = "--maximum " . implode(":$max --maximum ", $fields). ":$max"; + rrdtool('tune', $filename, $options); + } }
Oper Disable IgnoreRRD Tune Description