2013-02-14 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/Core.pm bin/pandora_server util/pandora_db.pl: Adapt status counts querys to use only not disabled modules git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7652 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
9becfa4231
commit
ad40156f0e
|
@ -1,3 +1,10 @@
|
||||||
|
2013-02-14 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Core.pm
|
||||||
|
bin/pandora_server
|
||||||
|
util/pandora_db.pl: Adapt status counts querys to use only
|
||||||
|
not disabled modules
|
||||||
|
|
||||||
2013-02-13 Ramon Novoa <rnovoa@artica.es>
|
2013-02-13 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/NmapParser.pm: Merged with version 1.3 of Nmap::Parser.
|
* lib/PandoraFMS/NmapParser.pm: Merged with version 1.3 of Nmap::Parser.
|
||||||
|
|
|
@ -87,12 +87,12 @@ sub pandora_startup () {
|
||||||
my @agents = get_db_rows ($DBH, 'SELECT id_agente FROM tagente');
|
my @agents = get_db_rows ($DBH, 'SELECT id_agente FROM tagente');
|
||||||
foreach my $agent (@agents) {
|
foreach my $agent (@agents) {
|
||||||
my $agent_id = $agent->{'id_agente'};
|
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),
|
db_do ($DBH, 'UPDATE tagente SET normal_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=0 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
critical_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=1 AND disabled=0),
|
critical_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=1 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
warning_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=2 AND disabled=0),
|
warning_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=2 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
unknown_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=3 AND disabled=0),
|
unknown_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=3 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=4 AND disabled=0),
|
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND estado=4 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
total_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND disabled=0)
|
total_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $agent_id . ' AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0))
|
||||||
WHERE id_agente = ' . $agent_id);
|
WHERE id_agente = ' . $agent_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2238,13 +2238,15 @@ sub pandora_create_module_from_hash ($$$) {
|
||||||
|
|
||||||
db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', $module_id, $parameters->{'id_agente'}, $status, $status, $status);
|
db_do ($dbh, 'INSERT INTO tagente_estado (id_agente_modulo, id_agente, estado, last_status, last_known_status, last_try) VALUES (?, ?, ?, ?, ?, \'1970-01-01 00:00:00\')', $module_id, $parameters->{'id_agente'}, $status, $status, $status);
|
||||||
|
|
||||||
# Update the module status count
|
# Update the module status count. When the module is created disabled dont do it
|
||||||
|
if(!defined($parameters->{'disabled'}) || $parameters->{'disabled'} == 0) {
|
||||||
if ($status == 4) {
|
if ($status == 4) {
|
||||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=?', $parameters->{'id_agente'});
|
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, notinit_count=notinit_count+1 WHERE id_agente=?', $parameters->{'id_agente'});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=?', $parameters->{'id_agente'});
|
db_do ($dbh, 'UPDATE tagente SET total_count=total_count+1, normal_count=normal_count+1 WHERE id_agente=?', $parameters->{'id_agente'});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $module_id;
|
return $module_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -637,8 +637,6 @@ sub pandora_checkdb_consistency {
|
||||||
|
|
||||||
# Delete the module
|
# Delete the module
|
||||||
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE id_agente_modulo = ?', $id_agente_modulo);
|
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE id_agente_modulo = ?', $id_agente_modulo);
|
||||||
# Update the module status count
|
|
||||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count-1, notinit_count=notinit_count-1 WHERE id_agente=?', $module->{'id_agente'});
|
|
||||||
|
|
||||||
# Delete any alerts associated to the module
|
# Delete any alerts associated to the module
|
||||||
db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ?', $id_agente_modulo);
|
db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ?', $id_agente_modulo);
|
||||||
|
@ -655,10 +653,7 @@ sub pandora_checkdb_consistency {
|
||||||
next if (defined($is_policy_module) && $is_policy_module);
|
next if (defined($is_policy_module) && $is_policy_module);
|
||||||
|
|
||||||
# Delete the module
|
# Delete the module
|
||||||
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);;
|
db_do ($dbh, 'DELETE FROM tagente_modulo WHERE disabled = 0 AND id_agente_modulo = ?', $id_agente_modulo);
|
||||||
|
|
||||||
# Update the module status count
|
|
||||||
db_do ($dbh, 'UPDATE tagente SET total_count=total_count-1, unknown_count=unknown_count-1 WHERE id_agente=?', $module->{'id_agente'});
|
|
||||||
|
|
||||||
# Delete any alerts associated to the module
|
# Delete any alerts associated to the module
|
||||||
db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ? AND NOT EXISTS (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente_modulo = ?)', $id_agente_modulo, $id_agente_modulo);
|
db_do ($dbh, 'DELETE FROM talert_template_modules WHERE id_agent_module = ? AND NOT EXISTS (SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente_modulo = ?)', $id_agente_modulo, $id_agente_modulo);
|
||||||
|
@ -700,12 +695,12 @@ sub pandora_checkdb_consistency {
|
||||||
my @agents = get_db_rows ($dbh, 'SELECT id_agente FROM tagente');
|
my @agents = get_db_rows ($dbh, 'SELECT id_agente FROM tagente');
|
||||||
foreach my $agent (@agents) {
|
foreach my $agent (@agents) {
|
||||||
my $id_agente = $agent->{'id_agente'};
|
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 disabled=0),
|
db_do ($dbh, 'UPDATE tagente SET normal_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=0 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
critical_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=1 AND disabled=0),
|
critical_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=1 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
warning_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=2 AND disabled=0),
|
warning_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=2 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
unknown_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=3 AND disabled=0),
|
unknown_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=3 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=4 AND disabled=0),
|
notinit_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND estado=4 AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0)),
|
||||||
total_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND disabled=0)
|
total_count=(SELECT COUNT(*) FROM tagente_estado WHERE id_agente=' . $id_agente . ' AND id_agente_modulo IN (SELECT id_agente_modulo FROM tagente_modulo WHERE disabled=0))
|
||||||
WHERE id_agente = ' . $id_agente);
|
WHERE id_agente = ' . $id_agente);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue