Merge branch 'ent-10269-bloqueo-de-xml-dataserver-tiene-cientos-de-xml-pero-no-procesa' into 'develop'

Make sure producers always release agent locks.

See merge request artica/pandorafms!5478
This commit is contained in:
Daniel Rodriguez 2023-02-07 11:31:04 +00:00
commit 01acebf1eb
3 changed files with 106 additions and 123 deletions

View File

@ -387,6 +387,7 @@ sub pandora_server_tasks ($) {
my $counter = 0; my $counter = 0;
my $first_run = 1; my $first_run = 1;
while ($THRRUN == 1) { while ($THRRUN == 1) {
eval {
if (pandora_is_master($pa_config) == 1) { if (pandora_is_master($pa_config) == 1) {
# TASKS EXECUTED ONCE # TASKS EXECUTED ONCE
@ -493,6 +494,7 @@ sub pandora_server_tasks ($) {
&& $counter % $pa_config->{'self_monitoring_interval'} == 0) { && $counter % $pa_config->{'self_monitoring_interval'} == 0) {
pandora_self_monitoring ($pa_config, $dbh); pandora_self_monitoring ($pa_config, $dbh);
} }
};
# Avoid counter overflow # Avoid counter overflow
if ($counter >= ~0){ if ($counter >= ~0){

View File

@ -6009,10 +6009,6 @@ sub pandora_self_monitoring ($$) {
$pandoradb = 1; $pandoradb = 1;
} }
my $start_performance = time;
get_db_value($dbh, "SELECT COUNT(*) FROM tagente_datos");
my $read_speed = int((time - $start_performance) * 1e6);
my $elasticsearch_perfomance = enterprise_hook("elasticsearch_performance", [$pa_config, $dbh]); my $elasticsearch_perfomance = enterprise_hook("elasticsearch_performance", [$pa_config, $dbh]);
$xml_output .= $elasticsearch_perfomance if defined($elasticsearch_perfomance); $xml_output .= $elasticsearch_perfomance if defined($elasticsearch_perfomance);
@ -6059,13 +6055,6 @@ sub pandora_self_monitoring ($$) {
$xml_output .=" </module>"; $xml_output .=" </module>";
} }
$xml_output .=" <module>";
$xml_output .=" <name>Execution_Time</name>";
$xml_output .=" <type>generic_data</type>";
$xml_output .=" <unit>us</unit>";
$xml_output .=" <data>$read_speed</data>";
$xml_output .=" </module>";
$xml_output .= "</agent_data>"; $xml_output .= "</agent_data>";
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".self.".$utimestamp.".data"; my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".self.".$utimestamp.".data";

View File

@ -304,8 +304,9 @@ sub data_consumer ($$) {
agent_unlock($pa_config, $agent_name); agent_unlock($pa_config, $agent_name);
return; return;
} }
unlink ($file_name); unlink ($file_name);
eval {
if (defined($xml_data->{'server_name'})) { if (defined($xml_data->{'server_name'})) {
process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ()); process_xml_server ($self->getConfig (), $file_name, $xml_data, $self->getDBH ());
} elsif (defined($xml_data->{'connection_source'})) { } elsif (defined($xml_data->{'connection_source'})) {
@ -313,12 +314,12 @@ sub data_consumer ($$) {
} elsif (defined($xml_data->{'ipam_source'})) { } elsif (defined($xml_data->{'ipam_source'})) {
enterprise_hook('process_xml_ipam', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]); enterprise_hook('process_xml_ipam', [$self->getConfig (), $file_name, $xml_data, $self->getDBH ()]);
} elsif (defined($xml_data->{'network_matrix'})){ } elsif (defined($xml_data->{'network_matrix'})){
process_xml_matrix_network( process_xml_matrix_network( $self->getConfig(), $xml_data, $self->getDBH());
$self->getConfig(), $xml_data, $self->getDBH()
);
} else { } else {
process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ()); process_xml_data ($self->getConfig (), $file_name, $xml_data, $self->getServerID (), $self->getDBH ());
} }
};
agent_unlock($pa_config, $agent_name); agent_unlock($pa_config, $agent_name);
return; return;
} }
@ -1174,15 +1175,6 @@ sub process_xml_matrix_network {
sub agent_lock { sub agent_lock {
my ($pa_config, $dbh, $agent_name) = @_; my ($pa_config, $dbh, $agent_name) = @_;
# Do not lock on LIFO mode if the agent already exist.
# get_agent_id will be called again from process_xml_data,
# so the should be no race conditions if the agent does
# not exist.
if ($pa_config->{'dataserver_lifo'} == 1 &&
get_agent_id ($dbh, $agent_name) > 0) {
return 1;
}
$AgentSem->down (); $AgentSem->down ();
if (defined ($Agents{$agent_name})) { if (defined ($Agents{$agent_name})) {
$AgentSem->up (); $AgentSem->up ();