2012-12-24 Ramon Novoa <rnovoa@artica.es>

* bin/pandora_server: Re-calculate module status count upon server
          startup.

        * util/pandora_db.pl: Use new not-init status for module status count
          calculation.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7326 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2012-12-24 12:15:51 +00:00
parent 0165f07bf0
commit d4196780e3
3 changed files with 25 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2012-12-24 Ramon Novoa <rnovoa@artica.es>
* bin/pandora_server: Re-calculate module status count upon server
startup.
* util/pandora_db.pl: Use new not-init status for module status count
calculation.
2012-12-21 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm,

View File

@ -78,11 +78,24 @@ sub pandora_startup () {
$Config{'dbuser'}, $Config{'dbpass'});
# Grab config tokens shared with the console and not in the .conf
pandora_get_sharedconfig (\%Config, $DBH);
pandora_audit (\%Config, 'Pandora FMS Server Daemon starting', 'SYSTEM', 'System', $DBH);
# Update module status count
print_message (\%Config, " [*] Updating module status count.\n", 1);
my @agents = get_db_rows ($DBH, 'SELECT id_agente FROM tagente');
foreach my $agent (@agents) {
my $agent_id = $agent->{'id_agente'};
db_do ($DBH, 'UPDATE tagente SET normal_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=0 AND disabled=0),
critical_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=1 AND disabled=0),
warning_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=2 AND disabled=0),
unknown_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=3 AND disabled=0),
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=4 AND disabled=0),
total_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND disabled=0)
WHERE id_agente = ' . $agent_id);
}
# Load servers
pandora_reset_server (\%Config, $DBH);
push (@Servers, new PandoraFMS::DataServer (\%Config, $DBH));

View File

@ -569,11 +569,11 @@ sub pandora_checkdb_consistency {
my @agents = get_db_rows ($dbh, 'SELECT id_agente FROM tagente');
foreach my $agent (@agents) {
my $id_agente = $agent->{'id_agente'};
db_do ($dbh, 'UPDATE tagente SET normal_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=0 AND utimestamp<>0 AND disabled=0),
db_do ($dbh, 'UPDATE tagente SET normal_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=0 disabled=0),
critical_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=1 AND disabled=0),
warning_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=2 AND disabled=0),
unknown_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=3 AND disabled=0),
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND utimestamp=0 AND disabled=0),
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=4 AND disabled=0),
total_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND disabled=0)
WHERE id_agente = ' . $id_agente);
}