Added an option to disable events related to unknown modules.

(cherry picked from commit 17bf92b695)
This commit is contained in:
Ramon Novoa 2016-11-29 09:11:00 +01:00
parent 044b9e374a
commit 853d9ae432
4 changed files with 28 additions and 4 deletions

View File

@ -503,6 +503,9 @@ console_pass pandora
# Passphrase used to generate the key for password encryption (PANDORA FMS ENTERPRISE ONLY).
#encryption_passphrase passphrase
# Enable (1) or disable (0) events related to the unknown module status.
unknown_events 1
# Time interval (as a multiple of the module interval) before a module becomes unknown. Twice the module's interval by default.
#unknown_interval 2

View File

@ -310,6 +310,9 @@ console_pass pandora
# Passphrase used to generate the key for password encryption (PANDORA FMS ENTERPRISE ONLY).
#encryption_passphrase passphrase
# Enable (1) or disable (0) events related to the unknown module status.
unknown_events 1
# Time interval (as a multiple of the module interval) before a module becomes unknown. Twice the module's interval by default.
#unknown_interval 2

View File

@ -416,6 +416,9 @@ sub pandora_load_config {
# External .enc files for XML::Parser.
$pa_config->{"enc_dir"} = ""; # > 6.0SP4
# Enable (1) or disable (0) events related to the unknown status.
$pa_config->{"unknown_events"} = 1; # > 6.0SP4
# Check for UID0
if ($pa_config->{"quiet"} != 0){
if ($> == 0){
@ -919,6 +922,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^enc_dir\s+(.*)/i) {
$pa_config->{'enc_dir'} = clean_blank($1);
}
elsif ($parametro =~ m/^unknown_events\s+([0-1])/i) {
$pa_config->{'unknown_events'} = clean_blank($1);
}
} # end of loop for parameter #
# Set to RDBMS' standard port

View File

@ -3810,6 +3810,11 @@ sub generate_status_event ($$$$$$$$) {
pandora_event ($pa_config, "Warmup mode for events ended.", 0, 0, 0, 0, 0, 'system', 0, $dbh);
}
# Disable events related to the unknown status.
if ($pa_config->{'unknown_events'} == 0 && ($last_status == 3 || $status == 3)) {
return;
}
# disable event just recovering from 'Unknown' without status change
if($last_status == 3 && $status == $last_known_status && $module->{'disabled_types_event'} ) {
my $disabled_types_event;
@ -4604,8 +4609,11 @@ sub pandora_module_unknown ($$) {
load_module_macros ($module->{'module_macros'}, \%macros);
$description = subst_alert_macros ($description, \%macros, $pa_config, $dbh, $agent, $module);
pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'},
$severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'});
# Are unknown events enabled?
if ($pa_config->{'unknown_events'} == 1) {
pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'},
$severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'});
}
}
# Regular module
else {
@ -4631,8 +4639,12 @@ sub pandora_module_unknown ($$) {
logger($pa_config, "Alerts inhibited for agent '" . $agent->{'nombre'} . "'.", 10);
}
my $do_event = 0;
if (!defined($module->{'disabled_types_event'}) || $module->{'disabled_types_event'} eq "") {
my $do_event;
# Are unknown events enabled?
if ($pa_config->{'unknown_events'} == 0) {
$do_event = 0;
}
elsif (!defined($module->{'disabled_types_event'}) || $module->{'disabled_types_event'} eq "") {
$do_event = 1;
}
else {