2012-11-28 Ramon Novoa <rnovoa@artica.es>
* 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
This commit is contained in:
parent
895fb864b2
commit
550704843d
|
@ -1,3 +1,11 @@
|
|||
2012-11-28 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* 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 <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_treeview.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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -259,7 +259,11 @@ function treeview_printTree($type) {
|
|||
}
|
||||
|
||||
echo "<li style='margin: 0px 0px 0px 0px;'>";
|
||||
echo "<a onfocus='JavaScript: this.blur()' href='javascript: loadSubTree(\"" . $type . "\",\"" . $item['_id_'] . "\", " . $lessBranchs . ", \"\", \"\")'>";
|
||||
|
||||
// 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 "<a onfocus='JavaScript: this.blur()' href='javascript: loadSubTree(\"" . $type . "\",\"" . $hex_id . "\", " . $lessBranchs . ", \"\", \"\")'>";
|
||||
|
||||
echo $img . $item['_iconImg_'] ." " . __($item['_name_']) . ' ('.
|
||||
'<span class="green">'.'<b>'.$item['_num_ok_'].'</b>'.'</span>'.
|
||||
|
@ -267,7 +271,7 @@ function treeview_printTree($type) {
|
|||
' : <span class="yellow">'.$item['_num_warning_'].'</span>'.
|
||||
' : <span class="grey">'.$item['_num_unknown_'].'</span>'.') '. "</a>";
|
||||
|
||||
echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "_" . $item['_id_'] . "'></div>";
|
||||
echo "<div hiddenDiv='1' loadDiv='0' style='margin: 0px; padding: 0px;' class='tree_view' id='tree_div_" . $type . "_" . $hex_id . "'></div>";
|
||||
echo "</li>\n";
|
||||
}
|
||||
echo "</ul>\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 ='';
|
||||
|
@ -382,9 +385,6 @@ 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";
|
||||
|
||||
$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,15 +771,12 @@ 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',
|
||||
'id_grupo' => $id,
|
||||
|
@ -784,10 +790,6 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel
|
|||
break;
|
||||
case 'os':
|
||||
|
||||
//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',
|
||||
'id_os' => $id,
|
||||
|
@ -801,9 +803,6 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -485,7 +485,11 @@ if (! defined ('METACONSOLE')) {
|
|||
}
|
||||
|
||||
echo "<br>";
|
||||
if (! defined ('METACONSOLE')) {
|
||||
echo '<form id="tree_search" method="post" action="index.php?extension_in_menu=estado&sec=estado&sec2=operation/tree&refr=0&sort_by='.$activeTab.'&pure='.$pure.'">';
|
||||
} else {
|
||||
echo '<form id="tree_search" method="post" action="index.php?sec=monitoring&sec2=operation/tree&refr=0&tab='.$activeTab.'&pure='.$pure.'">';
|
||||
}
|
||||
echo "<b>" . __('Agent status') . "</b>";
|
||||
|
||||
$search_free = get_parameter('search_free', '');
|
||||
|
|
Loading…
Reference in New Issue