Skip to content

Commit b6526b8

Browse files
committed
Fixing Cacti#5163 & Cacti#5165 DSStats Enhancements
* Adds multiple percentile data to the Data Source Statistics tables * Converts the Hourly Cache to InnoDB * Some normalization rrdtool_function_graph() calling params outside of plugins * Fix issues with variance and standard deviation calculations in graph_variables.php
1 parent ba959e5 commit b6526b8

17 files changed

+367
-258
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Cacti CHANGELOG
5050
-feature#5120: Define cacti system paths as constants for better code checking
5151
-feature#5148: Allow theme-based include paths with master location
5252
-feature#5149: Allow CSS files to be loaded async #5149
53+
-feature#5163: DSSTATS - Add Additional Data Source Statics to Cacti
54+
-feature#5165: DSSTATS - Change data_source_stats_hourly_cache from Memory to INNODB
5355
-feature: Allow messages to be popup notifications
5456

5557
1.2.24

cacti.sql

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,8 +1485,6 @@ CREATE TABLE `data_source_stats_daily` (
14851485
`p50n` double DEFAULT NULL,
14861486
`p25n` double DEFAULT NULL,
14871487
`sum` double DEFAULT NULL,
1488-
`elements` double DEFAULT NULL,
1489-
`variance` double DEFAULT NULL,
14901488
`stddev` double DEFAULT NULL,
14911489
PRIMARY KEY (`local_data_id`,`rrd_name`,`cf`)
14921490
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
@@ -1507,8 +1505,6 @@ CREATE TABLE `data_source_stats_hourly` (
15071505
`p50n` double DEFAULT NULL,
15081506
`p25n` double DEFAULT NULL,
15091507
`sum` double DEFAULT NULL,
1510-
`elements` double DEFAULT NULL,
1511-
`variance` double DEFAULT NULL,
15121508
`stddev` double DEFAULT NULL,
15131509
PRIMARY KEY (`local_data_id`,`rrd_name`,`cf`)
15141510
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
@@ -1524,7 +1520,7 @@ CREATE TABLE `data_source_stats_hourly_cache` (
15241520
`value` DOUBLE DEFAULT NULL,
15251521
PRIMARY KEY (`local_data_id`,`time`,`rrd_name`),
15261522
KEY `time` USING BTREE (`time`)
1527-
) ENGINE=MEMORY;
1523+
) ENGINE=InnoDB ROW_FORMAT=Dynamic;
15281524

15291525
--
15301526
-- Table structure for table `data_source_stats_hourly_last`
@@ -1554,8 +1550,6 @@ CREATE TABLE `data_source_stats_monthly` (
15541550
`p50n` double DEFAULT NULL,
15551551
`p25n` double DEFAULT NULL,
15561552
`sum` double DEFAULT NULL,
1557-
`elements` double DEFAULT NULL,
1558-
`variance` double DEFAULT NULL,
15591553
`stddev` double DEFAULT NULL,
15601554
PRIMARY KEY (`local_data_id`,`rrd_name`,`cf`)
15611555
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
@@ -1576,8 +1570,6 @@ CREATE TABLE `data_source_stats_weekly` (
15761570
`p50n` double DEFAULT NULL,
15771571
`p25n` double DEFAULT NULL,
15781572
`sum` double DEFAULT NULL,
1579-
`elements` double DEFAULT NULL,
1580-
`variance` double DEFAULT NULL,
15811573
`stddev` double DEFAULT NULL,
15821574
PRIMARY KEY (`local_data_id`,`rrd_name`,`cf`)
15831575
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
@@ -1598,8 +1590,6 @@ CREATE TABLE `data_source_stats_yearly` (
15981590
`p50n` double DEFAULT NULL,
15991591
`p25n` double DEFAULT NULL,
16001592
`sum` double DEFAULT NULL,
1601-
`elements` double DEFAULT NULL,
1602-
`variance` double DEFAULT NULL,
16031593
`stddev` double DEFAULT NULL,
16041594
PRIMARY KEY (`local_data_id`,`rrd_name`,`cf`)
16051595
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;

graph.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,13 @@ function graph_properties() {
650650
<span class='textInfo'><?= __('RRDtool Command:'); ?></span><br>
651651
<?php
652652
$null_param = array();
653-
print @rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]);
653+
print @rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]);
654654
unset($graph_data_array['print_source']);
655655
?>
656656
<span class='textInfo'><?= __('RRDtool Says:'); ?></span><br>
657657
<?php
658658
if ($config['poller_id'] == 1) {
659-
print @rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]);
659+
print @rrdtool_function_graph(get_request_var('local_graph_id'), get_request_var('rra_id'), $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]);
660660
} else {
661661
print __esc('Not Checked');
662662
}

