diff --git a/cacti.sql b/cacti.sql index 5a1c66c98e..f8cf976230 100644 --- a/cacti.sql +++ b/cacti.sql @@ -1289,6 +1289,7 @@ CREATE TABLE `data_source_profiles_rra` ( `name` varchar(255) NOT NULL DEFAULT '', `steps` int(10) unsigned DEFAULT '1', `rows` int(10) unsigned NOT NULL DEFAULT '700', + `timespan` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `data_source_profile_id` (`data_source_profile_id`) ) ENGINE=InnoDB COMMENT='Stores RRA Definitions for Data Source Profiles'; @@ -1297,15 +1298,14 @@ CREATE TABLE `data_source_profiles_rra` ( -- Dumping data for table `data_source_profiles_rra` -- -INSERT INTO `data_source_profiles_rra` VALUES (1,1,'Daily (5 Minute Average)',1,600); -INSERT INTO `data_source_profiles_rra` VALUES (2,1,'Weekly (30 Minute Average)',6,700); -INSERT INTO `data_source_profiles_rra` VALUES (3,1,'Monthly (2 Hour Average)',24,775); -INSERT INTO `data_source_profiles_rra` VALUES (4,1,'Yearly (1 Day Average)',288,797); -INSERT INTO `data_source_profiles_rra` VALUES (5,2,'30 Second Samples',1,1500); -INSERT INTO `data_source_profiles_rra` VALUES (6,2,'15 Minute Average',30,1346); -INSERT INTO `data_source_profiles_rra` VALUES (7,2,'1 Hour Average',120,1445); -INSERT INTO `data_source_profiles_rra` VALUES (8,2,'4 Hour Average',480,4380); - +INSERT INTO `data_source_profiles_rra` VALUES (1,1,'Daily (5 Minute Average)',1,600,86400); +INSERT INTO `data_source_profiles_rra` VALUES (2,1,'Weekly (30 Minute Average)',6,700,604800); +INSERT INTO `data_source_profiles_rra` VALUES (3,1,'Monthly (2 Hour Average)',24,775,2618784); +INSERT INTO `data_source_profiles_rra` VALUES (4,1,'Yearly (1 Day Average)',288,797,31536000); +INSERT INTO `data_source_profiles_rra` VALUES (5,2,'30 Second Samples',1,1500,86400); +INSERT INTO `data_source_profiles_rra` VALUES (6,2,'15 Minute Average',30,1346,604800); +INSERT INTO `data_source_profiles_rra` VALUES (7,2,'1 Hour Average',120,1445,2618784); +INSERT INTO `data_source_profiles_rra` VALUES (8,2,'4 Hour Average',480,4380,31536000); -- -- Table structure for table `data_source_purge_action` diff --git a/data_source_profiles.php b/data_source_profiles.php index 39796dd976..9b29f16262 100644 --- a/data_source_profiles.php +++ b/data_source_profiles.php @@ -176,6 +176,7 @@ function form_save() { $save['name'] = form_input_validate(get_nfilter_request_var('name'), 'name', '', true, 3); $save['data_source_profile_id'] = form_input_validate(get_request_var('profile_id'), 'profile_id', '^[0-9]+$', false, 3); $save['steps'] = form_input_validate(get_nfilter_request_var('steps'), 'steps', '^[0-9]+$', false, 3); + $save['timespan'] = form_input_validate(get_nfilter_request_var('timespan'), 'timespan', '^[0-9]+$', false, 3); if ($save['steps'] != '1') { $save['steps'] /= $sampling_interval; @@ -454,7 +455,7 @@ function item_edit() { function get_span() { $.get('data_source_profiles.php?action=ajax_span&profile_id='+profile_id+'&span='+$('#steps').val()+'&rows='+$('#rows').val(), function(data) { - $('#row_timespan').find('.formColumnRight').empty().html(''+data+''); + $('#row_retention').find('.formColumnRight').empty().html(''+data+''); }); } @@ -466,7 +467,7 @@ function item_edit() { --------------------- */ function profile_edit() { - global $fields_profile_edit; + global $fields_profile_edit, $timespans; /* ================= input validation ================= */ get_filter_request_var('id'); @@ -505,7 +506,8 @@ function profile_edit() { $display_text = array( array('display' => __('Name'), 'align' => 'left'), - array('display' => __('Effective Timespan'), 'align' => 'left'), + array('display' => __('Data Retention'), 'align' => 'left'), + array('display' => __('Graph Timespan'), 'align' => 'left'), array('display' => __('Steps'), 'align' => 'left'), array('display' => __('Rows'), 'align' => 'left'), ); @@ -524,6 +526,9 @@ function profile_edit() { + + + diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 5f863add70..0d1449dce8 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -1,6 +1,7 @@ Cacti CHANGELOG 1.1.17 +-issue#819: Customized timespans for graphs -issue#888: Rebuilding Poller Cache when External data sources are present results in false positive warnings in the log -issue#891: Database.php unable to connect to MySQL when using port different than 3306 -issue#893: Warning messages when duplicating CDEF objects diff --git a/graph.php b/graph.php index 2b851e41dd..0c900ee57f 100644 --- a/graph.php +++ b/graph.php @@ -110,7 +110,12 @@ case 'view': if (sizeof($rras)) { $graph_end = time(); foreach ($rras as $rra) { - $graph_start = $graph_end - ($rra['step'] * $rra['rows'] * $rra['steps']); + if (!empty($rra['timespan'])) { + $graph_start = $graph_end - $rra['timespan']; + } else { + $graph_start = $graph_end - ($rra['step'] * $rra['rows'] * $rra['steps']); + } + $aggregate_url = aggregate_build_children_url(get_request_var('local_graph_id'), $graph_start, $graph_end, $rra['id']); ?> diff --git a/include/global_arrays.php b/include/global_arrays.php index fe0f0d4829..cd41f784fa 100644 --- a/include/global_arrays.php +++ b/include/global_arrays.php @@ -90,6 +90,7 @@ $cacti_version_codes = array( '1.1.14' => '0101', '1.1.15' => '0101', '1.1.16' => '0101', + '1.1.17' => '0101', ); $messages = array( @@ -545,6 +546,27 @@ $heartbeats = array( 86400 => __('1 Day') ); +$timespans = array( + 3600 => __('%d Hour', 1), + 7200 => __('%d Hours', 2), + 14400 => __('%d Hours', 4), + 21600 => __('%d Hours', 6), + 43200 => __('%d Hours', 12), + 86400 => __('%d Day', 1), + 172800 => __('%d Days', 2), + 345600 => __('%d Days', 4), + 604800 => __('%d Week', 1), + 1209600 => __('%d Weeks', 2), + 1814400 => __('%d Weeks', 3), + 2618784 => __('%d Month', 1), + 5237568 => __('%d Months', 2), + 7856352 => __('%d Months', 3), + 10475136 => __('%d Months', 4), + 15712704 => __('%d Months', 6), + 31536000 => __('%d Year', 1), + 63072000 => __('%d Years', 2) +); + $poller_intervals = array( 10 => __('Every %d Seconds', 10), 15 => __('Every %d Seconds', 15), diff --git a/include/global_form.php b/include/global_form.php index 7f30b1704f..81a812b340 100644 --- a/include/global_form.php +++ b/include/global_form.php @@ -123,8 +123,15 @@ $fields_profile_rra_edit = array( 'default' => '600' ), 'timespan' => array( + 'method' => 'drop_array', + 'friendly_name' => __('Default Timespan'), + 'description' => __('When viewing a Graph based upon the RRA in question, the default Timespan to show for that Graph.'), + 'value' => '|arg1:timespan|', + 'array' => $timespans + ), + 'retention' => array( 'method' => 'other', - 'friendly_name' => __('Effective Retention'), + 'friendly_name' => __('Data Retention'), 'description' => __('Based upon the Aggregation Level, the Rows, and the Polling Interval the amount of data that will be retained in the RRA'), 'value' => '' ), diff --git a/install/upgrades/1_1_17.php b/install/upgrades/1_1_17.php new file mode 100644 index 0000000000..a2a7c4703d --- /dev/null +++ b/install/upgrades/1_1_17.php @@ -0,0 +1,50 @@ + $name) { + if ($timespan > $index) { + $last = $index; + continue; + } elseif ($timespan == $index) { + return $index; + } else { + return $last; + } + } + + return $last; +} + /* get_browser_query_string - returns the full url, including args requested by the browser @returns - the url requested by the browser */ function get_browser_query_string() {