2013-09-04 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm,
	  lib/PandoraFMS/Config.pm,
	  conf/pandora_server.conf.new: Added support for custom event texts.

	* lib/PandoraFMS/Server.pm: Fixed a comparison.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8741 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2013-09-04 13:28:13 +00:00
parent 1506127262
commit 8da72999b7
5 changed files with 66 additions and 9 deletions

View File

@ -1,3 +1,11 @@
2013-09-04 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm,
lib/PandoraFMS/Config.pm,
conf/pandora_server.conf.new: Added support for custom event texts.
* lib/PandoraFMS/Server.pm: Fixed a comparison.
2013-09-04 Ramon Novoa <rnovoa@artica.es> 2013-09-04 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Added support for treating events with the * lib/PandoraFMS/Core.pm: Added support for treating events with the

View File

@ -422,3 +422,9 @@ event_auto_validation 1
# Time interval for snmp_storm protection (in seconds). # Time interval for snmp_storm protection (in seconds).
#snmp_storm_timeout 600 #snmp_storm_timeout 600
# Default texts for some events. The macros _module_ and _data_ are supported.
#text_going_down_normal Module '_module_' is going to NORMAL (_data_)
#text_going_up_critical Module '_module_' is going to CRITICAL (_data_)
#text_going_up_warning Module '_module_' is going to WARNING (_data_)
#text_going_down_warning Module '_module_' is going to WARNING (_data_)
#text_going_unknown Module '_module_' is going to UNKNOWN

View File

