Merge branch 'ent-12152-generar-evento-de-encolamiento-excesivo-cuando-se-procesan-mas-de-xxx-xml-del-mismo-agente' into 'develop'
Generate an event when there are too many XML data files queued for an agent. See merge request artica/pandorafms!6884
This commit is contained in:
commit
78a46c3b1f
|
@ -816,5 +816,8 @@ madeserver_autofit 7d
|
||||||
# Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY).
|
# Model sensitivity. A lower value triggers less anomalies (PANDORA FMS ENTERPRISE ONLY).
|
||||||
madeserver_sensitivity 0.1
|
madeserver_sensitivity 0.1
|
||||||
|
|
||||||
|
# If greater than 0, generate an event when more than the specified number of XML data files are queued for an agent.
|
||||||
|
too_many_xml 10
|
||||||
|
|
||||||
# Encoding to use on mail subject (MIME-Header by default)
|
# Encoding to use on mail subject (MIME-Header by default)
|
||||||
# mail_subject_encoding MIME-Header-ISO_2022_JP
|
# mail_subject_encoding MIME-Header-ISO_2022_JP
|
||||||
|
|
|
@ -589,6 +589,8 @@ sub pandora_load_config {
|
||||||
|
|
||||||
$pa_config->{"madeserver"} = 0; # 774.
|
$pa_config->{"madeserver"} = 0; # 774.
|
||||||
|
|
||||||
|
$pa_config->{"too_many_xml"} = 10; # 776.
|
||||||
|
|
||||||
$pa_config->{"mail_subject_encoding"} = 'MIME-Header'; # 776.
|
$pa_config->{"mail_subject_encoding"} = 'MIME-Header'; # 776.
|
||||||
|
|
||||||
# Check for UID0
|
# Check for UID0
|
||||||
|
@ -1417,6 +1419,9 @@ sub pandora_load_config {
|
||||||
elsif ($parametro =~ m/^madeserver\s+([0-1])/i){
|
elsif ($parametro =~ m/^madeserver\s+([0-1])/i){
|
||||||
$pa_config->{'madeserver'}= clean_blank($1);
|
$pa_config->{'madeserver'}= clean_blank($1);
|
||||||
}
|
}
|
||||||
|
elsif ($parametro =~ m/^too_many_xml\s+([0-9]*)/i){
|
||||||
|
$pa_config->{'too_many_xml'}= clean_blank($1);
|
||||||
|
}
|
||||||
} # end of loop for parameter #
|
} # end of loop for parameter #
|
||||||
|
|
||||||
# The DB host was overridden by pandora_ha.
|
# The DB host was overridden by pandora_ha.
|
||||||
|
|
|
@ -56,6 +56,7 @@ our @ISA = qw(PandoraFMS::ProducerConsumerServer);
|
||||||
my @TaskQueue :shared;
|
my @TaskQueue :shared;
|
||||||
my %PendingTasks :shared;
|
my %PendingTasks :shared;
|
||||||
my %Agents :shared;
|
my %Agents :shared;
|
||||||
|
my %AgentCounts;
|
||||||
my $Sem :shared;
|
my $Sem :shared;
|
||||||
my $TaskSem :shared;
|
my $TaskSem :shared;
|
||||||
my $AgentSem :shared;
|
my $AgentSem :shared;
|
||||||
|
@ -73,6 +74,7 @@ sub new ($$;$) {
|
||||||
@TaskQueue = ();
|
@TaskQueue = ();
|
||||||
%PendingTasks = ();
|
%PendingTasks = ();
|
||||||
%Agents = ();
|
%Agents = ();
|
||||||
|
%AgentCounts = ();
|
||||||
$Sem = Thread::Semaphore->new;
|
$Sem = Thread::Semaphore->new;
|
||||||
$TaskSem = Thread::Semaphore->new (0);
|
$TaskSem = Thread::Semaphore->new (0);
|
||||||
$AgentSem = Thread::Semaphore->new (1);
|
$AgentSem = Thread::Semaphore->new (1);
|
||||||
|
@ -142,6 +144,9 @@ sub data_producer ($) {
|
||||||
opendir (DIR, $pa_config->{'incomingdir'})
|
opendir (DIR, $pa_config->{'incomingdir'})
|
||||||
|| die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!";
|
|| die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!";
|
||||||
|
|
||||||
|
# Reset agent XML file counts
|
||||||
|
%AgentCounts = ();
|
||||||
|
|
||||||
# Do not read more than max_queue_files files
|
# Do not read more than max_queue_files files
|
||||||
my $file_count = 0;
|
my $file_count = 0;
|
||||||
while (my $file = readdir (DIR)) {
|
while (my $file = readdir (DIR)) {
|
||||||
|
@ -177,11 +182,21 @@ sub data_producer ($) {
|
||||||
next if ($file !~ /^(.*)[\._]\d+\.data$/);
|
next if ($file !~ /^(.*)[\._]\d+\.data$/);
|
||||||
my $agent_name = $1;
|
my $agent_name = $1;
|
||||||
|
|
||||||
|
$AgentCounts{$agent_name} = defined($AgentCounts{$agent_name}) ? $AgentCounts{$agent_name} + 1 : 1;
|
||||||
next if (agent_lock($pa_config, $dbh, $agent_name) == 0);
|
next if (agent_lock($pa_config, $dbh, $agent_name) == 0);
|
||||||
|
|
||||||
push (@tasks, $file);
|
push (@tasks, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate an event if there are too many XML files for a given agent.
|
||||||
|
if ($pa_config->{'too_many_xml'} > 0) {
|
||||||
|
while (my ($agent_name, $xml_count) = each(%AgentCounts)) {
|
||||||
|
if ($xml_count > $pa_config->{'too_many_xml'}) {
|
||||||
|
pandora_timed_event(300, $pa_config, "More than " . $pa_config->{'too_many_xml'} . " XML files queued for agent $agent_name", 0, 0, 0, 0, 0, 'warning', 0, $dbh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return @tasks;
|
return @tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,6 +215,9 @@ sub data_producer_smart_queue ($) {
|
||||||
opendir (DIR, $pa_config->{'incomingdir'})
|
opendir (DIR, $pa_config->{'incomingdir'})
|
||||||
|| die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!";
|
|| die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!";
|
||||||
|
|
||||||
|
# Reset agent XML file counts
|
||||||
|
%AgentCounts = ();
|
||||||
|
|
||||||
# Do not read more than max_queue_files files
|
# Do not read more than max_queue_files files
|
||||||
my $smart_queue = {};
|
my $smart_queue = {};
|
||||||
while (my $file = readdir (DIR)) {
|
while (my $file = readdir (DIR)) {
|
||||||
|
@ -209,6 +227,9 @@ sub data_producer_smart_queue ($) {
|
||||||
next if ($file !~ /^(.*)[\._]\d+\.data$/);
|
next if ($file !~ /^(.*)[\._]\d+\.data$/);
|
||||||
my $agent_name = $1;
|
my $agent_name = $1;
|
||||||
|
|
||||||
|
# Update per agent XML counts.
|
||||||
|
$AgentCounts{$agent_name} = defined($AgentCounts{$agent_name}) ? $AgentCounts{$agent_name} + 1 : 1;
|
||||||
|
|
||||||
# Queue a new file.
|
# Queue a new file.
|
||||||
if (!defined($smart_queue->{$agent_name})) {
|
if (!defined($smart_queue->{$agent_name})) {
|
||||||
$smart_queue->{$agent_name} = $file;
|
$smart_queue->{$agent_name} = $file;
|
||||||
|
@ -229,6 +250,15 @@ sub data_producer_smart_queue ($) {
|
||||||
push (@tasks, $file);
|
push (@tasks, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate an event if there are too many XML files for a given agent.
|
||||||
|
if ($pa_config->{'too_many_xml'} > 0) {
|
||||||
|
while (my ($agent_name, $xml_count) = each(%AgentCounts)) {
|
||||||
|
if ($xml_count > $pa_config->{'too_many_xml'}) {
|
||||||
|
pandora_timed_event(300, $pa_config, "More than " . $pa_config->{'too_many_xml'} . " XML files queued for agent $agent_name", 0, 0, 0, 0, 0, 'warning', 0, $dbh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return @tasks;
|
return @tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue