Added support for warmup intervals (see the official docs for more

info).
This commit is contained in:
Ramon Novoa 2015-11-13 16:27:41 +01:00
parent 185b9e853e
commit feac9b4263
5 changed files with 95 additions and 0 deletions

View File

@ -536,9 +536,23 @@ sub main() {
}
}
# Save the start time for warmup intervals.
$Config{'__start_utimestamp__'} = time();
# Start the servers
pandora_startup ();
if ($Config{'warmup_unknown_interval'} > 0) {
logger(\%Config, "Warmup mode for unknown modules started.", 3);
pandora_event (\%Config, "Warmup mode for unknown modules started.", 0, 0, 0, 0, 0, 'system', 0, $DBH);
}
if ($Config{'warmup_event_interval'} > 0) {
logger(\%Config, "Warmup mode for alerts started.", 3);
logger(\%Config, "Warmup mode for events started.", 3);
pandora_event (\%Config, "Warmup mode for alerts started.", 0, 0, 0, 0, 0, 'system', 0, $DBH);
pandora_event (\%Config, "Warmup mode for events started.", 0, 0, 0, 0, 0, 'system', 0, $DBH);
}
# Start thread to execute server tasks on the master server
threads->create('pandora_server_tasks', (\%Config))->detach();

View File

@ -520,3 +520,13 @@ remote_config_address localhost
# Extra options for the Tentacle client to send the configuration file (PANDORA FMS ENTERPRISE ONLY).
#remote_config_opts
# Module status change events will not be generated and module alerts will not
# be executed for the specified number of seconds since the server starts up.
warmup_event_interval 0
# Modules will not become unknown (so no unknown events will be generated) and
# keepalive modules will not be updated for the specified number of seconds
# since the server starts up.
warmup_unknown_interval 300

View File

@ -318,3 +318,13 @@ global_alert_timeout 15
# If set to 1 allows PandoraFMS Server to be configured via the web console (Only Enterprise version)
remote_config 0
# Module status change events will not be generated and module alerts will not
# be executed for the specified number of seconds since the server starts up.
warmup_event_interval 0
# Modules will not become unknown (so no unknown events will be generated) and
# keepalive modules will not be updated for the specified number of seconds
# since the server starts up.
warmup_unknown_interval 300

View File

@ -401,6 +401,14 @@ sub pandora_load_config {
# Temp path for file sendinn and receiving
$pa_config->{"temporal"} = '/tmp'; # 6.0
# Warmup intervals.
$pa_config->{"warmup_alert_interval"} = 0; # 6.1
$pa_config->{"warmup_alert_on"} = 0; # 6.1
$pa_config->{"warmup_event_interval"} = 0; # 6.1
$pa_config->{"warmup_event_on"} = 0; # 6.1
$pa_config->{"warmup_unknown_interval"} = 300; # 6.1
$pa_config->{"warmup_unknown_on"} = 1; # 6.1
# Check for UID0
if ($pa_config->{"quiet"} != 0){
if ($> == 0){
@ -886,6 +894,18 @@ sub pandora_load_config {
elsif ($parametro =~ m/^temporal\s(.*)/i) {
$pa_config->{'temporal'}= clean_blank($1);
}
elsif ($parametro =~ m/^warmup_event_interval\s+([0-9]*)/i ||
$parametro =~ m/^warmup_alert_interval\s+([0-9]*)/i) {
$pa_config->{'warmup_event_interval'}= clean_blank($1);
$pa_config->{'warmup_event_on'} = 1 if ($pa_config->{'warmup_event_interval'} > 0); # Off by default.
# The same interval is used for alerts and events.
$pa_config->{'warmup_alert_interval'}= clean_blank($1);
$pa_config->{'warmup_alert_on'} = 1 if ($pa_config->{'warmup_event_interval'} > 0); # Off by default.
}
elsif ($parametro =~ m/^warmup_unknown_interval\s+([0-9]*)/i) {
$pa_config->{'warmup_unknown_interval'}= clean_blank($1);
$pa_config->{'warmup_unknown_on'} = 0 if ($pa_config->{'warmup_unknown_interval'} == 0); # On by default.
}
} # end of loop for parameter #
# Set to RDBMS' standard port

View File

@ -288,6 +288,17 @@ sub pandora_generate_alerts ($$$$$$$$;$$$) {
return;
}
# Warmup interval for alerts.
if ($pa_config->{'warmup_alert_on'} == 1) {
# No alerts.
return if (time() < $pa_config->{'__start_utimestamp__'} + $pa_config->{'warmup_alert_interval'});
$pa_config->{'warmup_alert_on'} = 0;
logger($pa_config, "Warmup mode for alerts ended.", 10);
pandora_event ($pa_config, "Warmup mode for alerts ended.", 0, 0, 0, 0, 0, 'system', 0, $dbh);
}
if ($agent->{'quiet'} == 1) {
logger($pa_config, "Generate Alert. The agent '" . $agent->{'nombre'} . "' is in quiet mode.", 10);
@ -3062,6 +3073,14 @@ Update keep_alive modules for agents without data.
sub pandora_module_keep_alive_nd {
my ($pa_config, $dbh) = @_;
# Warmup interval for keepalive modules.
if ($pa_config->{'warmup_unknown_on'} == 1) {
return if (time() < $pa_config->{'__start_utimestamp__'} + $pa_config->{'warmup_unknown_interval'});
# Disabled from pandora_module_unknown.
}
my @modules = get_db_rows ($dbh, 'SELECT tagente_modulo.*
FROM tagente_modulo, tagente_estado, tagente
WHERE tagente.id_agente = tagente_estado.id_agente
@ -3762,6 +3781,17 @@ sub generate_status_event ($$$$$$$$) {
return;
}
# Warmup interval for status events.
if ($pa_config->{'warmup_event_on'} == 1) {
# No status events.
return if (time() < $pa_config->{'__start_utimestamp__'} + $pa_config->{'warmup_event_interval'});
$pa_config->{'warmup_event_on'} = 0;
logger($pa_config, "Warmup mode for events ended.", 10);
pandora_event ($pa_config, "Warmup mode for events ended.", 0, 0, 0, 0, 0, 'system', 0, $dbh);
}
# 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;
@ -4476,6 +4506,17 @@ Set the status of unknown modules.
sub pandora_module_unknown ($$) {
my ($pa_config, $dbh) = @_;
# Warmup interval for unknown modules.
if ($pa_config->{'warmup_unknown_on'} == 1) {
# No status events.
return if (time() < $pa_config->{'__start_utimestamp__'} + $pa_config->{'warmup_unknown_interval'});
$pa_config->{'warmup_unknown_on'} = 0;
logger($pa_config, "Warmup mode for unknown modules ended.", 10);
pandora_event ($pa_config, "Warmup mode for unknown modules ended.", 0, 0, 0, 0, 0, 'system', 0, $dbh);
}
my @modules = get_db_rows ($dbh, 'SELECT tagente_modulo.*,
tagente_estado.id_agente_estado, tagente_estado.estado
FROM tagente_modulo, tagente_estado, tagente