@ -306,6 +306,13 @@ sub pandora_load_config {
# Export events to a text file # Export events to a text file
$pa_config->{"event_file"} = ''; # 5.0 $pa_config->{"event_file"} = ''; # 5.0
# Default event messages
$pa_config->{"text_going_down_normal"} = "Module '_module_' is going to NORMAL (_data_)"; # 5.0
$pa_config->{"text_going_up_critical"} = "Module '_module_' is going to CRITICAL (_data_)"; # 5.0
$pa_config->{"text_going_up_warning"} = "Module '_module_' is going to WARNING (_data_)"; # 5.0
$pa_config->{"text_going_down_warning"} = "Module '_module_' is going to WARNING (_data_)"; # 5.0
$pa_config->{"text_going_unknown"} = "Module '_module_' is going to UNKNOWN"; # 5.0
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# This values are not stored in .conf files. # This values are not stored in .conf files.
# This values should be stored in database, not in .conf files! # This values should be stored in database, not in .conf files!
@ -671,6 +678,21 @@ sub pandora_load_config {
elsif ($parametro =~ m/^event_file\s+(.*)/i) { elsif ($parametro =~ m/^event_file\s+(.*)/i) {
$pa_config->{'event_file'}= clean_blank($1); $pa_config->{'event_file'}= clean_blank($1);
} }
elsif ($parametro =~ m/^text_going_down_normal\s+(.*)/i) {
$pa_config->{'text_going_down_normal'} = safe_input ($1);
}
elsif ($parametro =~ m/^text_going_up_critical\s+(.*)/i) {
$pa_config->{'text_going_up_critical'} = safe_input ($1);
}
elsif ($parametro =~ m/^text_going_up_warning\s+(.*)/i) {
$pa_config->{'text_going_up_warning'} = safe_input ($1);
}
elsif ($parametro =~ m/^text_going_down_warning\s+(.*)/i) {
$pa_config->{'text_going_down_warning'} = safe_input ($1);
}
elsif ($parametro =~ m/^text_going_unknown\s+(.*)/i) {
$pa_config->{'text_going_unknown'} = safe_input ($1);
}
} # end of loop for parameter # } # end of loop for parameter #
# Set to RDBMS' standard port # Set to RDBMS' standard port

View File

@ -3220,7 +3220,7 @@ sub pandora_validate_event ($$$) {
sub generate_status_event ($$$$$$$$) { sub generate_status_event ($$$$$$$$) {
my ($pa_config, $data, $agent, $module, $status, $last_status, $last_known_status, $dbh) = @_; my ($pa_config, $data, $agent, $module, $status, $last_status, $last_known_status, $dbh) = @_;
my ($event_type, $severity); my ($event_type, $severity);
my $description = "Module " . safe_output($module->{'nombre'}) . " (".safe_output($data).") is "; my $description = '';
# No events when event storm protection is enabled # No events when event storm protection is enabled
if ($EventStormProtection == 1) { if ($EventStormProtection == 1) {
@ -3239,23 +3239,23 @@ sub generate_status_event ($$$$$$$$) {
} }
($event_type, $severity) = ('going_down_normal', 2); ($event_type, $severity) = ('going_down_normal', 2);
$description .= "going to NORMAL"; $description = $pa_config->{"text_going_down_normal"};
# Critical # Critical
} elsif ($status == 1) { } elsif ($status == 1) {
($event_type, $severity) = ('going_up_critical', 4); ($event_type, $severity) = ('going_up_critical', 4);
$description .= "going to CRITICAL"; $description = $pa_config->{"text_going_up_critical"};
# Warning # Warning
} elsif ($status == 2) { } elsif ($status == 2) {
# From normal # From normal
if ($last_known_status == 0 || $last_known_status == 4) { if ($last_known_status == 0 || $last_known_status == 4) {
($event_type, $severity) = ('going_up_warning', 3); ($event_type, $severity) = ('going_up_warning', 3);
$description .= "going to WARNING"; $description = $pa_config->{"text_going_up_warning"};
# From critical # From critical
} elsif ($last_known_status == 1) { } elsif ($last_known_status == 1) {
($event_type, $severity) = ('going_down_warning', 3); ($event_type, $severity) = ('going_down_warning', 3);
$description .= "going to WARNING"; $description = $pa_config->{"text_going_down_warning"};
} else { } else {
# Unknown last_status # Unknown last_status
return; return;
@ -3266,6 +3266,13 @@ sub generate_status_event ($$$$$$$$) {
return; return;
} }
# Replace macros
my %macros = (
_module_ => safe_output($module->{'nombre'}),
_data_ => safe_output($data),
);
$description = subst_alert_macros ($description, \%macros);
# Generate the event # Generate the event
if ($status != 0){ if ($status != 0){
pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'}, pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'},
@ -3912,7 +3919,14 @@ sub pandora_module_unknown ($$) {
# Generate event with severity minor # Generate event with severity minor
my ($event_type, $severity) = ('going_down_normal', 5); my ($event_type, $severity) = ('going_down_normal', 5);
my $description = "Module " . safe_output($module->{'nombre'}) . " is going to NORMAL"; my $description = $pa_config->{"text_going_down_normal"};
# Replace macros
my %macros = (
_module_ => safe_output($module->{'nombre'}),
_data_ => 'N/A',
);
pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'}, 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'}); $severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'});
} }
@ -3958,7 +3972,14 @@ sub pandora_module_unknown ($$) {
# Generate event with severity minor # Generate event with severity minor
if ($do_event) { if ($do_event) {
my ($event_type, $severity) = ('going_unknown', 5); my ($event_type, $severity) = ('going_unknown', 5);
my $description = "Module " . safe_output($module->{'nombre'}) . " is going to UNKNOWN"; my $description = $pa_config->{"going_unknown"};
# Replace macros
my %macros = (
_module_ => safe_output($module->{'nombre'}),
);
$description = subst_alert_macros ($description, \%macros);
pandora_event ($pa_config, $description, $agent->{'id_grupo'}, $module->{'id_agente'}, 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'}); $severity, 0, $module->{'id_agente_modulo'}, $event_type, 0, $dbh, 'Pandora', '', '', '', '', $module->{'critical_instructions'}, $module->{'warning_instructions'}, $module->{'unknown_instructions'});
} }

View File

@ -255,7 +255,7 @@ sub restartEvent ($$) {
return unless defined ($self->{'_dbh'}); return unless defined ($self->{'_dbh'});
eval { eval {
pandora_event ($self->{'_pa_config'}, $self->{'_pa_config'}->{'servername'} . pandora_event ($self->{'_pa_config'}, $self->{'_pa_config'}->{'servername'} .
$ServerTypes[$self->{'_server_type'}] . " RESTARTING" . (defined ($msg) ? " ($msg)" : ''), $ServerTypes[$self->{'_server_type'}] . " RESTARTING" . ($msg ne '' ? " ($msg)" : ''),
0, 0, 4, 0, 0, 'system', 0, $self->{'_dbh'}); 0, 0, 4, 0, 0, 'system', 0, $self->{'_dbh'});
}; };
} }