graph_image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
}
138138

139139
$null_param = array();
140-
$output = rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]);
140+
$output = rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]);
141141

142142
if ($output !== false && $output != '') {
143143
/* flush the headers now */
@@ -153,7 +153,7 @@
153153
/* get the error string */
154154
$graph_data_array['get_error'] = true;
155155
$null_param = array();
156-
rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]);
156+
rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]);
157157

158158
$error = ob_get_contents();
159159

graph_json.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164

165165
if ($config['poller_id'] == 1 || read_config_option('storage_location')) {
166166
$xport_meta = array();
167-
$output = rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, '', $xport_meta, $_SESSION[SESS_USER_ID]);
167+
168+
$output = rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, null, $xport_meta, $_SESSION[SESS_USER_ID]);
168169

169170
ob_end_clean();
170171
} else {
@@ -234,7 +235,7 @@
234235
$graph_data_array['get_error'] = true;
235236

236237
$null_param = array();
237-
rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]);
238+
rrdtool_function_graph(get_request_var('local_graph_id'), $rra_id, $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]);
238239

239240
$error = ob_get_contents();
240241

graphs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,10 +1714,10 @@ function graph_edit() {
17141714
<div class='cactiTable'>
17151715
<div style='float:left'>
17161716
<span class='textInfo'><?php print __('RRDtool Command:');?></span><br>
1717-
<pre><?php print @rrdtool_function_graph(get_request_var('id'), 1, $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]);?></pre>
1717+
<pre><?php print @rrdtool_function_graph(get_request_var('id'), 1, $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]);?></pre>
17181718
<span class='textInfo'><?php print __('RRDtool Says:');?></span><br>
17191719
<?php unset($graph_data_array['print_source']);?>
1720-
<pre><?php print($config['poller_id'] == 1 ? @rrdtool_function_graph(get_request_var('id'), 1, $graph_data_array, '', $null_param, $_SESSION[SESS_USER_ID]):__esc('Not Checked'));?></pre>
1720+
<pre><?php print($config['poller_id'] == 1 ? @rrdtool_function_graph(get_request_var('id'), 1, $graph_data_array, null, $null_param, $_SESSION[SESS_USER_ID]):__esc('Not Checked'));?></pre>
17211721
</div>
17221722
<?php
17231723
}

include/global_settings.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,12 @@
21782178
1 => __('All Statistical Metrics')
21792179
)
21802180
),
2181+
'dsstats_peak' => array(
2182+
'friendly_name' => __('Calculate Peaks Stats in Addition to Average Stats'),
2183+
'description' => __('This option will double the data collection time. If will use the MAX consolidation function and calculate statistics from the max values in each of the respective time ranges.'),
2184+
'method' => 'checkbox',
2185+
'default' => ''
2186+
),
21812187
'dsstats_parallel' => array(
21822188
'friendly_name' => __('Number of DSStats Processes'),
21832189
'description' => __('The number of concurrent DSStats processes to use to use to process all of the Data Sources.'),

install/upgrades/1_3_0.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ function ldap_convert_1_3_0() {
121121
'p50n',
122122
'p25n',
123123
'sum',
124-
'elements',
125-
'variance',
126124
'stddev'
127125
);
128126

@@ -147,11 +145,7 @@ function ldap_convert_1_3_0() {
147145
}
148146

149147
foreach ($columns as $index => $column) {
150-
if ($column == 'elements') {
151-
$type = "INT UNSIGNED NOT NULL DEFAULT '0'";
152-
} else {
153-
$type = 'DOUBLE';
154-
}
148+
$type = 'DOUBLE';
155149

156150
if (!db_column_exists($table, $column)) {
157151
$sql .= ($index == 0 ? '':', ') . " ADD COLUMN $column $type";
@@ -160,4 +154,6 @@ function ldap_convert_1_3_0() {
160154

161155
db_execute("$sql $suffix");
162156
}
157+
158+
db_execute('ALTER TABLE data_source_stats_hourly_cache ENGINE=InnoDB ROW_FORMAT=Dynamic');
163159
}

lib/boost.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function boost_poller_id_check() {
271271
return true;
272272
}
273273

274-
function boost_fetch_cache_check($local_data_id, $rrdtool_pipe = false) {
274+
function boost_fetch_cache_check($local_data_id, $rrdtool_pipe = null) {
275275
global $config;
276276

277277
if (read_config_option('boost_rrd_update_enable') == 'on') {
@@ -296,9 +296,9 @@ function boost_fetch_cache_check($local_data_id, $rrdtool_pipe = false) {
296296
/* process input parameters */
297297
if (!is_resource($rrdtool_pipe)) {
298298
$rrdtool_pipe = rrd_init();
299-
$close_pipe = true;
299+
$close_pipe = true;
300300
} else {
301-
$close_pipe = false;
301+
$close_pipe = false;
302302
}
303303

304304
/* get the information to populate into the rrd files */
@@ -336,7 +336,7 @@ function boost_return_cached_image(&$graph_data_array) {
336336
}
337337
}
338338

339-
function boost_graph_cache_check($local_graph_id, $rra_id, $rrdtool_pipe, &$graph_data_array, $return = true) {
339+
function boost_graph_cache_check($local_graph_id, $rra_id, $rrdtool_pipe = null, &$graph_data_array = array(), $return = true) {
340340
global $config;
341341

342342
/* include poller processing routines */
@@ -686,14 +686,12 @@ function boost_get_arch_table_names($latest_table = '') {
686686
* 4) Merge the results together
687687
* 5) Process the entire result set
688688
*
689-
* @param (int) local_data_id - the local data id to update
690-
* @param (resourse) rrdtool_pipe - a pointer to the rrdtool process
691-
* @param mixed $local_data_id
692-
* @param mixed $rrdtool_pipe
689+
* @param int local_data_id - the local data id to update
690+
* @param res|null rrdtool_pipe - a pointer to the rrdtool process
693691
*
694-
* @return (void)
692+
* @return void
695693
*/
696-
function boost_process_poller_output($local_data_id, $rrdtool_pipe = '') {
694+
function boost_process_poller_output($local_data_id, $rrdtool_pipe = null) {
697695
global $config, $database_default, $boost_sock, $boost_timeout, $debug, $get_memory, $memory_used;
698696

699697
static $archive_table = false;
@@ -815,11 +813,11 @@ function boost_process_poller_output($local_data_id, $rrdtool_pipe = '') {
815813
}
816814

817815
if (cacti_sizeof($results)) {
818-
$rrdp_auto_close = false;
816+
$local_init = false;
819817

820818
if (!$rrdtool_pipe) {
821-
$rrdtool_pipe = rrd_init();
822-
$rrdp_auto_close = true;
819+
$rrdtool_pipe = rrd_init();
820+
$local_init = true;
823821
}
824822

825823
/* create an array keyed off of each .rrd file */
@@ -995,7 +993,7 @@ function boost_process_poller_output($local_data_id, $rrdtool_pipe = '') {
995993

996994
boost_timer('results_cycle', BOOST_TIMER_END);
997995

998-
if ($rrdp_auto_close) {
996+
if ($local_init) {
999997
rrd_close($rrdtool_pipe);
1000998
}
1001999
}
@@ -1006,7 +1004,7 @@ function boost_process_poller_output($local_data_id, $rrdtool_pipe = '') {
10061004
return cacti_sizeof($results);
10071005
}
10081006

1009-
function boost_rrdtool_get_last_update_time($rrd_path, &$rrdtool_pipe) {
1007+
function boost_rrdtool_get_last_update_time($rrd_path, $rrdtool_pipe) {
10101008
$return_value = 0;
10111009

10121010
/* check if the rrd_path is empty
@@ -1019,7 +1017,7 @@ function boost_rrdtool_get_last_update_time($rrd_path, &$rrdtool_pipe) {
10191017
return time();
10201018
}
10211019

1022-
if (read_config_option('storage_location')) {
1020+
if (read_config_option('storage_location') > 0) {
10231021
$file_exists = rrdtool_execute("file_exists $rrd_path" , true, RRDTOOL_OUTPUT_BOOLEAN, $rrdtool_pipe, 'BOOST');
10241022
} else {
10251023
$file_exists = file_exists($rrd_path);
@@ -1108,7 +1106,7 @@ function boost_get_rrd_filename_and_template($local_data_id) {
11081106
return array('rrd_path' => $rrd_path, 'rrd_template' => trim($rrd_template));
11091107
}
11101108

1111-
function boost_rrdtool_function_create($local_data_id, $show_source, &$rrdtool_pipe) {
1109+
function boost_rrdtool_function_create($local_data_id, $show_source, $rrdtool_pipe) {
11121110
global $config;
11131111

11141112
/**
@@ -1122,7 +1120,7 @@ function boost_rrdtool_function_create($local_data_id, $show_source, &$rrdtool_p
11221120
/* ok, if that passes lets check to make sure an rra does not already
11231121
exist, the last thing we want to do is overwrite data! */
11241122
if ($show_source != true) {
1125-
if (read_config_option('storage_location')) {
1123+
if (read_config_option('storage_location') > 0) {
11261124
$file_exists = rrdtool_execute("file_exists $data_source_path" , true, RRDTOOL_OUTPUT_BOOLEAN, $rrdtool_pipe, 'POLLER');
11271125
} else {
11281126
$file_exists = file_exists($data_source_path);
@@ -1297,12 +1295,15 @@ function boost_rrdtool_function_create($local_data_id, $show_source, &$rrdtool_p
12971295
}
12981296

12991297
/* boost_rrdtool_function_update - a re-write of the Cacti rrdtool update command
1300-
specifically designed for bulk updates.
1301-
@arg $local_data_id - the data source to obtain information from
1302-
@arg $rrd_path - the path to the RRD file
1303-
@arg $rrd_update_template - the order in which values need to be added
1304-
@arg $rrd_update_values - values to include in the database */
1305-
function boost_rrdtool_function_update($local_data_id, $rrd_path, $rrd_update_template, &$rrd_update_values, &$rrdtool_pipe) {
1298+
* specifically designed for bulk updates.
1299+
*
1300+
* @param $local_data_id - the data source to obtain information from
1301+
* @param $rrd_path - the path to the RRD file
1302+
* @param $rrd_update_template - the order in which values need to be added
1303+
* @param $rrd_update_values - values to include in the database
1304+
* @param $rrdtool_pipe - the proess structure from rrd_init
1305+
*/
1306+
function boost_rrdtool_function_update($local_data_id, $rrd_path, $rrd_update_template, &$rrd_update_values, $rrdtool_pipe = null) {
13061307
/* lets count the number of rrd files processed */
13071308
$rrds_processed = 0;
13081309

@@ -1318,7 +1319,7 @@ function boost_rrdtool_function_update($local_data_id, $rrd_path, $rrd_update_te
13181319
}
13191320

13201321
/* create the rrd if one does not already exist */
1321-
if (read_config_option('storage_location')) {
1322+
if (read_config_option('storage_location') > 0) {
13221323
$file_exists = rrdtool_execute("file_exists $rrd_path" , true, RRDTOOL_OUTPUT_BOOLEAN, $rrdtool_pipe, 'BOOST');
13231324
} else {
13241325
$file_exists = file_exists($rrd_path);

0 commit comments

Comments
 (0)