From 550704843d8b633b15909db2183e83c63b981327 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 28 Nov 2012 13:04:11 +0000 Subject: [PATCH] 2012-11-28 Ramon Novoa * include/functions_groups.php, include/functions_treeview.php, include/functions_os.php, include/functions_tags.php, operation/tree.php: Small fixes to the treeview. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7195 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 +++ pandora_console/include/functions_groups.php | 8 +-- pandora_console/include/functions_os.php | 8 +-- pandora_console/include/functions_tags.php | 4 ++ .../include/functions_treeview.php | 59 +++++++++---------- pandora_console/operation/tree.php | 6 +- 6 files changed, 54 insertions(+), 39 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index dd2366a725..347ef88b17 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2012-11-28 Ramon Novoa + + * include/functions_groups.php, + include/functions_treeview.php, + include/functions_os.php, + include/functions_tags.php, + operation/tree.php: Small fixes to the treeview. + 2012-11-28 Sergio Martin * include/functions_treeview.php diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index c82f80bdfe..05648daf58 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -865,7 +865,7 @@ function groups_agent_unknown ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); } // Get ok agents by using the status code in modules. @@ -883,7 +883,7 @@ function groups_agent_ok ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE normal_count=total_count AND id_grupo IN $group_clause"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_grupo IN $group_clause"); } // Get critical agents by using the status code in modules. @@ -901,7 +901,7 @@ function groups_agent_critical ($group_array) { $group_clause = "(" . $group_clause . ")"; //TODO REVIEW ORACLE AND POSTGRES - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE critical_count>0 AND id_grupo IN $group_clause"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); } @@ -919,7 +919,7 @@ function groups_agent_warning ($group_array) { $group_clause = implode (",", $group_array); $group_clause = "(" . $group_clause . ")"; - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); } diff --git a/pandora_console/include/functions_os.php b/pandora_console/include/functions_os.php index 6c85faa1f5..5f8366bfc6 100755 --- a/pandora_console/include/functions_os.php +++ b/pandora_console/include/functions_os.php @@ -20,28 +20,28 @@ function os_agents_critical ($id_os) { //TODO REVIEW ORACLE AND POSTGRES - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE critical_count>0 AND id_os=$id_os"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_os=$id_os"); } // Get ok agents by using the status code in modules. function os_agents_ok($id_os) { - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE normal_count=total_count AND id_os=$id_os"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_os=$id_os"); } // Get warning agents by using the status code in modules. function os_agents_warning ($id_os) { - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE critical_count=0 AND warning_count>0 AND id_os=$id_os"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_os=$id_os"); } // Get unknown agents by using the status code in modules. function os_agents_unknown ($id_os) { - return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_os=$id_os"); + return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_os=$id_os"); } // Get the name of a group given its id. diff --git a/pandora_console/include/functions_tags.php b/pandora_console/include/functions_tags.php index 5cf15ab858..b9ce24ed6c 100644 --- a/pandora_console/include/functions_tags.php +++ b/pandora_console/include/functions_tags.php @@ -30,6 +30,7 @@ function tags_agent_critical ($id_tag) { return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled=0 AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = $id_tag AND critical_count>0"); @@ -46,6 +47,7 @@ function tags_agent_unknown ($id_tag) { return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled=0 AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = $id_tag AND critical_count=0 AND warning_count=0 AND unknown_count>0"); @@ -84,6 +86,7 @@ function tags_agent_ok ($id_tag) { return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled=0 AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = $id_tag AND normal_count=total_count"); @@ -100,6 +103,7 @@ function tags_agent_warning ($id_tag) { return db_get_sql ("SELECT COUNT(*) FROM tagente, tagente_modulo, ttag_module WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled=0 AND tagente_modulo.id_agente_modulo = ttag_module.id_agente_modulo AND ttag_module.id_tag = $id_tag AND critical_count=0 AND warning_count>0"); diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 3127a8ca63..0e67ddc7bb 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -259,7 +259,11 @@ function treeview_printTree($type) { } echo "
  • "; - echo ""; + + // Convert the id to hexadecimal, since it will be used as a div id + $hex_id = unpack ('H*', $item['_id_']); + $hex_id = $hex_id[1]; + echo ""; echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('. ''.''.$item['_num_ok_'].''.''. @@ -267,7 +271,7 @@ function treeview_printTree($type) { ' : '.$item['_num_warning_'].''. ' : '.$item['_num_unknown_'].''.') '. ""; - echo "
    "; + echo "
    "; echo "
  • \n"; } echo "\n"; @@ -296,8 +300,7 @@ function treeview_getData ($type, $server=false) { $avariableGroups = users_get_groups (); //db_get_all_rows_in_table('tgrupo', 'nombre'); //Get all groups with agents - //$full_groups = db_get_all_rows_sql("SELECT DISTINCT id_grupo FROM tagente WHERE total_count > 0"); - $full_groups = db_get_all_rows_sql("SELECT DISTINCT id_grupo FROM tagente"); + $full_groups = db_get_all_rows_sql("SELECT DISTINCT id_grupo FROM tagente WHERE total_count > 0"); if ($full_groups === false) { return array (); } @@ -373,7 +376,7 @@ function treeview_getData ($type, $server=false) { if ($search_free != '') { $sql_search = " AND id_grupo IN (SELECT id_grupo FROM tagente - WHERE nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; + WHERE tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%')"; } else { $sql_search =''; @@ -381,10 +384,7 @@ function treeview_getData ($type, $server=false) { switch ($type) { - case 'os': - //Skip agent with all modules in not init status - $sql_search .= " AND total_count<>notinit_count"; - + case 'os': $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, @@ -421,8 +421,6 @@ function treeview_getData ($type, $server=false) { } break; case 'module_group': - //Skip agents which only have not init modules - $sql_search .= " AND total_count<>notinit_count"; $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, @@ -651,10 +649,21 @@ function treeview_getData ($type, $server=false) { break; case 'tag': - $list = db_get_all_rows_sql('SELECT DISTINCT ttag.name - FROM ttag, ttag_module, tagente_modulo - WHERE ttag.id_tag = ttag_module.id_tag AND - ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'); + $sql = 'SELECT DISTINCT ttag.name + FROM ttag, ttag_module, tagente, tagente_modulo + WHERE ttag.id_tag = ttag_module.id_tag + AND tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled = 0 + AND ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'; + if ($search_free != '') { + $sql = "SELECT DISTINCT ttag.name + FROM ttag, ttag_module, tagente, tagente_modulo + WHERE ttag.id_tag = ttag_module.id_tag + AND tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled = 0 + AND ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; + } + $list = db_get_all_rows_sql($sql); break; } @@ -751,7 +760,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel $groups_sql = implode(', ', $avariableGroupsIds); if ($search_free != '') { - $search_sql = " AND nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; + $search_sql = " AND tagente.nombre COLLATE utf8_general_ci LIKE '%$search_free%'"; } else { $search_sql = ''; @@ -762,14 +771,11 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel case 'group': if (defined ('METACONSOLE')) { - $id = groups_get_id ($id); + $id = groups_get_id (pack ('H*', $id)); if ($id == '') { return false; } } - - //Skip agents which only have not init modules - $search_sql .= " AND total_count<>notinit_count"; $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', @@ -782,11 +788,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel false, true); break; - case 'os': - - //Skip agents which only have not init modules - $search_sql .= " AND total_count<>notinit_count"; - + case 'os': $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', @@ -800,10 +802,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel true); break; case 'module_group': - - //Skip agents which only have not init modules - $search_sql .= " AND total_count<>notinit_count"; - + $sql = agents_get_agents(array ( 'order' => 'nombre COLLATE utf8_general_ci ASC', 'disabled' => 0, @@ -885,7 +884,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel ', $name); break; case 'tag': - $id = tags_get_id ($id); + $id = tags_get_id (pack ('H*', $id)); if ($id === false) { return false; } diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index c39d1d9ce7..e4564991da 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -485,7 +485,11 @@ if (! defined ('METACONSOLE')) { } echo "
    "; -echo '