2009-01-26 Sancho Lerena <slerena@artica.es>

* DB.pm: Fixed NOT behaviour of alerts, now works as supposed to do.
	
	* pandora_db.pl: Deleted pending modules, fixed problems using bad DB
	function. 

	* Config.pm: Version update.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1402 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2009-01-26 15:05:33 +00:00
parent 2e2a2bf6fc
commit 759260ba22
4 changed files with 27 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2009-01-26 Sancho Lerena <slerena@artica.es>
* DB.pm: Fixed NOT behaviour of alerts, now works as supposed to do.
* pandora_db.pl: Deleted pending modules, fixed problems using bad DB
function.
2009-01-26 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/DB.pm: Added a new alert macro (_address_).

View File

@ -39,7 +39,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "2.1-dev";
my $pandora_build="PS090120";
my $pandora_build="PS090126";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -235,10 +235,10 @@ sub pandora_evaluate_alert (%$%$$$) {
return $status;
}
}
elsif ($alert_data->{'type'} eq "equal" && $module_data == $alert_data->{'value'}) {
elsif ($alert_data->{'type'} eq "equal" && $module_data != $alert_data->{'value'}) {
return $status;
}
elsif ($alert_data->{'type'} eq "not_equal" && $module_data != $alert_data->{'value'}) {
elsif ($alert_data->{'type'} eq "not_equal" && $module_data == $alert_data->{'value'}) {
return $status;
}
elsif ($alert_data->{'type'} eq "regex") {

View File

@ -24,6 +24,7 @@ use Time::Local; # DateTime basic manipulation
use DBI; # DB interface with MySQL
use Date::Manip; # Date/Time manipulation
use PandoraFMS::Tools;
use PandoraFMS::DB;
# version: define la version actual del programa
my $version = "2.1 PS090105";
@ -100,13 +101,25 @@ sub pandora_purgedb {
print "[PURGE] Delete old data (string) ... \n";
$dbh->do ("DELETE FROM tagente_datos_string WHERE utimestamp < '$ulimit_timestamp'");
# TODO: Delete data from tagente_modulo items marked for deletion
print "[PURGE] Delete pending deleted modules (data table)...\n";
$dbh->do ("DELETE FROM tagente_datos WHERE id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1)");
print "[PURGE] Delete pending deleted modules (data string table)...\n";
$dbh->do ("DELETE FROM tagente_datos_string WHERE id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1)");
print "[PURGE] Delete pending deleted modules (data inc table)...\n";
$dbh->do ("DELETE FROM tagente_datos_inc WHERE id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1)");
print "[PURGE] Delete pending deleted modules (status, module table)...\n";
$dbh->do ("DELETE FROM tagente_estado WHERE id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1)");
$dbh->do ("DELETE FROM tagente_modulo WHERE delete_pending = 1");
print "[PURGE] Delete old session data \n";
db_delete ("DELETE FROM tsesion WHERE utimestamp < $ulimit_timestamp", $dbh);
db_do ("DELETE FROM tsesion WHERE utimestamp < $ulimit_timestamp", $dbh);
print "[PURGE] Delete old data from SNMP Traps \n";
db_delete("DELETE FROM ttrap WHERE timestamp < '$limit_timestamp'", $dbh);
db_do ("DELETE FROM ttrap WHERE timestamp < '$limit_timestamp'", $dbh);
$dbh->disconnect();
}
@ -407,7 +420,7 @@ sub pandora_checkdb_consistency {
# If have 0 items, we need to create tagente_estado record
if ($prep2->rows == 0) {
my $id_agente = $datarow1[1];
my $query3 = "INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, cambio, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUE ($id_agente_modulo, 0, '0000-00-00 00:00:00', 0, 100, $id_agente, '0000-00-00 00:00:00', 0, 0, 0, 0)";
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)";
print "[CHECKDB] Inserting module $id_agente_modulo in state table \n";
my $prep3 = $dbh->prepare($query3);
$prep3->execute;