2009-09-02 Ramon Novoa <rnovoa@artica.es>
* conf/pandora_server.conf: Added sample configurations for inhibit_alerts and use_xml_timestamp. * lib/PandoraFMS/Config.pm: Added the inhibit_alerts configuration token. * lib/PandoraFMS/Core.pm: Added the option to inhibit agent alerts if the parent has fired a critical alert. * lib/PandoraFMS/DataServer.pm: Use the XML file last modification time if no timestamp is specified. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1902 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b3b63955d0
commit
176ae0f6ac
|
@ -1,3 +1,17 @@
|
|||
2009-09-02 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* conf/pandora_server.conf: Added sample configurations for
|
||||
inhibit_alerts and use_xml_timestamp.
|
||||
|
||||
* lib/PandoraFMS/Config.pm: Added the inhibit_alerts configuration
|
||||
token.
|
||||
|
||||
* lib/PandoraFMS/Core.pm: Added the option to inhibit agent alerts if
|
||||
the parent has fired a critical alert.
|
||||
|
||||
* lib/PandoraFMS/DataServer.pm: Use the XML file last modification time
|
||||
if no timestamp is specified.
|
||||
|
||||
2009-09-01 Sancho Lerena <slerena@artica.es>
|
||||
|
||||
* pandora_server.spec: Using chkconfig for service install. Using the new
|
||||
|
|
|
@ -216,3 +216,8 @@ max_log_size 65536
|
|||
|
||||
max_queue_files 250
|
||||
|
||||
# Use the XML file last modification time as timestamp.
|
||||
# use_xml_timestamp 1
|
||||
|
||||
# Inhibit agent alerts if the parent has fired a critical alert.
|
||||
# inhibit_alerts 1
|
||||
|
|
|
@ -225,6 +225,9 @@ sub pandora_load_config {
|
|||
|
||||
# Ignore the timestamp in the XML and use the file timestamp instead
|
||||
$pa_config->{'use_xml_timestamp'} = 0;
|
||||
|
||||
# Inhibit alerts if the parent agent fired a critical alert
|
||||
$pa_config->{'inhibit_alerts'} = 0;
|
||||
|
||||
# Check for UID0
|
||||
if ($pa_config->{"quiet"} != 0){
|
||||
|
@ -491,6 +494,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^use_xml_timestamp\s([0-1])/i) {
|
||||
$pa_config->{'use_xml_timestamp'} = clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^inhibit_alerts\s([0-1])/i) {
|
||||
$pa_config->{'inhibit_alerts'} = clean_blank($1);
|
||||
}
|
||||
} # end of loop for parameter #
|
||||
|
||||
|
||||
|
|
|
@ -524,7 +524,9 @@ sub pandora_process_module ($$$$$$$$$) {
|
|||
my $status = get_module_status ($data, $module, $module_type);
|
||||
|
||||
# Generate alerts
|
||||
pandora_generate_alerts ($pa_config, $data, $status, $agent, $module, $utimestamp, $dbh);
|
||||
if (pandora_inhibit_alerts ($pa_config, $agent, $dbh) == 0) {
|
||||
pandora_generate_alerts ($pa_config, $data, $status, $agent, $module, $utimestamp, $dbh);
|
||||
}
|
||||
|
||||
#Update module status
|
||||
my $current_utimestamp = time ();
|
||||
|
@ -1154,6 +1156,30 @@ sub export_module_data ($$$$$$) {
|
|||
(?, ?, ?, ?, ?, ?)', $module->{'id_export'}, $agent->{'nombre'}, $module->{'nombre'}, $module_type, $data, $timestamp);
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# Returns 1 if alerts for the given agent should be inhibited, 0 otherwise.
|
||||
##########################################################################
|
||||
sub pandora_inhibit_alerts ($$$) {
|
||||
my ($pa_config, $agent, $dbh) = @_;
|
||||
|
||||
return 0 if ($pa_config->{'inhibit_alerts'} ne '1' || $agent->{'id_parent'} eq '0');
|
||||
|
||||
# Are any of the parent's critical alerts fired?
|
||||
my $count = get_db_value ($dbh, 'SELECT COUNT(*) FROM tagente_modulo, talert_template_modules, talert_templates
|
||||
WHERE tagente_modulo.id_agente = ?
|
||||
AND tagente_modulo.id_agente_modulo = talert_template_modules.id_agent_module
|
||||
AND talert_template_modules.id_alert_template = talert_templates.id
|
||||
AND talert_template_modules.times_fired > 0
|
||||
AND talert_templates.priority = 4', $agent->{'id_parent'});
|
||||
return 1 if ($count > 0);
|
||||
|
||||
# Are any of the parent's critical compound alerts fired?
|
||||
$count = get_db_value ($dbh, 'SELECT COUNT(*) FROM talert_compound WHERE id_agent = ? AND times_fired > 0 AND priority = 4', $agent->{'id_parent'});
|
||||
return 1 if ($count > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
# End of function declaration
|
||||
# End of defined Code
|
||||
|
||||
|
|
|
@ -132,13 +132,12 @@ sub data_consumer ($$) {
|
|||
|
||||
# Invalid XML
|
||||
if ($@) {
|
||||
print "$@\n";
|
||||
sleep (60);
|
||||
next;
|
||||
}
|
||||
|
||||
# Ignore the timestamp in the XML and use the file timestamp instead
|
||||
$xml_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime((stat($file_name))[9])) if ($pa_config->{'use_xml_timestamp'} eq '1');
|
||||
$xml_data->{'timestamp'} = strftime ("%Y-%m-%d %H:%M:%S", localtime((stat($file_name))[9])) if ($pa_config->{'use_xml_timestamp'} eq '1' || ! defined ($xml_data->{'timestamp'}));
|
||||
|
||||
unlink ($file_name);
|
||||
process_xml_data ($self->getConfig (), $xml_data, $self->getServerID (), $self->getDBH ());
|
||||
|
|
Loading…
Reference in New Issue