mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-08 21:16:17 +09:00
Inform the primary Cacti administrator of problems by Email
This commit is contained in:
1 parent
bbf40bc253
commit
9a5cf5ae54
4 files changed
+44
-31
No files matched your search
@@ -108,6 +108,7 @@ Cacti CHANGELOG
|
||||
-feature: Allow ASCII filepath paths to not be found on settings save
|
||||
-feature: Provide option to debug width errors where output exceeds column width
|
||||
-feature: Allow snmpagent to be disabled for very large installs
|
||||
-feature: Inform the primary Cacti administrator of problems by Email
|
||||
|
||||
1.1.38
|
||||
-issue#1501: cmd.php poller not stripping alpha from snmp get values
|
||||
|
||||
@@ -472,33 +472,6 @@ $settings = array(
|
||||
'description' => __('When disabled, Cacti Automation will not actively create any Tree Item. This is useful when adjusting Host or Graph settings so as to avoid creating new Tree Entries each time you save an object. Invoking Rules manually will still be possible.'),
|
||||
'default' => '',
|
||||
),
|
||||
'automation_email' => array(
|
||||
'method' => 'textbox',
|
||||
'friendly_name' => __('Automation recipient email address'),
|
||||
'description' => __('Default email address automation report is sent to per network discovery. Leave this field empty to suppress report generation.'),
|
||||
'value' => '|arg1:automation_email|',
|
||||
'default' => '',
|
||||
'max_length' => '128',
|
||||
'size' => '40'
|
||||
),
|
||||
'automation_email_from' => array(
|
||||
'method' => 'textbox',
|
||||
'friendly_name' => __('Automation sender email address'),
|
||||
'description' => __('Default email address automation report is sent from per network discovery. Leave this field empty to use default Cacti email address.'),
|
||||
'value' => '|arg1:automation_email_from|',
|
||||
'default' => '',
|
||||
'max_length' => '128',
|
||||
'size' => '40'
|
||||
),
|
||||
'automation_email_name' => array(
|
||||
'method' => 'textbox',
|
||||
'friendly_name' => __('Automation sender display name'),
|
||||
'description' => __('Default email display name automation report is sent from per network discovery. Leave this field empty to use default Cacti email display name.'),
|
||||
'value' => '|arg1:automation_email_name|',
|
||||
'default' => '',
|
||||
'max_length' => '128',
|
||||
'size' => '40'
|
||||
),
|
||||
),
|
||||
'snmp' => array(
|
||||
'general_header' => array(
|
||||
@@ -1113,6 +1086,14 @@ $settings = array(
|
||||
'method' => 'spacer',
|
||||
'collapsible' => 'true'
|
||||
),
|
||||
'admin_user' => array(
|
||||
'friendly_name' => __('Primary Admin'),
|
||||
'description' => __('The name of the primary administrative account that will automatically receive Emails when the Cacti system experiences issues. To receive these Emails, ensure that your mail settings are correct, and the the administrative account has an Email address that is set.'),
|
||||
'method' => 'drop_sql',
|
||||
'none_value' => __('No User'),
|
||||
'sql' => 'SELECT id AS id, username AS name FROM user_auth WHERE realm = 0 ORDER BY username',
|
||||
'default' => '0'
|
||||
),
|
||||
'guest_user' => array(
|
||||
'friendly_name' => __('Guest User'),
|
||||
'description' => __('The name of the guest user for viewing graphs; is \'No User\' by default.'),
|
||||
@@ -1384,7 +1365,7 @@ $settings = array(
|
||||
),
|
||||
'cn_email' => array(
|
||||
'friendly_name' => __('Email'),
|
||||
'description' => __('Field that will replace the email taken from LDAP. (on windows: mail)'),
|
||||
'description' => __('Field that will replace the Email taken from LDAP. (on windows: mail)'),
|
||||
'method' => 'textbox',
|
||||
'max_length' => '255'
|
||||
),
|
||||
|
||||
@@ -3724,6 +3724,29 @@ function general_header() {
|
||||
}
|
||||
}
|
||||
|
||||
function admin_email($subject, $message) {
|
||||
if (read_config_option('admin_user')) {
|
||||
$admin_details = db_fetch_row_prepared('SELECT full_name, email_address
|
||||
FROM user_auth
|
||||
WHERE id = ?',
|
||||
array(read_config_option('admin_user')));
|
||||
|
||||
if (sizeof($admin_details)) {
|
||||
$from[0] = read_config_option('settings_from_email');
|
||||
$from[1] = read_config_option('settings_from_name');
|
||||
|
||||
$to[0] = $admin_details['email_address'];
|
||||
$to[1] = $admin_details['full_name'];
|
||||
|
||||
send_mail($to, $from, $subject, $message, strip_tags($message), '', true);
|
||||
} else {
|
||||
cacti_log('WARNING: Primay Admin account not found! Unable to send administrative Email.', false, 'SYSTEM');
|
||||
}
|
||||
} else {
|
||||
cacti_log('WARNING: Primary Admin account not set! Unable to send administrative Email.', false, 'SYSTEM');
|
||||
}
|
||||
}
|
||||
|
||||
function send_mail($to, $from, $subject, $body, $attachments = '', $headers = '', $html = false) {
|
||||
$fromname = '';
|
||||
if (is_array($from)) {
|
||||
@@ -4712,6 +4735,7 @@ function CactiErrorHandler($level, $message, $file, $line, $context) {
|
||||
if ($plugin != '') {
|
||||
api_plugin_disable_all($plugin);
|
||||
cacti_log("ERRORS DETECTED - DISABLING PLUGIN '$plugin'");
|
||||
admin_email(__('Cacti System Warning'), __('Cacti disabled plugin %s due to the following error: %s! See the Cacti logfile for more details.', $plugin, $error));
|
||||
}
|
||||
break;
|
||||
case E_RECOVERABLE_ERROR:
|
||||
@@ -4772,6 +4796,7 @@ function CactiShutdownHandler () {
|
||||
if ($plugin != '') {
|
||||
api_plugin_disable_all($plugin);
|
||||
cacti_log("ERRORS DETECTED - DISABLING PLUGIN '$plugin'");
|
||||
admin_email(__('Cacti System Warning'), __('Cacti disabled plugin %s due to the following error: %s! See the Cacti logfile for more details.', $plugin, $message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -286,6 +286,7 @@ if ((isset($poller_lastrun) && isset($poller_interval) && $poller_lastrun > 0) &
|
||||
/* check to see whether we have the poller interval set lower than the poller is actually ran, if so, issue a warning */
|
||||
if ((($poller_start - $poller_lastrun - 5) > MAX_POLLER_RUNTIME) && ($poller_lastrun > 0)) {
|
||||
cacti_log("WARNING: $task_type is out of sync with the Poller Interval! The Poller Interval is '$poller_interval' seconds, with a maximum of a '$min_period' second $task_type, but " . number_format_i18n($poller_start - $poller_lastrun, 1) . ' seconds have passed since the last poll!', true, 'POLLER');
|
||||
admin_email(__('Cacti System Warning'), __('WARNING: %s is out of sync with the Poller Interval! The Poller Interval is \'%d\' seconds, with a maximum of a \'%d\' seconds, but %d seconds have passed since the last poll!', $task_type, $poller_interval, $min_period, number_format_i18n($poller_start - $poller_lastrun, 1)));
|
||||
}
|
||||
|
||||
set_config_option('poller_lastrun_' . $poller_id, (int)$poller_start);
|
||||
@@ -387,7 +388,8 @@ while ($poller_runs_completed < $poller_runs) {
|
||||
array($poller_id));
|
||||
|
||||
if ($running_processes) {
|
||||
cacti_log("WARNING: There are '$running_processes' detected as overrunning a polling process, please investigate", true, 'POLLER');
|
||||
cacti_log("WARNING: There are '$running_processes' detected as overrunning a polling cycle, please investigate", true, 'POLLER');
|
||||
admin_email(__('Cacti System Warning'), __('WARNING: There are \'%d\' detected as overrunning a polling cycle, please investigate.', $running_processes));
|
||||
}
|
||||
|
||||
db_execute_prepared('DELETE FROM poller_time
|
||||
@@ -447,6 +449,7 @@ while ($poller_runs_completed < $poller_runs) {
|
||||
}
|
||||
|
||||
cacti_log("WARNING: Poller Output Table not Empty. Issues: $count, $issue_list", true, 'POLLER');
|
||||
admin_email(__('Cacti System Warning'), __('WARNING: Poller Output Table not Empty. Issues: %d, %s.', $count, $issue_list));
|
||||
|
||||
db_execute_prepared('DELETE po
|
||||
FROM poller_output AS po
|
||||
@@ -454,7 +457,8 @@ while ($poller_runs_completed < $poller_runs) {
|
||||
ON po.local_data_id=dl.id
|
||||
LEFT JOIN host AS h
|
||||
ON dl.host_id=h.id
|
||||
WHERE h.poller_id = ? OR h.id IS NULL',
|
||||
WHERE h.poller_id = ?
|
||||
OR h.id IS NULL',
|
||||
array($poller_id));
|
||||
}
|
||||
|
||||
@@ -467,7 +471,8 @@ while ($poller_runs_completed < $poller_runs) {
|
||||
|
||||
/* exit poller if spine is selected and file does not exist */
|
||||
if (($poller_type == '2') && (!file_exists(read_config_option('path_spine')))) {
|
||||
cacti_log('ERROR: The path: ' . read_config_option('path_spine') . ' is invalid. Can not continue', true, 'POLLER');
|
||||
cacti_log('ERROR: The spine path: ' . read_config_option('path_spine') . ' is invalid. Poller can not continue!', true, 'POLLER');
|
||||
admin_email(__('Cacti System Warning'), __('ERROR: The spine path: %s is invalid. Poller can not continue!', read_config_option('path_spine')));
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -608,6 +613,7 @@ while ($poller_runs_completed < $poller_runs) {
|
||||
/* end the process if the runtime exceeds MAX_POLLER_RUNTIME */
|
||||
if (($poller_start + MAX_POLLER_RUNTIME) < time()) {
|
||||
cacti_log('Maximum runtime of ' . MAX_POLLER_RUNTIME . ' seconds exceeded. Exiting.', true, 'POLLER');
|
||||
admin_email(__('Cacti System Warning'), __('Maximum runtime of %d seconds exceeded. Exiting.', MAX_POLLER_RUNTIME));
|
||||
|
||||
/* generate a snmp notification */
|
||||
snmpagent_poller_exiting();
|
||||
|
||||
Reference in new issue
Block a user