2000-02-03 Sancho Lerena <slerena@artica.es>
* pandora_db.pl: BUGFIX. DB Maintance was deleting data older than 24hr since commit of 12th January!. * pandora_wmi, pandora_network, pandora_plugin: Algorithm upgraded. First are executed modules with less margin until be considered down and modules with flag of manual execution. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1419 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f7e49b71d3
commit
9f7e9edf00
|
@ -1,3 +1,12 @@
|
||||||
|
2000-02-03 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
|
* pandora_db.pl: BUGFIX. DB Maintance was deleting data older than 24hr
|
||||||
|
since commit of 12th January!.
|
||||||
|
|
||||||
|
* pandora_wmi, pandora_network, pandora_plugin: Algorithm upgraded.
|
||||||
|
First are executed modules with less margin until be considered down and
|
||||||
|
modules with flag of manual execution.
|
||||||
|
|
||||||
2009-01-30 Ramon Novoa <rnovoa@artica.es>
|
2009-01-30 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/DB.pm: Fixed regexp alerts.
|
* lib/PandoraFMS/DB.pm: Fixed regexp alerts.
|
||||||
|
|
|
@ -204,7 +204,7 @@ sub pandora_network_producer ($) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if ($pa_config->{"pandora_master"} != 1) {
|
if ($pa_config->{"pandora_master"} != 1) {
|
||||||
# Query for normal server, not MASTER server
|
# Query for normal server, not MASTER server
|
||||||
$query1 = "SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag
|
$query1 = "SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, UNIX_TIMESTAMP() - tagente_estado.current_interval - tagente_estado.last_execution_try AS time_left
|
||||||
FROM
|
FROM
|
||||||
tagente, tagente_modulo, tagente_estado
|
tagente, tagente_modulo, tagente_estado
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -227,11 +227,11 @@ sub pandora_network_producer ($) {
|
||||||
((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP())
|
((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP())
|
||||||
)
|
)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
last_execution_try ASC ";
|
tagente_modulo.flag DESC, time_left DESC, last_execution_try ASC ";
|
||||||
} else {
|
} else {
|
||||||
# Query for MASTER SERVER !
|
# Query for MASTER SERVER !
|
||||||
# Apparently the MASTER SERVER takes over a SLAVE SERVER tasks' when it's down. Made a subquery of it so it doesn't do 3-4 joins
|
# Apparently the MASTER SERVER takes over a SLAVE SERVER tasks' when it's down. Made a subquery of it so it doesn't do 3-4 joins
|
||||||
$query1 = "SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.last_execution_try
|
$query1 = "SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.last_execution_try, UNIX_TIMESTAMP() - tagente_estado.current_interval - tagente_estado.last_execution_try AS time_left
|
||||||
FROM
|
FROM
|
||||||
tagente, tagente_modulo, tagente_estado
|
tagente, tagente_modulo, tagente_estado
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -257,7 +257,7 @@ sub pandora_network_producer ($) {
|
||||||
OR
|
OR
|
||||||
((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() )
|
((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() )
|
||||||
)
|
)
|
||||||
ORDER BY last_execution_try ASC";
|
ORDER BY tagente_modulo.flag DESC, time_left DESC, last_execution_try ASC";
|
||||||
}
|
}
|
||||||
$exec_sql1 = $dbh->prepare($query1);
|
$exec_sql1 = $dbh->prepare($query1);
|
||||||
$exec_sql1 ->execute;
|
$exec_sql1 ->execute;
|
||||||
|
@ -686,17 +686,8 @@ sub exec_network_module {
|
||||||
pandora_lastagentcontact ($pa_config, $timestamp, $agent_name, $pa_config->{'servername'}.$pa_config->{"servermode"}, $pa_config->{'version'}, -1, $dbh);
|
pandora_lastagentcontact ($pa_config, $timestamp, $agent_name, $pa_config->{'servername'}.$pa_config->{"servermode"}, $pa_config->{'version'}, -1, $dbh);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ($module_interval == 0){
|
|
||||||
$module_interval = dame_intervalo ($pa_config, $id_agente, $dbh);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Modules who cannot connect or something go bad, update last_execution_try field
|
# Modules who cannot connect or something go bad, update last_execution_try field
|
||||||
logger ($pa_config, "Cannot obtain exec Network Module $nombre from agent $agent_name", 3);
|
update_on_error ($pa_config, $id_agente_modulo, $dbh);
|
||||||
my $query_act = "UPDATE tagente_estado SET current_interval = ($module_interval*5), last_execution_try = $utimestamp WHERE id_agente_modulo = $id_agente_modulo ";
|
|
||||||
my $a_idages = $dbh->prepare($query_act);
|
|
||||||
$a_idages->execute;
|
|
||||||
$a_idages->finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,7 @@ sub pandora_plugin_producer ($) {
|
||||||
$query1 = "SELECT
|
$query1 = "SELECT
|
||||||
tagente_modulo.id_agente_modulo,
|
tagente_modulo.id_agente_modulo,
|
||||||
tagente_modulo.flag
|
tagente_modulo.flag
|
||||||
|
UNIX_TIMESTAMP() - tagente_estado.current_interval - tagente_estado.last_execution_try AS time_left
|
||||||
FROM
|
FROM
|
||||||
tagente, tagente_modulo, tagente_estado
|
tagente, tagente_modulo, tagente_estado
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -229,11 +230,11 @@ sub pandora_plugin_producer ($) {
|
||||||
(tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()
|
(tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()
|
||||||
)
|
)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
last_execution_try ASC ";
|
tagente_modulo.flag DESC, time_left DESC, last_execution_try ASC ";
|
||||||
} else {
|
} else {
|
||||||
# Query for MASTER SERVER !
|
# Query for MASTER SERVER !
|
||||||
$query1 = "SELECT
|
$query1 = "SELECT
|
||||||
DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag
|
DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, UNIX_TIMESTAMP() - tagente_estado.current_interval - tagente_estado.last_execution_try AS time_left
|
||||||
FROM
|
FROM
|
||||||
tagente, tagente_modulo, tagente_estado
|
tagente, tagente_modulo, tagente_estado
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -252,7 +253,8 @@ sub pandora_plugin_producer ($) {
|
||||||
tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||||
AND
|
AND
|
||||||
(tagente_modulo.flag = 1 OR (tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() )
|
(tagente_modulo.flag = 1 OR (tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() )
|
||||||
ORDER BY last_execution_try ASC";
|
ORDER BY
|
||||||
|
tagente_modulo.flag DESC, time_left DESC, last_execution_try ASC";
|
||||||
}
|
}
|
||||||
$exec_sql1 = $dbh->prepare($query1);
|
$exec_sql1 = $dbh->prepare($query1);
|
||||||
$exec_sql1 ->execute;
|
$exec_sql1 ->execute;
|
||||||
|
|
|
@ -203,6 +203,7 @@ sub pandora_wmi_producer ($) {
|
||||||
$query1 = "SELECT
|
$query1 = "SELECT
|
||||||
tagente_modulo.id_agente_modulo,
|
tagente_modulo.id_agente_modulo,
|
||||||
tagente_modulo.flag
|
tagente_modulo.flag
|
||||||
|
UNIX_TIMESTAMP() - tagente_estado.current_interval - tagente_estado.last_execution_try AS time_left
|
||||||
FROM
|
FROM
|
||||||
tagente, tagente_modulo, tagente_estado
|
tagente, tagente_modulo, tagente_estado
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -223,11 +224,11 @@ sub pandora_wmi_producer ($) {
|
||||||
tagente_modulo.flag = 1
|
tagente_modulo.flag = 1
|
||||||
)
|
)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
last_execution_try ASC ";
|
tagente_modulo.flag DESC, time_left DESC, last_execution_try ASC ";
|
||||||
} else {
|
} else {
|
||||||
# Query for MASTER SERVER !
|
# Query for MASTER SERVER !
|
||||||
$query1 = "SELECT
|
$query1 = "SELECT
|
||||||
DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag
|
DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, UNIX_TIMESTAMP() - tagente_estado.current_interval - tagente_estado.last_execution_try AS time_left
|
||||||
FROM
|
FROM
|
||||||
tagente, tagente_modulo, tagente_estado, tserver
|
tagente, tagente_modulo, tagente_estado, tserver
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -243,7 +244,8 @@ sub pandora_wmi_producer ($) {
|
||||||
tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo
|
||||||
AND
|
AND
|
||||||
((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() OR tagente_modulo.flag = 1 )
|
((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP() OR tagente_modulo.flag = 1 )
|
||||||
ORDER BY last_execution_try ASC";
|
ORDER BY
|
||||||
|
tagente_modulo.flag DESC, time_left DESC, last_execution_try ASC";
|
||||||
}
|
}
|
||||||
$exec_sql1 = $dbh->prepare($query1);
|
$exec_sql1 = $dbh->prepare($query1);
|
||||||
$exec_sql1 ->execute;
|
$exec_sql1 ->execute;
|
||||||
|
|
|
@ -91,15 +91,17 @@ sub pandora_purgedb {
|
||||||
print "[PURGE] Deleting old access data (More than 24hr) \n";
|
print "[PURGE] Deleting old access data (More than 24hr) \n";
|
||||||
$dbh->do("DELETE FROM tagent_access WHERE utimestamp < '$ulimit_timestamp'");
|
$dbh->do("DELETE FROM tagent_access WHERE utimestamp < '$ulimit_timestamp'");
|
||||||
|
|
||||||
my $limit_event = DateCalc("today","-$config_days_purge days",\$err);
|
$limit_access = DateCalc("today","-$config_days_purge days",\$err);
|
||||||
$limit_event = &UnixDate($limit_event,"%Y-%m-%d %H:%M:%S");
|
$limit_access = &UnixDate($limit_access,"%Y-%m-%d %H:%M:%S");
|
||||||
|
$ulimit_timestamp = &UnixDate($limit_access,"%s");
|
||||||
|
|
||||||
print "[PURGE] Deleting old event data (More than $config_days_purge days)... \n";
|
print "[PURGE] Deleting old event data (More than $config_days_purge days)... \n";
|
||||||
$dbh->do("DELETE FROM tevento WHERE utimestamp < '$ulimit_timestamp'");
|
$dbh->do("DELETE FROM tevento WHERE utimestamp < '$ulimit_timestamp'");
|
||||||
|
|
||||||
print "[PURGE] Deleting old data... \n";
|
print "[PURGE] Deleting old data... \n";
|
||||||
$dbh->do ("DELETE FROM tagente_datos WHERE utimestamp < '$ulimit_timestamp'");
|
$dbh->do ("DELETE FROM tagente_datos WHERE utimestamp < '$ulimit_timestamp'");
|
||||||
print "[PURGE] Delete old data (string) ... \n";
|
print "[PURGE] Delete old data (string) ... \n";
|
||||||
$dbh->do ("DELETE FROM tagente_datos_string WHERE utimestamp < '$ulimit_timestamp'");
|
$dbh->do ("DELETE FROM tagente_datos_string WHERE utimestamp < '$ulimit_timestamp'");
|
||||||
|
|
||||||
print "[PURGE] Delete pending deleted modules (data table)...\n";
|
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)");
|
$dbh->do ("DELETE FROM tagente_datos WHERE id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1)");
|
||||||
|
@ -110,7 +112,6 @@ sub pandora_purgedb {
|
||||||
print "[PURGE] Delete pending deleted modules (data inc table)...\n";
|
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)");
|
$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";
|
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_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");
|
$dbh->do ("DELETE FROM tagente_modulo WHERE delete_pending = 1");
|
||||||
|
@ -504,9 +505,11 @@ sub help_screen{
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub pandoradb_main {
|
sub pandoradb_main {
|
||||||
|
|
||||||
|
print "Starting at ". &UnixDate("today","%Y/%m/%d %H:%M:%S"). "\n";
|
||||||
pandora_purgedb ($config_days_purge, $dbname, $dbuser, $dbpass, $dbhost);
|
pandora_purgedb ($config_days_purge, $dbname, $dbuser, $dbpass, $dbhost);
|
||||||
pandora_checkdb_consistency ($dbname, $dbuser, $dbpass, $dbhost);
|
pandora_checkdb_consistency ($dbname, $dbuser, $dbpass, $dbhost);
|
||||||
pandora_compactdb ($config_days_compact, $dbname, $dbuser, $dbpass, $dbhost);
|
pandora_compactdb ($config_days_compact, $dbname, $dbuser, $dbpass, $dbhost);
|
||||||
print "\n";
|
print "Ending at ". &UnixDate("today","%Y/%m/%d %H:%M:%S"). "\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue