Skip to content

Commit

Permalink
Fixing #5439 - DSStats Logging Issues
Browse files Browse the repository at this point in the history
DSStats - missing values in log message
  • Loading branch information
TheWitness committed Aug 13, 2023
1 parent f528dc5 commit 638b910
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Cacti CHANGELOG
-issue#5426: Importing a legacy Data Query Template can result in the Template being unusable
-issue#5427: Unable to hook the settings.php page with JavaScript action
-issue#5434: Remove SQL Mode NO_AUTO_CREATE_USER as it's deprecated and removed from recent MySQL releases
-issue#5439: DSStats - missing values in log message
-issue#5440: Device class not saved when importing a template during a new installation
-issue#5446: Duplication functions for Graph/Template and Data Source/Template do not return an id
-issue#5447: Duplication of Device Templates happens in the base Cacti file and not in an API file
Expand Down
12 changes: 7 additions & 5 deletions lib/dsstats.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ function dsstats_debug($message) {
* and stores that information into the various database tables.
*
* @param $interval - (string) either 'daily', 'weekly', 'monthly', or 'yearly'
* @param $type - (string) the statistics type to store
* @param $thread_id - (int) the dsstats parallel thread id
*
* @return - NULL
*/
function dsstats_get_and_store_ds_avgpeak_values($interval, $thread_id = 1) {
global $config, $type;
function dsstats_get_and_store_ds_avgpeak_values($interval, $type, $thread_id = 1) {
global $config;

global $total_user, $total_system, $total_real, $total_dsses;
global $user_time, $system_time, $real_time, $rrd_files;
Expand Down Expand Up @@ -660,8 +661,8 @@ function dsstats_log_statistics($type) {

db_execute("DELETE FROM settings
WHERE name LIKE 'dsstats_rrd_%$sub_type%'
OR name LIKE 'dsstats_total_rrds_%$sub_type%'
OR name LIKE 'dsstats_total_dsses_%$sub_type%'");
OR name LIKE 'dsstats_total_rrds%_$sub_type%'
OR name LIKE 'dsstats_total_dsses%_$sub_type%'");
} else {
$cacti_stats = sprintf('Time:%01.2f Type:%s', $end - $start, $type);
}
Expand Down Expand Up @@ -1124,7 +1125,7 @@ function dsstats_boost_bottom() {
sleep(2);
}

dsstats_get_and_store_ds_avgpeak_values('daily');
dsstats_get_and_store_ds_avgpeak_values('daily', 'child', 0);

dsstats_log_statistics('DAILY');
}
Expand Down Expand Up @@ -1327,6 +1328,7 @@ function dsstats_launch_children($type) {
function dsstats_get_subtype($type) {
switch($type) {
case 'master':
case 'pmaster':
return 'child';

break;
Expand Down
18 changes: 8 additions & 10 deletions poller_dsstats.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
switch ($type) {
case 'pmaster':
if (read_config_option('dsstats_enable') == 'on' || $force) {
dsstats_master_handler($force, $fpartition);
dsstats_master_handler($type, $force, $fpartition);
}

break;
Expand All @@ -176,7 +176,7 @@
case 'bchild': // Launched by the boost process
$child_start = microtime(true);

dsstats_get_and_store_ds_avgpeak_values('daily', $thread_id);
dsstats_get_and_store_ds_avgpeak_values('daily', $type, $thread_id);

$total_time = microtime(true) - $child_start;

Expand All @@ -187,9 +187,9 @@
$child_start = microtime(true);

dsstats_debug(sprintf('Daily Stats Master Child %s Executing', $thread_id));
dsstats_get_and_store_ds_avgpeak_values('weekly', $thread_id);
dsstats_get_and_store_ds_avgpeak_values('monthly', $thread_id);
dsstats_get_and_store_ds_avgpeak_values('yearly', $thread_id);
dsstats_get_and_store_ds_avgpeak_values('weekly', $type, $thread_id);
dsstats_get_and_store_ds_avgpeak_values('monthly', $type, $thread_id);
dsstats_get_and_store_ds_avgpeak_values('yearly', $type, $thread_id);

$total_time = microtime(true) - $child_start;

Expand Down Expand Up @@ -226,9 +226,7 @@ function dsstats_insert_hourly_data_into_cache() {
ON DUPLICATE KEY UPDATE average=VALUES(average), peak=VALUES(peak)');
}

function dsstats_master_handler($force, $fpartition) {
global $type;

function dsstats_master_handler($type, $force, $fpartition) {
/* read some important settings relative to timing from the database */
$major_time = date('H:i:s', strtotime(read_config_option('dsstats_major_update_time')));
$daily_interval = read_config_option('dsstats_daily_interval');
Expand All @@ -249,7 +247,7 @@ function dsstats_master_handler($force, $fpartition) {
// Insert new rows into cache
dsstats_insert_hourly_data_into_cache();

dsstats_log_statistics('HOURLY');
dsstats_log_statistics('HOURLY', $type);

/* see if boost is active or not */
$boost_active = read_config_option('boost_rrd_update_enable');
Expand Down Expand Up @@ -296,7 +294,7 @@ function dsstats_master_handler($force, $fpartition) {
sleep(2);
}

dsstats_log_statistics('DAILY');
dsstats_log_statistics('DAILY', $type);
}
}

Expand Down

0 comments on commit 638b910

Please sign in to comment.