#8732 Added autoconfiguration scheduled 3
This commit is contained in:
parent
e8c7c38c1f
commit
8ffb247703
|
@ -320,10 +320,13 @@ sub pandora_agent_autoconfiguration_scheduled($) {
|
||||||
$pa_config{'dbuser'}, $pa_config{'dbpass'});
|
$pa_config{'dbuser'}, $pa_config{'dbpass'});
|
||||||
|
|
||||||
while ($THRRUN == 1) {
|
while ($THRRUN == 1) {
|
||||||
|
eval {{
|
||||||
|
local $SIG{__DIE__};
|
||||||
|
|
||||||
my @autoconfig = get_db_rows (
|
my @autoconfig = get_db_rows (
|
||||||
$dbh,
|
$dbh,
|
||||||
'SELECT *, DATE_FORMAT(DATE_ADD(periodically_time_from, INTERVAL 5 MINUTE), "%H:%i:%S") AS time_minutes FROM tautoconfig
|
'SELECT *, DATE_FORMAT(DATE_ADD(periodically_time_from, INTERVAL ' . $pa_config->{'autoconfigure_agents_threshold'} . ' SECOND), "%H:%i:%S") AS time_minutes
|
||||||
WHERE executed = 0 AND type_execution LIKE "scheduled" AND disabled = 0'
|
FROM tautoconfig WHERE executed = 0 AND type_execution LIKE "scheduled" AND disabled = 0'
|
||||||
);
|
);
|
||||||
|
|
||||||
# Get current time.
|
# Get current time.
|
||||||
|
@ -338,6 +341,8 @@ sub pandora_agent_autoconfiguration_scheduled($) {
|
||||||
($conf->{'friday'} eq 1 && $wday eq 5) || ($conf->{'saturday'} eq 1 && $wday eq 6)))
|
($conf->{'friday'} eq 1 && $wday eq 5) || ($conf->{'saturday'} eq 1 && $wday eq 6)))
|
||||||
) {
|
) {
|
||||||
if ($time ge $conf->{'periodically_time_from'} && $time le $conf->{'time_minutes'}) {
|
if ($time ge $conf->{'periodically_time_from'} && $time le $conf->{'time_minutes'}) {
|
||||||
|
# Update executed.
|
||||||
|
db_process_update ($dbh, 'tautoconfig', {'executed' => 1}, {'id' => $conf->{'id'}});
|
||||||
# Get agents.
|
# Get agents.
|
||||||
my @agents = get_db_rows(
|
my @agents = get_db_rows(
|
||||||
$dbh,
|
$dbh,
|
||||||
|
@ -346,16 +351,21 @@ sub pandora_agent_autoconfiguration_scheduled($) {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach my $agent (@agents) {
|
foreach my $agent (@agents) {
|
||||||
|
# Check if the agent matches the rules.
|
||||||
my $match = enterprise_hook('autoconf_evaluate_rules', [$pa_config, $dbh, $agent, $conf->{'id'}, $agent->{'id_agente'}, 1]);
|
my $match = enterprise_hook('autoconf_evaluate_rules', [$pa_config, $dbh, $agent, $conf->{'id'}, $agent->{'id_agente'}, 1]);
|
||||||
if (defined($match) && $match > 0) {
|
if (defined($match) && $match > 0) {
|
||||||
enterprise_hook('autoconf_execute_actions', [$pa_config, $dbh, $agent->{'id_agente'}, $agent, $conf->{'id'}]);
|
enterprise_hook('autoconf_execute_actions', [$pa_config, $dbh, $agent->{'id_agente'}, $agent, $conf->{'id'}]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep (300);
|
# Update executed.
|
||||||
|
db_process_update ($dbh, 'tautoconfig', {'executed' => 0}, {'id' => $conf->{'id'}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
|
||||||
|
sleep ($pa_config->{'autoconfigure_agents_threshold'});
|
||||||
}
|
}
|
||||||
|
|
||||||
db_disconnect($dbh);
|
db_disconnect($dbh);
|
||||||
|
|
|
@ -539,6 +539,7 @@ sub pandora_load_config {
|
||||||
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
|
$pa_config->{"provisioning_cache_interval"} = 300; # 7.0 720
|
||||||
|
|
||||||
$pa_config->{"autoconfigure_agents"} = 1; # 7.0 725
|
$pa_config->{"autoconfigure_agents"} = 1; # 7.0 725
|
||||||
|
$pa_config->{"autoconfigure_agents_threshold"} = 300; #7.0 764
|
||||||
|
|
||||||
$pa_config->{'snmp_extlog'} = ""; # 7.0 726
|
$pa_config->{'snmp_extlog'} = ""; # 7.0 726
|
||||||
|
|
||||||
|
@ -1265,6 +1266,9 @@ sub pandora_load_config {
|
||||||
elsif ($parametro =~ m/^autoconfigure_agents\s+([0-1])/i){
|
elsif ($parametro =~ m/^autoconfigure_agents\s+([0-1])/i){
|
||||||
$pa_config->{'autoconfigure_agents'}= clean_blank($1);
|
$pa_config->{'autoconfigure_agents'}= clean_blank($1);
|
||||||
}
|
}
|
||||||
|
elsif ($parametro =~ m/^autoconfigure_agents_threshold\s+([0-1])/i){
|
||||||
|
$pa_config->{'autoconfigure_agents_threshold'}= clean_blank($1);
|
||||||
|
}
|
||||||
elsif ($parametro =~ m/^snmp_extlog\s(.*)/i) {
|
elsif ($parametro =~ m/^snmp_extlog\s(.*)/i) {
|
||||||
$pa_config->{'snmp_extlog'} = clean_blank($1);
|
$pa_config->{'snmp_extlog'} = clean_blank($1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue