2013-08-02 Sergio Martin <sergio.martin@artica.es>

* include/functions_modules.php: Fix modules and 
	alerts count when delete modules massively



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8621 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2013-08-02 10:48:30 +00:00
parent d4f4611b76
commit b6ae3efc27
2 changed files with 28 additions and 36 deletions

View File

@ -1,3 +1,8 @@
2013-08-02 Sergio Martin <sergio.martin@artica.es>
* include/functions_modules.php: Fix modules and
alerts count when delete modules massively
2013-08-01 Miguel de Dios <miguel.dedios@artica.es> 2013-08-01 Miguel de Dios <miguel.dedios@artica.es>
* enterprise/godmode/agentes/agent_disk_conf_editor.php, * enterprise/godmode/agentes/agent_disk_conf_editor.php,

View File

@ -199,11 +199,30 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
* @return True if the module was deleted. False if not. * @return True if the module was deleted. False if not.
*/ */
function modules_delete_agent_module ($id_agent_module) { function modules_delete_agent_module ($id_agent_module) {
if (!$id_agent_module) if (empty($id_agent_module))
return false; return false;
if (is_array($id_agent_module)) {
$id_agents = db_get_all_rows_sql (sprintf('SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo IN (%s) GROUP BY id_agente', implode(',', $id_agent_module)));
foreach($id_agents as $k => $v) {
$id_agents[$k] = $v['id_agente'];
}
// Update update flags to server side
db_process_sql (sprintf('UPDATE tagente
SET update_module_count=1, update_alert_count=1
WHERE id_agente IN (%s)', implode(',', $id_agents)));
}
else {
// Read module data // Read module data
$module = db_get_row_sql ('SELECT * FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.id_agente_modulo=' . (int)$id_agent_module); $id_agent = modules_get_agentmodule_agent($id_agent_module);
// Update update flags to server side
db_process_sql (sprintf('UPDATE tagente
SET update_module_count=1, update_alert_count=1
WHERE id_agente = %s', $id_agent));
}
$where = array ('id_agent_module' => $id_agent_module); $where = array ('id_agent_module' => $id_agent_module);
@ -222,38 +241,6 @@ function modules_delete_agent_module ($id_agent_module) {
$where); $where);
db_process_sql_delete('ttag_module', $where); db_process_sql_delete('ttag_module', $where);
// Update module status count only if the module is not disabled
if ($module['disabled'] == 0) {
if ($module['estado'] == AGENT_MODULE_STATUS_NORMAL) {
db_process_sql ('UPDATE tagente
SET normal_count=normal_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_CRITICAL_BAD) {
db_process_sql ('UPDATE tagente
SET critical_count=critical_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_WARNING) {
db_process_sql ('UPDATE tagente
SET warning_count=warning_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_UNKNOWN) {
db_process_sql ('UPDATE tagente
SET unknown_count=unknown_count-1
WHERE id_agente=' . $module['id_agente']);
}
else if ($module['estado'] == AGENT_MODULE_STATUS_NO_DATA) {
db_process_sql ('UPDATE tagente
SET notinit_count=notinit_count-1
WHERE id_agente=' . $module['id_agente']);
}
db_process_sql ('UPDATE tagente
SET total_count=total_count-1
WHERE id_agente=' . $module['id_agente']);
}
return true; return true;
} }