Generate an event when there are too many XML data files queued for an agent.
This commit is contained in:
parent
eba0ce9e80
commit
b7bd289457
|
@ -816,3 +816,6 @@ 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
|
||||||
|
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
# Check for UID0
|
# Check for UID0
|
||||||
if ($pa_config->{"quiet"} != 0){
|
if ($pa_config->{"quiet"} != 0){
|
||||||
if ($> == 0){
|
if ($> == 0){
|
||||||
|
@ -1412,6 +1414,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, "Too many XML files for agent $agent_name ($xml_count)", 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,16 @@ 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)) {
|
||||||
|
print ">>> AGENT: $agent_name COUNT: $xml_count\n";
|
||||||
|
if ($xml_count > $pa_config->{'too_many_xml'}) {
|
||||||
|
pandora_timed_event(300, $pa_config, "Too many XML files for agent $agent_name ($xml_count)", 0, 0, 0, 0, 0, 'warning', 0, $dbh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return @tasks;
|
return @tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue