From 585aef05357bdd61ecc784b8bf7de3a8a2d369f4 Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 30 Sep 2009 16:24:02 +0000 Subject: [PATCH] 2009-09-30 Sancho Lerena * lib/PandoraFMS/DataServer.pm: Reduced timeout for sleep on BADXML from 60 to 10 sec. This could result in bottleneck when several BADXML found at the same time. Default code retries 3 times x 10 secs, time enough to discard and retry. * util/pandora_db.pl: Disabled non-init modules are not deleted. This is needed for disabled modules coming from a remote conf (manual or by policy) who cannot execute in agent. If are deleted each day after purge, will appear as "unknown" and admin will need to disable it again, and the same next day. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1994 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 11 ++++ pandora_server/lib/PandoraFMS/DataServer.pm | 2 +- pandora_server/util/pandora_db.pl | 60 ++++++++++----------- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index b3c0ca1547..aa3543ce47 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,5 +1,16 @@ 2009-09-30 Sancho Lerena + * lib/PandoraFMS/DataServer.pm: Reduced timeout for sleep + on BADXML from 60 to 10 sec. This could result in bottleneck + when several BADXML found at the same time. Default code + retries 3 times x 10 secs, time enough to discard and retry. + + * util/pandora_db.pl: Disabled non-init modules are not deleted. + This is needed for disabled modules coming from a remote conf + (manual or by policy) who cannot execute in agent. If are + deleted each day after purge, will appear as "unknown" and + admin will need to disable it again, and the same next day. + * pandora_server.spec: A complete uninstall for RPM. Database is not killed because user could be just uninstalling one of multiple servers and drop it will not be funny :-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index fd75fde433..a7543db131 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -132,7 +132,7 @@ sub data_consumer ($$) { # Invalid XML if ($@) { - sleep (60); + sleep (10); next; } diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 14033ec24e..9221cfddbf 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -26,7 +26,7 @@ use PandoraFMS::Tools; use PandoraFMS::DB; # version: define la version actual del programa -my $version = "3.0-dev PS090917"; +my $version = "3.0-dev PS090930"; # Setup variables my $dirname=""; @@ -394,16 +394,35 @@ sub pandora_checkdb_consistency { # 1. Check for modules that do not have tagente_estado but have tagente_module - my $dbname = $_[0]; - my $dbuser = $_[1]; - my $dbpass = $_[2]; - my $dbhost = $_[3]; + my $dbname = $_[0]; + my $dbuser = $_[1]; + my $dbpass = $_[2]; + my $dbhost = $_[3]; + my @query; my $counter; my $err; # error code in datecalc function my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost:3306",$dbuser, $dbpass,{RaiseError => 1, AutoCommit => 1 }); - print "[CHECKDB] Checking database consistency (step1)... \n"; + print "[CHECKDB] Deleting non-init data... \n"; + my $query4 = "SELECT * FROM tagente_estado WHERE utimestamp = 0"; + my $prep4 = $dbh->prepare($query4); + $prep4 ->execute; + my @datarow4; + if ($prep4->rows != 0) { + # for each record in tagente_modulo + while (@datarow4 = $prep4->fetchrow_array()) { + my $id_agente_modulo = $datarow4[1]; + my $query0 = "DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = $id_agente_modulo"; + my $prep0 = $dbh->prepare($query0); + $prep0 ->execute; + $prep0->finish(); + } + } + $prep4->finish(); + + print "[CHECKDB] Checking database consistency (Missing status)... \n"; + my $query1 = "SELECT * FROM tagente_modulo"; my $prep1 = $dbh->prepare($query1); $prep1 ->execute; @@ -416,7 +435,7 @@ sub pandora_checkdb_consistency { my $query2 = "SELECT * FROM tagente_estado WHERE id_agente_modulo = $id_agente_modulo"; my $prep2 = $dbh->prepare($query2); $prep2->execute; - # If have 0 items, we need to create tagente_estado record + # If have 0 items, we need to re-create tagente_estado record if ($prep2->rows == 0) { my $id_agente = $datarow1[1]; my $query3 = "INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUE ($id_agente_modulo, 0, '0000-00-00 00:00:00', 1, $id_agente, '0000-00-00 00:00:00', 0, 0, 0, 0)"; @@ -430,8 +449,9 @@ sub pandora_checkdb_consistency { } $prep1->finish(); - print "[CHECKDB] Checking database consistency (step2)... \n"; + print "[CHECKDB] Checking database consistency (Missing module)... \n"; # 2. Check for modules in tagente_estado that do not have tagente_modulo, if there is any, delete it + my $query1 = "SELECT * FROM tagente_estado"; my $prep1 = $dbh->prepare($query1); $prep1 ->execute; @@ -458,30 +478,6 @@ sub pandora_checkdb_consistency { } $prep1->finish(); - print "[CHECKDB] Deleting non-init data... \n"; - my $query4 = "SELECT * FROM tagente_estado WHERE utimestamp = 0"; - my $prep4 = $dbh->prepare($query4); - $prep4 ->execute; - my @datarow4; - if ($prep4->rows != 0) { - # for each record in tagente_modulo - while (@datarow4 = $prep4->fetchrow_array()) { - my $id_agente_modulo = $datarow4[1]; - my $query0 = "DELETE FROM tagente_modulo WHERE id_agente_modulo = $id_agente_modulo"; - my $prep0 = $dbh->prepare($query0); - $prep0 ->execute; - $prep0->finish(); - } - } - $prep4->finish(); - - # Delete from tagente_estado - my $query0 = "DELETE FROM tagente_estado WHERE utimestamp = 0"; - my $prep0 = $dbh->prepare($query0); - $prep0 ->execute; - $prep0->finish(); - - } ##############################################################################