diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5b30de9d9d..b7257b1c3c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2013-09-30 Miguel de Dios + + * include/functions_agents.php: added code for to delete the nodes + of any agent when it is deleted. + 2013-09-30 Vanessa Gil * include/languages/ar.mo diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 72c25ba233..b05f236580 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1621,7 +1621,8 @@ function agents_delete_agent ($id_agents, $disableACL = false) { $addresses = array (); } foreach ($addresses as $address) { - db_process_delete_temp ("taddress_agent", "id_ag", $address["id_ag"]); + db_process_delete_temp ("taddress_agent", + "id_ag", $address["id_ag"]); } // We cannot delete tagente_datos and tagente_datos_string here @@ -1630,20 +1631,40 @@ function agents_delete_agent ($id_agents, $disableACL = false) { // daily maintance process, all data for that modules are deleted //Alert - db_process_delete_temp ("talert_template_modules", "id_agent_module", $where_modules); + db_process_delete_temp ("talert_template_modules", + "id_agent_module", $where_modules); //Events (up/down monitors) // Dont delete here, could be very time-exausting, let the daily script // delete them after XXX days // db_process_delete_temp ("tevento", "id_agente", $id_agent); - //Graphs, layouts & reports - db_process_delete_temp ("tgraph_source", "id_agent_module", $where_modules); - db_process_delete_temp ("tlayout_data", "id_agente_modulo", $where_modules); - db_process_delete_temp ("treport_content", "id_agent_module", $where_modules); + //Graphs, layouts, reports & networkmapenterprise + db_process_delete_temp ("tgraph_source", + "id_agent_module", $where_modules); + db_process_delete_temp ("tlayout_data", + "id_agente_modulo", $where_modules); + db_process_delete_temp ("treport_content", + "id_agent_module", $where_modules); + if (enterprise_installed()) { + $nodes = db_get_all_rows_filter( + "tnetworkmap_enterprise_nodes", + array("id_agent" => $id_agent)); + + foreach ($nodes as $node) { + db_process_delete_temp ("tnetworkmap_enterprise_relation_nodes", + "parent", $node['id']); + db_process_delete_temp ("tnetworkmap_enterprise_relation_nodes", + "child", $node['id']); + } + + db_process_delete_temp ("tnetworkmap_enterprise_nodes", + "id_agent", $id_agent); + } //Planned Downtime - db_process_delete_temp ("tplanned_downtime_agents", "id_agent", $id_agent); + db_process_delete_temp ("tplanned_downtime_agents", "id_agent", + $id_agent); //The status of the module db_process_delete_temp ("tagente_estado", "id_agente", $id_agent);