Skip to content

Commit

Permalink
QA: Runtime Limit Threshold Wordsmithing
Browse files Browse the repository at this point in the history
* We only log in English by policy.
* Friendly Names use Title Case.
* Convert the poller_warning_1h_count to a drop_array.
* Add 'Disabled' for the 0 setting in the array.
  • Loading branch information
TheWitness committed Dec 28, 2024
1 parent 8d5cfcf commit 4228961
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
40 changes: 26 additions & 14 deletions include/global_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1747,33 +1747,45 @@
'method' => 'spacer',
),
'poller_warning_1h_count' => array(
'friendly_name' => __('1h count warning threshold'),
'description' => __('When this count of guarded ratio (below) is reached in one hour, warning will be written to log and email will be send. 0 = disable.'),
'method' => 'textbox',
'friendly_name' => __('One Hour Count Warning Threshold'),
'description' => __('When the count of the Poller Guarded Ratio (below) is reached in one hour, a warning will be written to log and email will be sent to the Primary Cact Administraror.'),
'method' => 'drop_array',
'default' => '3',
'max_length' => 1,
'size' => 4,
),
'array' => array(
'0' => __('Disabled'),
'1' => __('%d Poller Intervals', 1),
'2' => __('%d Poller Intervals', 2),
'3' => __('%d Poller Intervals', 3),
'4' => __('%d Poller Intervals', 4),
'5' => __('%d Poller Intervals', 5),
'6' => __('%d Poller Intervals', 6),
'7' => __('%d Poller Intervals', 7),
'8' => __('%d Poller Intervals', 8),
'9' => __('%d Poller Intervals', 9),
'10' => __('%d Poller Intervals', 10),
)
),
'poller_warning_1h_ratio' => array(
'friendly_name' => __('1 hour guarded poller ratio run/max'),
'description' => __('Define guarded ratio poller run/max time (in percent).'),
'friendly_name' => __('One Hour Guarded Poller Ratio run/max'),
'description' => __('Define a Guarded Poller Ratio run/max time (in percent).'),
'method' => 'drop_array',
'default' => '70',
'array' => array(
'0' => '0',
'0' => __('Disabled'),
'50' => '50',
'60' => '60',
'70' => '70',
'80' => '80',
'90' => '90',)
),
'90' => '90'
)
),
'poller_warning_24h_ratio' => array(
'friendly_name' => __('24 hours guarded poller ratio run/max'),
'description' => __('Define guarded average ratio poller run/max time (in percent). When it is reached, warning will be written to log and email will be send. 0 = disable'),
'friendly_name' => __('24 Hour Guarded Poller Ratio run/max'),
'description' => __('Define a Guarded average Ratio Poller run/max time (in percent). When it is reached, warning will be written to log and email will be sent to the Primary Cacti administrator.'),
'method' => 'drop_array',
'default' => '60',
'array' => array(
'0' => '0',
'0' => __('Disabled'),
'50' => '50',
'60' => '60',
'70' => '70',
Expand Down
12 changes: 6 additions & 6 deletions poller.php
Original file line number Diff line number Diff line change
Expand Up @@ -1325,14 +1325,14 @@ function poller_run_stats($loop_start) {
$count = db_fetch_cell('SELECT COUNT(total_time) FROM poller_time_stats');

if ($count > 0) {
$ratio = round($sum / $count,2);
$ratio = round($sum / $count, 2);

cacti_log(__("24 hours avg. poller run time is $ratio seconds, min: $min, max: $max") , true, 'POLLER');
cacti_log(sprintf("24 Hour Average Poller run time is %0.2f seconds, min: %s , max: %s", $ratio, $min, $max), true, 'POLLER');

if ($ratio / $poller_interval > $threshold_24h / 100 && $threshold_24h > 0) {
cacti_log(__("WARNING: 24 hours poller avg. run time reached more than $threshold_24h% of time limit") , true, 'POLLER');
cacti_log(sprintf("WARNING: 24 Hour Poller Average run time reached more than %s percent of time limit.", $threshold_24h), true, 'POLLER');

admin_email(__('Cacti System Warning'), __('WARNING: 24 hours Poller[%d] avg. run time is %f seconds (more than %d % of time limit)', $poller_id, $ratio,$threshold_24h));
admin_email(__('Cacti System Warning'), __('WARNING: 24 Hour Poller[%d] Average run time threshold breached. It is %f seconds (more than %d % of threshold.)', $poller_id, $ratio, $threshold_24h));
}
}
}
Expand All @@ -1346,9 +1346,9 @@ function poller_run_stats($loop_start) {
array($poller_interval, $threshold_1h));

if ($count > $threshold_1h_count && $threshold_1h_count > 0) {
cacti_log(__("WARNING: In last hour poller run time $count times (limit $threshold_1h_count) reached more than $threshold_1h% of time limit") , true, 'POLLER');
cacti_log(sprintf("WARNING: In the last hour, the Poller run time exceeded the threshold %d times (limit %d) by %d percent of time limit.", $count, $threshold_1h_count, $threshold_1h) , true, 'POLLER');

admin_email(__('Cacti System Warning'), __('WARNING: In last hour Poller[%d] run time %d times reached more than %d % of time limit', $poller_id, $threshold_1h_count, $threshold_1h));
admin_email(__('Cacti System Warning'), __('WARNING: In last hour Poller[%d] run time exceeded the threshold %d times (limit %d) by %d percent of the time limit.', $poller_id, $count, $threshold_1h_count, $threshold_1h));
}
}

Expand Down

0 comments on commit 4228961

Please sign in to comment.