From d6c47ca069d296197140f95d23f79e1230d2d296 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Thu, 14 Dec 2023 16:21:22 -0600 Subject: [PATCH 1/3] Disable PrintError on DB --- pandora_server/lib/PandoraFMS/DB.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index c0ee332f64..9ee699a08c 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -1263,6 +1263,7 @@ sub db_delete_limit ($$$$;@) { sub db_insert ($$$;@) { my ($dbh, $index, $query, @values) = @_; my $insert_id = undef; + $dbh->{PrintError} = 0; eval { $dbh->do($query, undef, @values); @@ -1288,6 +1289,7 @@ sub db_insert ($$$;@) { sub db_update ($$;@) { my ($dbh, $query, @values) = @_; my $rows; + $dbh->{PrintError} = 0; eval { $rows = $dbh->do($query, undef, @values); @@ -1533,7 +1535,8 @@ sub get_agent_addr_id ($$$) { ######################################################################## sub db_do ($$;@) { my ($dbh, $query, @values) = @_; - + $dbh->{PrintError} = 0; + #DBI->trace( 3, '/tmp/dbitrace.log' ); eval { $dbh->do($query, undef, @values); From 3d71d27d6b58a6b7d31815a82fa0469739d47df8 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Sat, 16 Dec 2023 23:59:21 -0600 Subject: [PATCH 2/3] Change autodisabled query --- pandora_server/lib/PandoraFMS/Core.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 84d3d51bd2..e6f61836e6 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -7187,10 +7187,18 @@ Puts all autodisable agents with all modules unknown on disabled mode sub pandora_disable_autodisable_agents ($$) { my ($pa_config, $dbh) = @_; - my $sql = 'SELECT id_agente FROM tagente - WHERE disabled=0 AND - tagente.unknown_count>0 AND - tagente.modo=2'; + + my $sql = 'SELECT id_agente + FROM ( + SELECT tm.id_agente, count(*) as sync_modules, ta.unknown_count + FROM tagente_modulo tm + JOIN tagente ta ON ta.id_agente = tm.id_agente + WHERE ta.disabled = 0 + AND NOT ((id_tipo_modulo >= 21 AND id_tipo_modulo <= 23) OR id_tipo_modulo = 100) + GROUP BY tm.id_agente + ) AS subquery + WHERE subquery.unknown_count >= subquery.sync_modules;'; + my @agents_autodisabled = get_db_rows ($dbh, $sql); return if ($#agents_autodisabled < 0); From d348f1bf1db26d5b6048a7688c3a72fb21136884 Mon Sep 17 00:00:00 2001 From: "felix.suarez" Date: Sun, 17 Dec 2023 00:01:47 -0600 Subject: [PATCH 3/3] Remove conf db change --- pandora_server/lib/PandoraFMS/DB.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DB.pm b/pandora_server/lib/PandoraFMS/DB.pm index 9ee699a08c..b417e44efd 100644 --- a/pandora_server/lib/PandoraFMS/DB.pm +++ b/pandora_server/lib/PandoraFMS/DB.pm @@ -1263,7 +1263,6 @@ sub db_delete_limit ($$$$;@) { sub db_insert ($$$;@) { my ($dbh, $index, $query, @values) = @_; my $insert_id = undef; - $dbh->{PrintError} = 0; eval { $dbh->do($query, undef, @values); @@ -1289,7 +1288,6 @@ sub db_insert ($$$;@) { sub db_update ($$;@) { my ($dbh, $query, @values) = @_; my $rows; - $dbh->{PrintError} = 0; eval { $rows = $dbh->do($query, undef, @values); @@ -1535,7 +1533,6 @@ sub get_agent_addr_id ($$$) { ######################################################################## sub db_do ($$;@) { my ($dbh, $query, @values) = @_; - $dbh->{PrintError} = 0; #DBI->trace( 3, '/tmp/dbitrace.log' ); eval {