Improve pandora_server_tasks.

* Do not let pandora_server_tasks die.
* Remove a query from self_monitoring that could freeze the
  pandora_server_tasks thread.
This commit is contained in:
Ramon Novoa 2023-02-02 11:49:09 +01:00
parent a200362ffe
commit 5106e658c3
2 changed files with 91 additions and 100 deletions

View File

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

View File

@ -6005,10 +6005,6 @@ sub pandora_self_monitoring ($$) {
$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]);
$xml_output .= $elasticsearch_perfomance if defined($elasticsearch_perfomance);
@ -6055,13 +6051,6 @@ sub pandora_self_monitoring ($$) {
$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>";
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".self.".$utimestamp.".data";