diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 6e5e937da3..3b2d928179 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -79,14 +79,15 @@ if ($get_module_detail) { if (defined ('METACONSOLE')) { $server = metaconsole_get_connection ($server_name); - $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], - $server['dbpass']); - $select_db = mysql_select_db ($server['dbname'], $conexion); + + if (metaconsole_connect($server) != NOERR) + return; + $conexion = false; } else { $conexion = false; } - + html_debug_print($conexion, true); $selection_mode = get_parameter('selection_mode', 'fromnow'); $date_from = (string) get_parameter ('date_from', date ('Y-m-j')); $time_from = (string) get_parameter ('time_from', date ('h:iA')); @@ -266,6 +267,9 @@ if ($get_module_detail) { html_print_table($table); } + if (defined ('METACONSOLE')) + metaconsole_restore_db(); + return; } diff --git a/pandora_console/include/ajax/tree.ajax.php b/pandora_console/include/ajax/tree.ajax.php index 13639f97fa..46d1d1ef04 100644 --- a/pandora_console/include/ajax/tree.ajax.php +++ b/pandora_console/include/ajax/tree.ajax.php @@ -27,13 +27,14 @@ if (is_ajax ()) { $getChildren = (bool) get_parameter('getChildren', 0); $getGroupStatus = (bool) get_parameter('getGroupStatus', 0); - $get_detail = (bool) get_parameter('getDetail'); + $getDetail = (bool) get_parameter('getDetail'); if ($getChildren) { $type = get_parameter('type', 'group'); $rootType = get_parameter('rootType', ''); $id = get_parameter('id', -1); $rootID = get_parameter('rootID', -1); + $serverID = get_parameter('serverID', false); $childrenMethod = get_parameter('childrenMethod', 'on_demand'); $default_filters = array( @@ -45,10 +46,10 @@ if (is_ajax ()) { $filter = get_parameter('filter', $default_filters); if (class_exists('TreeEnterprise')) { - $tree = new TreeEnterprise($type, $rootType, $id, $rootID, $childrenMethod); + $tree = new TreeEnterprise($type, $rootType, $id, $rootID, $serverID, $childrenMethod); } else { - $tree = new Tree($type, $rootType, $id, $rootID, $childrenMethod); + $tree = new Tree($type, $rootType, $id, $rootID, $serverID, $childrenMethod); } $tree->setFilter($filter); @@ -56,61 +57,38 @@ if (is_ajax ()) { return; } - if ($getGroupStatus) { - $id = (int)get_parameter('id', 0); - $type = get_parameter('type', 'group'); - $id = 0; - - $status = array(); - - switch ($type) { - case 'group': - $data = reporting_get_group_stats($id); - - $status['unknown'] = $data['agents_unknown']; - $status['critical'] = $data['agent_critical']; - $status['warning'] = $data['agent_warning']; - $status['not_init'] = $data['agent_not_init']; - $status['ok'] = $data['agent_ok']; - $status['total'] = $data['total_agents']; - $status['status'] = $data['status']; - $status['alert_fired'] = $data['alert_fired']; - - echo json_encode($status); - break; - } - return; - } - - if ($get_detail) { + if ($getDetail) { require_once($config['homedir']."/include/functions_treeview.php"); - // Clean the output - ob_clean(); - $id = (int) get_parameter('id'); $type = (string) get_parameter('type'); $server = array(); if (defined ('METACONSOLE')) { - $server_name = (string) get_parameter('server'); - $server = metaconsole_get_connection($server_name); - metaconsole_connect($server); + $server_id = (int) get_parameter('serverID'); + $server = metaconsole_get_servers($server_id); + + if (metaconsole_connect($server) != NOERR) + return; } - switch ($type) { - case 'agent': - treeview_printTable($id, $server); - break; - case 'module': - treeview_printModuleTable($id, $server); - break; - case 'alert': - treeview_printAlertsTable($id, $server); - break; - default: - // Nothing - break; + ob_clean(); + + if (!empty($id) && !empty($type)) { + switch ($type) { + case 'agent': + treeview_printTable($id, $server); + break; + case 'module': + treeview_printModuleTable($id, $server); + break; + case 'alert': + treeview_printAlertsTable($id, $server); + break; + default: + // Nothing + break; + } } if (!empty($server) && defined ('METACONSOLE')) { diff --git a/pandora_console/include/class/Tree.class.php b/pandora_console/include/class/Tree.class.php index d937a7d10e..982a5dd976 100644 --- a/pandora_console/include/class/Tree.class.php +++ b/pandora_console/include/class/Tree.class.php @@ -18,6 +18,7 @@ class Tree { protected $rootType = null; protected $id = -1; protected $rootID = -1; + protected $serverID = false; protected $tree = array(); protected $filter = array(); protected $childrenMethod = "on_demand"; @@ -27,12 +28,13 @@ class Tree { protected $strictACL = false; protected $acltags = false; - public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $childrenMethod = "on_demand") { + public function __construct($type, $rootType = '', $id = -1, $rootID = -1, $serverID = false, $childrenMethod = "on_demand") { $this->type = $type; $this->rootType = !empty($rootType) ? $rootType : $type; $this->id = $id; $this->rootID = !empty($rootID) ? $rootID : $id; + $this->serverID = $serverID; $this->childrenMethod = $childrenMethod; $userGroups = users_get_groups(); @@ -45,6 +47,9 @@ class Tree { global $config; include_once($config['homedir']."/include/functions_servers.php"); + if (defined("METACONSOLE")) + enterprise_include_once("meta/include/functions_ui_meta.php"); + $this->strictACL = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']); if ($this->strictACL) { @@ -150,7 +155,7 @@ class Tree { // Not init $agent_not_init_filter = $this->getAgentStatusFilter(AGENT_STATUS_NOT_INIT); $agents_not_init_count = "($agent_table - $agent_not_init_filter) AS total_not_init_count"; + $agent_not_init_filter) AS total_not_init_count"; $columns = "$agents_not_init_count, $agents_fired_count, $agents_total_count"; break; case AGENT_STATUS_CRITICAL: @@ -213,6 +218,9 @@ class Tree { // Get the root id $rootID = $this->rootID; + // Get the server id + $serverID = $this->serverID; + // Agent name filter $agent_search_filter = ""; if (!empty($this->filter['searchAgent'])) { @@ -377,9 +385,10 @@ class Tree { ORDER BY $order_fields"; } else { - $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count, - ta.normal_count, ta.warning_count, ta.critical_count, - ta.unknown_count, ta.notinit_count, ta.total_count'; + $columns = 'ta.id_agente AS id, ta.nombre AS name, + ta.fired_count, ta.normal_count, ta.warning_count, + ta.critical_count, ta.unknown_count, ta.notinit_count, + ta.total_count, ta.quiet'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $sql = "SELECT $columns @@ -508,9 +517,10 @@ class Tree { } } else { - $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count, - ta.normal_count, ta.warning_count, ta.critical_count, - ta.unknown_count, ta.notinit_count, ta.total_count'; + $columns = 'ta.id_agente AS id, ta.nombre AS name, + ta.fired_count, ta.normal_count, ta.warning_count, + ta.critical_count, ta.unknown_count, ta.notinit_count, + ta.total_count, ta.quiet'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $sql = "SELECT $columns @@ -603,9 +613,10 @@ class Tree { } } else { - $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count, - ta.normal_count, ta.warning_count, ta.critical_count, - ta.unknown_count, ta.notinit_count, ta.total_count'; + $columns = 'ta.id_agente AS id, ta.nombre AS name, + ta.fired_count, ta.normal_count, ta.warning_count, + ta.critical_count, ta.unknown_count, ta.notinit_count, + ta.total_count, ta.quiet'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $sql = "SELECT $columns @@ -701,9 +712,10 @@ class Tree { } } else { - $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count, - ta.normal_count, ta.warning_count, ta.critical_count, - ta.unknown_count, ta.notinit_count, ta.total_count'; + $columns = 'ta.id_agente AS id, ta.nombre AS name, + ta.fired_count, ta.normal_count, ta.warning_count, + ta.critical_count, ta.unknown_count, ta.notinit_count, + ta.total_count, ta.quiet'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $sql = "SELECT $columns @@ -802,9 +814,10 @@ class Tree { } } else { - $columns = 'ta.id_agente AS id, ta.nombre AS name, ta.fired_count, - ta.normal_count, ta.warning_count, ta.critical_count, - ta.unknown_count, ta.notinit_count, ta.total_count'; + $columns = 'ta.id_agente AS id, ta.nombre AS name, + ta.fired_count, ta.normal_count, ta.warning_count, + ta.critical_count, ta.unknown_count, ta.notinit_count, + ta.total_count, ta.quiet'; $order_fields = 'ta.nombre ASC, ta.id_agente ASC'; $symbols = ' !"#$%&\'()*+,./:;<=>?@[\\]^{|}~'; @@ -880,29 +893,26 @@ class Tree { } break; default: - $sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID, - $agent_search_filter, $agent_status_filter, - $agents_join, $module_search_filter, - $module_status_filter, $modules_join, + $sql = $this->getSqlExtended($item_for_count, $type, $rootType, $parent, $rootID, + $agent_search_filter, $agent_status_filter, $agents_join, + $module_search_filter, $module_status_filter, $modules_join, $module_status_join); } - html_debug_print($sql, true); return $sql; } // Override this method - protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID, - $agent_search_filter, $agent_status_filter, - $agents_join, $module_search_filter, - $module_status_filter, $modules_join, + protected function getSqlExtended ($item_for_count, $type, $rootType, $parent, $rootID, + $agent_search_filter, $agent_status_filter, $agents_join, + $module_search_filter, $module_status_filter, $modules_join, $module_status_join) { return false; } protected function getItems ($item_for_count = false) { $sql = $this->getSql($item_for_count); - + if (empty($sql)) return array(); @@ -928,7 +938,7 @@ class Tree { return strcmp($a["name"], $b["name"]); } - protected function getGroupsChildren($groups, $parent_id, $server_id = false) { + protected function getGroupsChildren($groups, $parent_id, $server = false) { $children = array(); foreach ($groups as $key => $group) { unset($groups[$key]); @@ -936,7 +946,7 @@ class Tree { if ((isset($group['parent']) && $group['parent'] == $parent_id) || (isset($group['_parent_id_']) && $group['_parent_id_'] == $parent_id)) { - $children_aux = $this->getProcessedItem($group, $server_id, $groups); + $children_aux = $this->getProcessedItem($group, $server, $groups); if (!empty($children_aux)) $children[] = $children_aux; } @@ -945,7 +955,7 @@ class Tree { return $children; } - protected function getProcessedItem ($item, $server_id = false, $items = array()) { + protected function getProcessedItem ($item, $server = false, $items = array()) { $processed_item = array(); $processed_item['id'] = $item['id']; $processed_item['name'] = $item['name']; @@ -972,8 +982,8 @@ class Tree { $processed_item['icon'] = "without_group.png"; } - if (defined ('METACONSOLE') && $server_id) { - $processed_item['server_id'] = $server_id; + if (defined("METACONSOLE") && !empty($server)) { + $processed_item['serverID'] = $server['id']; } $counters = array(); @@ -994,7 +1004,7 @@ class Tree { if ($processed_item['type'] == 'group' && !empty($items)) { - $children = $this->getGroupsChildren($items, $item['id'], $server_id); + $children = $this->getGroupsChildren($items, $item['id'], $server); if (!empty($children)) { $processed_item['children'] = $children; @@ -1030,9 +1040,11 @@ class Tree { // The 'id' parameter will be stored as 'server_id' => 'id' $resultItem['id'] = array(); - $resultItem['id'][$item['server_id']] = $item['id']; + $resultItem['id'][$item['serverID']] = $item['id']; $resultItem['rootID'] = array(); - $resultItem['rootID'][$item['server_id']] = $item['rootID']; + $resultItem['rootID'][$item['serverID']] = $item['rootID']; + $resultItem['serverID'] = array(); + $resultItem['serverID'][$item['serverID']] = $item['rootID']; // Initialize counters if any of it don't exist if (!isset($resultItem['counters'])) @@ -1067,8 +1079,9 @@ class Tree { // Match with the name and type if ($item['name'] == $item2['name'] && $item['type'] == $item2['type']) { // Add the matched ids - $resultItem['id'][$item2['server_id']] = $item2['id']; - $resultItem['rootID'][$item2['server_id']] = $item2['rootID']; + $resultItem['id'][$item2['serverID']] = $item2['id']; + $resultItem['rootID'][$item2['serverID']] = $item2['rootID']; + $resultItem['serverID'][$item2['serverID']] = $item2['rootID']; // Add the matched counters if (isset($item2['counters']) && !empty($item2['counters'])) { @@ -1109,7 +1122,7 @@ class Tree { return $mergedItems; } - protected function processModule (&$module) { + protected function processModule (&$module, $server = false) { global $config; $module['type'] = 'module'; @@ -1119,7 +1132,11 @@ class Tree { $module['server_type'] = (int) $module['id_modulo']; $module['status'] = $module['estado']; $module['value'] = $module['datos']; - // $module['icon'] = modules_get_type_icon($module['id_tipo_modulo']); + + if (defined("METACONSOLE") && !empty($server)) { + $module['serverID'] = $server['id']; + $module['serverName'] = $server['server_name']; + } if (!isset($module['value'])) $module['value'] = modules_get_last_value($module['id']); @@ -1179,28 +1196,51 @@ class Tree { // Link to the Module graph $graphType = return_graphtype($module['id']); $winHandle = dechex(crc32($module['id'] . $module['name'])); - - $moduleGraphURL = $config['homeurl'] . - "/operation/agentes/stat_win.php?" . - "type=$graphType&" . - "period=86400&" . - "id=" . $module['id'] . "&" . - "label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" . - "refresh=600"; - $module['moduleGraph'] = array( - 'url' => $moduleGraphURL, - 'handle' => $winHandle - ); - } + if (!defined('METACONSOLE')) { + $moduleGraphURL = $config['homeurl'] . + "/operation/agentes/stat_win.php?" . + "type=$graphType&" . + "period=86400&" . + "id=" . $module['id'] . "&" . + "label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" . + "refresh=600"; + } + else if (!empty($server)) { + $moduleGraphURL = ui_meta_get_url_console_child( + $server, null, null, null, null, + "operation/agentes/stat_win.php?" . + "type=$graph_type&" . + "period=86400&" . + "id=" . $module["id"] . "&" . + "label=" . rawurlencode(urlencode(base64_encode($module['name']))) . "&" . + "refresh=600"); + } - protected function processModules (&$modules) { - foreach ($modules as $iterator => $module) { - $this->processModule($modules[$iterator]); + if (!empty($moduleGraphURL)) { + $module['moduleGraph'] = array( + 'url' => $moduleGraphURL, + 'handle' => $winHandle + ); + } + + // Alerts fired image + $has_alerts = (bool) db_get_value('COUNT(DISTINCT(id_agent_module))', 'talert_template_modules', 'id_agent_module', $module['id']); + + if ($has_alerts) { + $module['alertsImageHTML'] = html_print_image("images/bell.png", true, array("title" => __('Module alerts'))); } } - - protected function processAgent (&$agent, $server_id = false) { + + protected function processModules (&$modules, $server = false) { + foreach ($modules as $iterator => $module) { + $this->processModule($modules[$iterator], $server); + } + } + + protected function processAgent (&$agent, $server = false) { + global $config; + $agent['type'] = 'agent'; $agent['id'] = (int) $agent['id']; $agent['name'] = $agent['name']; @@ -1208,11 +1248,8 @@ class Tree { $agent['rootID'] = $this->rootID; $agent['rootType'] = $this->rootType; - $id = $agent['id']; - if ($server_id) { - $agent['id'] = array(); - $agent['id'][$server_id] = $id; - } + if (defined("METACONSOLE") && !empty($server)) + $agent['serverID'] = $server['id']; // Counters if (empty($agent['counters'])) { @@ -1221,37 +1258,37 @@ class Tree { if (isset($agent['unknown_count'])) $agent['counters']['unknown'] = $agent['unknown_count']; else - $agent['counters']['unknown'] = agents_monitor_unknown($id); + $agent['counters']['unknown'] = agents_monitor_unknown($agent['id']); if (isset($agent['critical_count'])) $agent['counters']['critical'] = $agent['critical_count']; else - $agent['counters']['critical'] = agents_monitor_critical($id); + $agent['counters']['critical'] = agents_monitor_critical($agent['id']); if (isset($agent['warning_count'])) $agent['counters']['warning'] = $agent['warning_count']; else - $agent['counters']['warning'] = agents_monitor_warning($id); + $agent['counters']['warning'] = agents_monitor_warning($agent['id']); if (isset($agent['notinit_count'])) $agent['counters']['not_init'] = $agent['notinit_count']; else - $agent['counters']['not_init'] = agents_monitor_notinit($id); + $agent['counters']['not_init'] = agents_monitor_notinit($agent['id']); if (isset($agent['normal_count'])) $agent['counters']['ok'] = $agent['normal_count']; else - $agent['counters']['ok'] = agents_monitor_ok($id); + $agent['counters']['ok'] = agents_monitor_ok($agent['id']); if (isset($agent['total_count'])) $agent['counters']['total'] = $agent['total_count']; else - $agent['counters']['total'] = agents_monitor_total($id); + $agent['counters']['total'] = agents_monitor_total($agent['id']); if (isset($agent['fired_count'])) $agent['counters']['alerts'] = $agent['fired_count']; else - $agent['counters']['alerts'] = agents_get_alerts_fired($id); + $agent['counters']['alerts'] = agents_get_alerts_fired($agent['id']); } // Status image @@ -1265,8 +1302,12 @@ class Tree { // Alerts fired image $agent["alertImageHTML"] = agents_tree_view_alert_img_ball($agent['counters']['alerts']); + // Quiet image + if (isset($agent['quiet']) && $agent['quiet']) + $agent['quietImageHTML'] = html_print_image("/images/dot_green.disabled.png", true, array("title" => __('Quiet'))); + // Status - $agent['statusRaw'] = agents_get_status($id); + $agent['statusRaw'] = agents_get_status($agent['id']); switch ($agent['statusRaw']) { case AGENT_STATUS_NORMAL: $agent['status'] = "ok"; @@ -1300,7 +1341,7 @@ class Tree { $agent['searchChildren'] = 0; // if ($searchChildren) - // $agent['children'] = $this->getModules($id, $modulesFilter); + // $agent['children'] = $this->getModules($agent['id'], $modulesFilter); break; } } @@ -1317,10 +1358,10 @@ class Tree { } } - protected function processAgents (&$agents, $server_id = false) { + protected function processAgents (&$agents, $server = false) { if (!empty($agents)) { foreach ($agents as $iterator => $agent) { - $this->processAgent($agents[$iterator], $server_id); + $this->processAgent($agents[$iterator], $server); } } } @@ -1383,23 +1424,21 @@ class Tree { $processed_items = $items; } else { - $ids = $this->id; - $items = array(); - foreach ($ids as $serverID => $id) { - $server = metaconsole_get_servers($serverID); - if (metaconsole_connect($server) != NOERR) - continue; - db_clean_cache(); - $this->id = $id; - $newItems = $this->getItems(); - $this->processModules($newItems); - $items = array_merge($items, $newItems); + if ($this->serverID !== false) { - metaconsole_restore_db(); + $server = metaconsole_get_servers($this->serverID); + if (metaconsole_connect($server) == NOERR) { + db_clean_cache(); + + $newItems = $this->getItems(); + $this->processModules($newItems, $server); + $items = array_merge($items, $newItems); + + metaconsole_restore_db(); + } } - $this->id = $ids; if (!empty($items)) usort($items, array("Tree", "cmpSortNames")); @@ -1519,7 +1558,7 @@ class Tree { if (isset($item['_monitors_alerts_fired_'])) $item['total_fired_count'] = $item['_monitors_alerts_fired_']; - $processed_items[] = $this->getProcessedItem($item, $server['id'], $items); + $processed_items[] = $this->getProcessedItem($item, $server, $items); } } $unmerged_items += $processed_items; @@ -1549,7 +1588,7 @@ class Tree { $this->rootID = $rootID; $newItems = $this->getItems(); - $this->processAgents($newItems, $serverID); + $this->processAgents($newItems, $server); $items = array_merge($items, $newItems); metaconsole_restore_db(); @@ -1606,7 +1645,7 @@ class Tree { if (empty($item['parent'])) { unset($items[$key]); - $processed_items[] = $this->getProcessedItem($item, $server['id'], $items); + $processed_items[] = $this->getProcessedItem($item, $server, $items); } } @@ -1637,7 +1676,7 @@ class Tree { $this->rootID = $rootID; $newItems = $this->getItems(); - $this->processAgents($newItems, $serverID); + $this->processAgents($newItems, $server); $items = array_merge($items, $newItems); metaconsole_restore_db(); @@ -1696,7 +1735,7 @@ class Tree { } } - $processed_item = $this->getProcessedItem($item, $server['id']); + $processed_item = $this->getProcessedItem($item, $server); $processed_items[] = $processed_item; } $item_list = array_merge($item_list, $processed_items); @@ -1726,7 +1765,7 @@ class Tree { $this->rootID = $rootID; $newItems = $this->getItems(); - $this->processAgents($newItems, $serverID); + $this->processAgents($newItems, $server); $items = array_merge($items, $newItems); metaconsole_restore_db(); @@ -1814,7 +1853,7 @@ class Tree { '_articapandora_'.ord('!').'_pandoraartica_'), io_safe_output($item['name'])); - $processed_item = $this->getProcessedItem($item, $server['id']); + $processed_item = $this->getProcessedItem($item, $server); $processed_item['id'] = $name; $processed_item['rootID'] = $name; @@ -1847,7 +1886,7 @@ class Tree { $this->rootID = $rootID; $newItems = $this->getItems(); - $this->processAgents($newItems, $serverID); + $this->processAgents($newItems, $server); $items = array_merge($items, $newItems); metaconsole_restore_db(); @@ -1906,7 +1945,7 @@ class Tree { } } - $processed_item = $this->getProcessedItem($item, $server['id']); + $processed_item = $this->getProcessedItem($item, $server); $processed_items[] = $processed_item; } $item_list = array_merge($item_list, $processed_items); @@ -1936,7 +1975,7 @@ class Tree { $this->rootID = $rootID; $newItems = $this->getItems(); - $this->processAgents($newItems, $serverID); + $this->processAgents($newItems, $server); $items = array_merge($items, $newItems); metaconsole_restore_db(); @@ -1996,7 +2035,7 @@ class Tree { } } - $processed_item = $this->getProcessedItem($item, $server['id']); + $processed_item = $this->getProcessedItem($item, $server); $processed_item['icon'] = $item['os_icon']; $processed_items[] = $processed_item; } @@ -2027,7 +2066,7 @@ class Tree { $this->rootID = $rootID; $newItems = $this->getItems(); - $this->processAgents($newItems, $serverID); + $this->processAgents($newItems, $server); $items = array_merge($items, $newItems); metaconsole_restore_db(); diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index bb41341d0d..4b0f2198f3 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -55,55 +55,75 @@ function treeview_printModuleTable($id_module, $server_data = false) { return; } - echo '
'; - echo ''; + $table = new StdClass(); + $table->width = "100%"; + $table->style = array(); + $table->style['title'] = 'font-weight: bold;'; + $table->head = array(); + $table->head[] = __('Module'); + $table->head_colspan[] = 2; + $table->data = array(); //Module name - echo ''; - if ($module["disabled"]) $cellName = "" . ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;") . ui_print_help_tip(__('Disabled'), true) . ""; else $cellName = ui_print_truncate_text ($module["nombre"], GENERIC_SIZE_TEXT, true, true, true, '[…]',"text-transform: uppercase;"); - echo ''; + $row = array(); + $row['title'] = __('Name'); + $row['data'] = "".$cellName.""; + $table->data['name'] = $row; // Interval - echo ''; - echo ''; + $row = array(); + $row['title'] = __('Interval'); + $row['data'] = human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true); + $table->data['interval'] = $row; // Warning Min/Max - echo ''; if (modules_is_string_type($module['id_tipo_modulo'])) { - echo ''; + $warning_status_str = __('Str.') . ': ' . $module['str_warning']; } else { - echo ''; + $warning_status_str = __('Min.') . ': ' . $module['min_warning'] . '
' . __('Max.') . ': ' . $module['max_warning']; } + + $row = array(); + $row['title'] = __('Warning status'); + $row['data'] = $warning_status_str; + $table->data['watning_status'] = $row; // Critical Min/Max - echo '
'; if (modules_is_string_type($module['id_tipo_modulo'])) { - echo ''; + $critical_status_str = __('Str.') . ': ' . $module['str_warning']; } else { - echo ''; + $critical_status_str = __('Min.') . ': ' . $module['min_critical'] . '
' . __('Max.') . ': ' . $module['max_critical']; } + $row = array(); + $row['title'] = __('Critical status'); + $row['data'] = $critical_status_str; + $table->data['critical_status'] = $row; // Module group - echo '
'; - echo ''; + $module_group = __("$module_group"); + + $row = array(); + $row['title'] = __('Module group'); + $row['data'] = $module_group; + $table->data['module_group'] = $row; // Description - echo ''; - echo ''; + $row = array(); + $row['title'] = __('Description'); + $row['data'] = ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]'); + $table->data['description'] = $row; // Tags $tags = tags_get_module_tags($module['id_agente_modulo']); @@ -135,8 +155,10 @@ function treeview_printModuleTable($id_module, $server_data = false) { $tags = implode(', ' , $tags); } - echo ''; - echo ''; + $row = array(); + $row['title'] = __('Tags'); + $row['data'] = $tags; + $table->data['tags'] = $row; // Data $last_data = db_get_row_filter ('tagente_estado', array('id_agente_modulo' => $module['id_agente_modulo'], 'order' => array('field' => 'id_agente_estado', 'order' => 'DESC'))); @@ -145,28 +167,28 @@ function treeview_printModuleTable($id_module, $server_data = false) { else $data = "" . substr(io_safe_output($last_data['datos']),0,12) . ""; - echo ''; - echo ''; + $row = array(); + $row['title'] = __('Last data'); + $row['data'] = $last_data_str; + $table->data['last_data'] = $row; //End of table - echo '
'.__('Module name').''.$cellName.'
' . __('Interval') . '' . human_time_description_raw (modules_get_interval($module['id_agente_modulo']), true) . '
' . __('Warning status') . '' . __('Str.') . ': ' . $module['str_warning'] . '
' . __('Min.') . ': ' . $module['min_warning'] . '
' . __('Max.') . ': ' . $module['max_warning'] . '
' . __('Critical status') . '' . __('Str.') . ': ' . $module['str_warning'] . '
' . __('Min.') . ': ' . $module['min_critical'] . '
' . __('Max.') . ': ' . $module['max_critical'] . '
'.__('Module group').''; $module_group = modules_get_modulegroup_name($module['id_module_group']); - + if ($module_group === false) - echo __('Not assigned'); + $module_group = __('Not assigned'); else - echo __("$module_group"); - echo '
'.__('Description').''. ui_print_truncate_text ($module['descripcion'], 'description', true, true, true, '[…]') .'
'.__('Tags').'' . $tags . '
'.__('Last data').''; - if (!empty($last_data['utimestamp'])) { - echo $data; + $last_data_str = $data; if ($module['unit'] != '') { - echo " "; - echo '('.$module['unit'].')'; + $last_data_str .= " "; + $last_data_str .= '('.$module['unit'].')'; } - echo " "; - html_print_image('images/clock2.png', false, array('title' => $last_data["timestamp"], 'width' => '18px')); + $last_data_str .= " "; + $last_data_str .= html_print_image('images/clock2.png', true, array('title' => $last_data["timestamp"], 'width' => '18px')); } else { - echo '' . __('No data') . ''; + $last_data_str = '' . __('No data') . ''; } - echo '
'; + html_print_table($table); $id_group = agents_get_agent_group($module['id_agente']); $group_name = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group); @@ -174,10 +196,10 @@ function treeview_printModuleTable($id_module, $server_data = false) { if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'AW')) { // Actions table - echo '
'; - echo '
'; + echo '
'; + echo ''; html_print_submit_button (__('Go to module edition'), 'upd_button', false, 'class="sub config"'); - echo ''; + echo ''; echo '
'; } @@ -218,42 +240,53 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { return; } - echo '
'; - echo ''; - echo ''; - - echo ''; - echo ''; + $table = new StdClass(); + $table->width = "100%"; + $table->style = array(); + $table->style['titles'] = 'font-weight: bold; background: #B3B3B3;'; + $table->head = array(); + $table->head[] = __('Alerts') . ": " . $module_name; + $table->head_colspan[] = 2; + $table->data = array(); + + $row = array(); + $row['template'] = __('Template'); + $row['actions'] = __('Actions'); + $table->data['titles'] = $row; foreach($module_alerts as $module_alert) { //Template name - echo ''; $template_name = db_get_value('name','talert_templates','id',$module_alert['id_alert_template']); - echo ''; + $actions = alerts_get_alert_agent_module_actions($module_alert['id']); - echo ''; + + $row = array(); + $row['template'] = $template_name; + $row['actions'] = $actions_list; + $table->data['last_data'] = $row; } - echo '
' . $module_name . '
'.__('Template').''.__('Actions').'
'.$template_name.''; + if (empty($actions)) { - echo ''.__('N/A').''; + $actions_list = ''.__('N/A').''; } else { - echo '
    '; - foreach($actions as $act) { - echo '
  • '; - echo $act['name']; - echo '
  • '; + $actions_list = '
      '; + foreach($actions_list as $act) { + $actions_list .= '
    • '; + $actions_list .= $act['name']; + $actions_list .= '
    • '; } - echo '
    '; + $actions_list .= '
'; } - echo '
'; + + html_print_table($table); if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) { // Actions table - echo '
'; - echo '
'; + echo '
'; } } @@ -386,9 +419,9 @@ function treeview_printTable($id_agente, $server_data = array()) { if (can_user_access_node () && check_acl ($config["id_user"], $agent["id_grupo"], "AW")) { $go_to_agent = ''; $agent_table .= $go_to_agent; diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 49321db16d..e70bd121e2 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -77,10 +77,10 @@ TreeController = { modules: "Total modules", none: "Total" }, - fired: { - agents: "Alert fired", - modules: "Alert fired", - none: "Alert fired" + alerts: { + agents: "Alerts fired", + modules: "Alerts fired", + none: "Alerts fired" }, critical: { agents: "Critical agents", @@ -173,16 +173,16 @@ TreeController = { $counters.append($totalCounter); - if (typeof counters.fired != 'undefined' - && counters.fired > 0) { + if (typeof counters.alerts != 'undefined' + && counters.alerts > 0) { var $firedCounter = $("
"); $firedCounter .addClass('tree-node-counter') - .addClass('fired') + .addClass('alerts') .addClass('orange') - .html(counters.fired); + .html(counters.alerts); - _processNodeCounterTitle($firedCounter, type, "fired"); + _processNodeCounterTitle($firedCounter, type, "alerts"); $counters .append(" : ") @@ -311,6 +311,14 @@ TreeController = { $content.append(element.name); break; case 'agent': + // Is quiet + if (typeof element.quietImageHTML != 'undefined' + && element.quietImageHTML.length > 0) { + var $quietImage = $(element.quietImageHTML); + $quietImage.addClass("agent-quiet"); + + $content.append($quietImage); + } // Status image if (typeof element.statusImageHTML != 'undefined' && element.statusImageHTML.length > 0) { @@ -361,14 +369,16 @@ TreeController = { winopeng(element.moduleGraph.url, element.moduleGraph.handle); } catch (error) { - console.log(error); + // console.log(error); } }); + + $content.append($graphImage); } // Data pop-up - if (typeof element.id != 'undefined' - && !isNaN(element.id)) { + if (typeof element.id != 'undefined' && !isNaN(element.id)) { + var $dataImage = $(' '); $dataImage @@ -377,19 +387,46 @@ TreeController = { e.preventDefault(); try { + var serverName = element.serverName.length > 0 ? element.serverName : ''; if ($("#module_details_window").length > 0) - show_module_detail_dialog(element.id, '', '', 0, 86400); + show_module_detail_dialog(element.id, '', serverName, 0, 86400); } catch (error) { - console.log(error); + // console.log(error); } }); + + $content.append($dataImage); } - $content - .append($graphImage) - .append($dataImage) - .append(element.name); + // Alerts + if (typeof element.alertsImageHTML != 'undefined' + && element.alertsImageHTML.length > 0) { + + var $alertsImage = $(element.alertsImageHTML); + + $alertsImage + .addClass("module-alerts") + .click(function (e) { + TreeNodeDetailController.getController().init({ + recipient: controller.detailRecipient, + type: 'alert', + id: element.id, + serverID: element.serverID, + baseURL: controller.baseURL, + ajaxURL: controller.ajaxURL, + ajaxPage: controller.ajaxPage + }); + + // Avoid the execution of the module detail event + e.stopPropagation(); + }) + .css('cursor', 'pointer'); + + $content.append($alertsImage); + } + + $content.append(element.name); break; case 'os': if (typeof element.icon != 'undefined' && element.icon.length > 0) { @@ -419,16 +456,20 @@ TreeController = { // If exist the detail container, show the data if (typeof controller.detailRecipient != 'undefined' && controller.detailRecipient.length > 0) { - $content.click(function (e) { - TreeNodeDetailController.getController().init({ - recipient: controller.detailRecipient, - type: element.type, - id: element.id, - baseURL: controller.baseURL, - ajaxURL: controller.ajaxURL, - ajaxPage: controller.ajaxPage - }); - }); + if (element.type == 'agent' || element.type == 'module') { + $content.click(function (e) { + TreeNodeDetailController.getController().init({ + recipient: controller.detailRecipient, + type: element.type, + id: element.id, + serverID: element.serverID, + baseURL: controller.baseURL, + ajaxURL: controller.ajaxURL, + ajaxPage: controller.ajaxPage + }); + }) + .css('cursor', 'pointer'); + } } $node @@ -494,6 +535,7 @@ TreeController = { id: element.id, type: element.type, rootID: element.rootID, + serverID: element.serverID, rootType: element.rootType, filter: controller.filter }, @@ -648,21 +690,23 @@ TreeNodeDetailController = { } }, removeControllers: function () { - if (TreeNodeDetailController.controllers.length > 0) { - TreeNodeDetailController.controllers.forEach(function(elements, type) { - if (elements.length > 0) { - elements.forEach(function(element, id) { - element.remove(); - }); - } + try { + $.each(TreeNodeDetailController.controllers, function(type, elements) { + $.each(elements, function(id, element) { + element.remove(); + }); }); } + catch (error) { + // console.log(error); + } }, getController: function () { var controller = { recipient: '', type: 'none', id: -1, + serverID: -1, emptyMessage: "Empty", errorMessage: "Error", baseURL: "", @@ -687,37 +731,33 @@ TreeNodeDetailController = { this.container = $("
"); this.container .addClass("tree-element-detail") + .addClass("tree-element-detail-closed") .append($label) .data('label', $label) .append($content) - .data('content', $content) - .hide(); + .data('content', $content); $label.addClass('tree-element-detail-loading'); $.ajax({ url: this.ajaxURL, type: 'POST', - dataType: 'json', + dataType: 'html', + async: true, data: { page: this.ajaxPage, getDetail: 1, type: this.type, - id: this.id + id: this.id, + serverID: this.serverID }, complete: function(xhr, textStatus) { $label.removeClass('tree-element-detail-loading'); }, success: function(data, textStatus, xhr) { - if (data.success) { - $label.addClass('tree-element-detail-loaded'); - $content.html(data.html); + $label.addClass('tree-element-detail-loaded'); + $content.html(data); - controller.open(); - } - else { - $label.addClass('tree-element-detail-error'); - $content.html(controller.errorMessage); - } + controller.open(); }, error: function(xhr, textStatus, errorThrown) { $label.addClass('tree-element-detail-error'); @@ -726,16 +766,15 @@ TreeNodeDetailController = { }); this.recipient.append(this.container); - this.open(); }, load: function () { this.reload(); }, toggle: function () { - if (typeof this.container != 'undefined' && this.container.length > 0) { + if (typeof this.container == 'undefined' || this.container.length <= 0) { return false; } - if (this.container.isClosed) { + if (this.container.hasClass("tree-element-detail-closed")) { this.open(); } else { @@ -743,21 +782,23 @@ TreeNodeDetailController = { } }, open: function () { - if (typeof this.container != 'undefined' && this.container.length > 0) { + if (typeof this.container == 'undefined' || this.container.length <= 0) { return false; } - if (this.container.isClosed) { - this.container.data('content').slideLeft(); - this.container.isClosed = false; + if (this.container.hasClass("tree-element-detail-closed")) { + this.container + .removeClass("tree-element-detail-closed") + .data('content').show(); } }, close: function () { - if (typeof this.container != 'undefined' && this.container.length > 0) { + if (typeof this.container == 'undefined' || this.container.length <= 0) { return false; } - if (!this.container.isClosed) { - this.container.data('content').slideRight(); - this.container.isClosed = true; + if (!this.container.hasClass("tree-element-detail-closed")) { + this.container + .addClass("tree-element-detail-closed") + .data('content').hide(); } }, init: function (data) { @@ -785,6 +826,9 @@ TreeNodeDetailController = { else { return false; } + if (typeof data.serverID != 'undefined' && (data.serverID.length > 0 || !isNaN(data.serverID))) { + this.serverID = data.serverID; + } if (typeof data.emptyMessage != 'undefined' && data.emptyMessage.length > 0) { this.emptyMessage = data.emptyMessage; } @@ -826,27 +870,29 @@ TreeNodeDetailController = { } }, closeOther: function () { - if (TreeNodeDetailController.controllers.length > 0) { - TreeNodeDetailController.controllers.forEach(function(elements, type) { - if (elements.length > 0) { - elements.forEach(function(element, id) { - if (this.type != type && this.id != id) - element.close(); - }, this); - } - }, this); + try { + $.each(TreeNodeDetailController.controllers, function(type, elements) { + $.each(elements, function(id, element) { + if (controller.type != type && controller.id != id) + element.close(); + }); + }); + } + catch (error) { + // console.log(error); } }, removeOther: function () { - if (TreeNodeDetailController.controllers.length > 0) { + try { TreeNodeDetailController.controllers.forEach(function(elements, type) { - if (elements.length > 0) { - elements.forEach(function(element, id) { - if (this.type != type && this.id != id) - element.remove(); - }, this); - } - }, this); + elements.forEach(function(element, id) { + if (controller.type != type && controller.id != id) + element.remove(); + }); + }); + } + catch (error) { + // console.log(error); } } } diff --git a/pandora_console/include/styles/tree.css b/pandora_console/include/styles/tree.css index 2db5b7ae26..e9eb0863bc 100644 --- a/pandora_console/include/styles/tree.css +++ b/pandora_console/include/styles/tree.css @@ -5,7 +5,7 @@ .tree-group { margin-left: 16px; - padding-top: 4px; + padding-top: 1px; } .tree-node { @@ -22,11 +22,16 @@ background: 0 0; } .node-content { - height: 21px; + height: 16px; +} + +.node-content>img { + position: relative; + top: -2px; } .node-content:hover { - background-color: #9AB8DF; + background-color: #FFF; -moz-border-radius: 3px; -webkit-border-radius: 3px; @@ -101,7 +106,9 @@ .tree-node>.node-content>img.module-server-type, .tree-node>.node-content>img.agent-status, .tree-node>.node-content>img.agent-alerts-fired, -.tree-node>.node-content>img.module-status { +.tree-node>.node-content>img.agent-quiet, +.tree-node>.node-content>img.module-status, +.tree-node>.node-content>img.module-alerts { padding-right: 3px; } @@ -122,4 +129,43 @@ font-weight: bold; font-size: 7pt; cursor: default; -} \ No newline at end of file +} + +div.tree-table { + display: table; + width: 98%; + margin-top: 10px; +} + +div.tree-table-row { + display: table-row; +} + +div.tree-table-cell { + display: table-cell; + vertical-align: top; +} + +div.tree-table-cell.tree-table-cell-tree { + /*width: 70%;*/ + max-width: 600px; + overflow-x: auto; + overflow-y: hidden; +} + +div.tree-table-cell.tree-table-cell-detail { + padding-left: 10px; + width: 350px; +} + +div.tree-element-detail-closed { + display: none; +} + +div#tree-controller-recipient { + text-align: left; +} + +div#tree-controller-detail-recipient { + /*text-align: right;*/ +} diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index cb781137e8..baa7d8c626 100755 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -14,900 +14,316 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - - -require_once("tree2.php"); -return; -//////////////////////////////////////////////////////////////////////// - - -define('ALL', -1); -define('NORMAL', 0); -define('WARNING', 2); -define('CRITICAL', 1); -define('UNKNOWN', 3); -define('NOT_INIT', 5); - - global $config; -require_once ($config['homedir'] . '/include/functions_treeview.php'); - -if (defined ('METACONSOLE')) { - // For each server defined: - $servers = db_get_all_rows_sql ("SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0"); - if ($servers === false) { - $servers = array(); - } -} - -if (is_ajax ()) { - require_once ($config['homedir'] . '/include/functions_reporting.php'); - require_once ($config['homedir'] . '/include/functions_users.php'); - require_once ($config['homedir'] . '/include/functions_servers.php'); - - global $config; - - $enterpriseEnable = false; - if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { - $enterpriseEnable = true; - require_once ('enterprise/include/functions_policies.php'); - require_once ('enterprise/meta/include/functions_ui_meta.php'); - } - - $type = get_parameter('type'); - $id = get_parameter('id'); - $id_father = get_parameter('id_father'); - $statusSel = get_parameter('status'); - $search_free = get_parameter('search_free', ''); - $printTable = get_parameter('printTable', 0); - $printAlertsTable = get_parameter('printAlertsTable', 0); - $printModuleTable = get_parameter('printModuleTable', 0); - $server_name = get_parameter('server_name', ''); - $server = array(); - if ($printTable) { - $id_agente = get_parameter('id_agente'); - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); - } - - treeview_printTable($id_agente, $server); - - if (defined ('METACONSOLE')) { - metaconsole_restore_db(); - } - } - if ($printAlertsTable) { - $id_module = get_parameter('id_module'); - - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); - } - - treeview_printAlertsTable($id_module, $server); - - if (defined ('METACONSOLE')) { - metaconsole_restore_db(); - } - } - if ($printModuleTable) { - $id_module = get_parameter('id_module'); - $id_agent = get_parameter('id_agent'); - - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - metaconsole_connect($server); - } - - treeview_printModuleTable($id_module, $server); - - - if (defined ('METACONSOLE')) { - metaconsole_restore_db(); - } - } - - /* - * It's a binary for branch (0 show - 1 hide) - * and there are 2 position - * 0 0 - show 2 branch - * 0 1 - hide the 2º branch - * 1 0 - hide the 1º branch - * 1 1 - hide 2 branch - */ - $lessBranchs = get_parameter('less_branchs'); - - switch ($type) { - case 'group': - case 'os': - case 'module_group': - case 'policies': - case 'module': - case 'tag': - - $countRows = 0; - if (! defined ('METACONSOLE')) { - $avariableGroups = users_get_groups(); - $avariableGroupsIds = array_keys($avariableGroups); - $sql = treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel, $search_free); - - if ($sql === false) { - $rows = array (); - } - else { - $rows = db_get_all_rows_sql($sql); - } - } - else { - $rows = array (); - foreach ($servers as $server) { - if (metaconsole_connect($server) != NOERR) { - continue; - } - $avariableGroups = users_get_groups(); - $avariableGroupsIds = array_keys($avariableGroups); - $sql = treeview_getFirstBranchSQL ($type, $id, - $avariableGroupsIds, $statusSel, $search_free); - if ($sql === false) { - $server_rows = array (); - } - else { - $server_rows = db_get_all_rows_sql($sql); - if ($server_rows === false) { - $server_rows = array (); - } - } - // Add the server name - foreach ($server_rows as $key => $row) { - $server_rows[$key]['server_name'] = $server['server_name']; - } - $rows = array_merge($rows, $server_rows); - } - metaconsole_restore_db(); - } - $countRows = count ($rows); - - //Empty Branch - if ($countRows === 0) { - echo "
    \n"; - echo "
  • "; - if ($lessBranchs == 1) - echo html_print_image ("operation/tree/no_branch.png", true, array ("style" => 'vertical-align: middle;')); - else - echo html_print_image ("operation/tree/branch.png", true, array ("style" => 'vertical-align: middle;')); - echo "" . __("Empty") . ""; - echo "
  • "; - echo "
"; - return; - } - - //Branch with items - $count = 0; - echo "\n"; - break; - - //also aknolegment as second subtree/branch - case 'agent_group': - case 'agent_module_group': - case 'agent_os': - case 'agent_policies': - case 'agent_module': - case 'agent_tag': - $fatherType = str_replace('agent_', '', $type); - - if (defined ('METACONSOLE')) { - $server = metaconsole_get_connection ($server_name); - if (metaconsole_connect($server) != NOERR) { - continue; - } - } - - $sql = treeview_getSecondBranchSQL ($fatherType, $id, $id_father); - $rows = db_get_all_rows_sql($sql); - if (empty($rows)) { - $rows = array(); - } - $countRows = count ($rows); - - if ($countRows === 0) { - echo "
    \n"; - echo "
  • "; - switch ($lessBranchs) { - case 0: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 1: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 2: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 3: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - } - echo "" . __("Empty") . ""; - echo "
  • "; - echo "
"; - return; - } - - $count = 0; - echo "
    \n"; - foreach ($rows as $row) { - $count++; - echo "
  • "; - - switch ($lessBranchs) { - case 0: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 1: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 2: - html_print_image ("operation/tree/branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - case 3: - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - html_print_image ("operation/tree/no_branch.png", false, array ("style" => 'vertical-align: middle;')); - break; - } - - if ($countRows != $count) - html_print_image ("operation/tree/leaf.png", false, array ("style" => 'vertical-align: middle;', "id" => "tree_image_os_" . $row["id_agente"], "pos_tree" => "1" )); - else - html_print_image ("operation/tree/last_leaf.png", false, array ("style" => 'vertical-align: middle;', "id" => "tree_image_os_" . $row["id_agente"], "pos_tree" => "2" )); - - // Assign image and status depend on the status data - switch ($row["estado"]) { - case AGENT_MODULE_STATUS_NO_DATA: - case AGENT_MODULE_STATUS_UNKNOWN: - $status = STATUS_MODULE_NO_DATA; - $title = __('UNKNOWN'); - break; - case AGENT_MODULE_STATUS_CRITICAL_BAD: - $status = STATUS_MODULE_CRITICAL; - $title = __('CRITICAL'); - break; - case AGENT_MODULE_STATUS_WARNING: - $status = STATUS_MODULE_WARNING; - $title = __('WARNING'); - break; - default: - $status = STATUS_MODULE_OK; - $title = __('NORMAL'); - break; - } - - if (is_numeric($row["datos"])) { - $title .= " : " . format_for_graph($row["datos"]); - } - else { - $title .= " : " . substr(io_safe_output($row["datos"]),0,42); - } - - echo str_replace('.png' ,'_ball.png', - str_replace('img', 'img style="vertical-align: middle;"', ui_print_status_image($status, $title,true)) - ); - echo " "; - echo str_replace('img', 'img style="vertical-align: middle;"', servers_show_type ($row['id_modulo'])); - echo " "; - $graph_type = return_graphtype ($row["id_tipo_modulo"]); - $win_handle=dechex(crc32($row["id_agente_modulo"] . $row["nombre"])); - - if (defined ('METACONSOLE')) { - $console_url = $server['server_url'] . '/'; - } - else { - $console_url = ''; - } - - - //Icon and link to the Module graph. - if (defined('METACONSOLE')) { - $url_module_graph = ui_meta_get_url_console_child( - $server, null, null, null, null, - "operation/agentes/stat_win.php?" . - "type=$graph_type&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"] . "&" . - "label=" . rawurlencode(urlencode(base64_encode($row["nombre"]))) . "&" . - "refresh=600"); - } - else { - $url_module_graph = $console_url . - "operation/agentes/stat_win.php?" . - "type=$graph_type&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"] . "&" . - "label=" . rawurlencode(urlencode(base64_encode($row["nombre"]))) . "&" . - "refresh=600"; - } - $link ="winopeng('" . $url_module_graph . "','day_".$win_handle."')"; - echo '' . html_print_image ("images/chart_curve.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ''; - - - echo " "; - - - //Icon and link to the Module data. - if (defined('METACONSOLE')) { - - $url_module_data = ui_meta_get_url_console_child( - $server, - "estado", "operation/agentes/ver_agente", - "id_agente=" . $row['id_agente'] . "&" . - "tab=data_view&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"]); - } - else { - $url_module_data = $console_url . - "index.php?" . - "sec=estado&" . - "sec2=operation/agentes/ver_agente&" . - "id_agente=" . $row['id_agente'] . "&" . - "tab=data_view&" . - "period=86400&" . - "id=" . $row["id_agente_modulo"]; - } - echo "". html_print_image ("images/binary.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; - - echo " "; - - $nmodule_alerts = db_get_value_sql(sprintf("SELECT count(*) FROM talert_template_modules WHERE id_agent_module = %s", $row["id_agente_modulo"])); - - if($nmodule_alerts > 0) { - echo ""; - echo html_print_image ("images/bell.png", true, array ("style" => 'vertical-align: middle;', "border" => "0", "title" => __('Module alerts') )); - echo ""; - - echo " "; - } - - echo ""; - echo ui_print_truncate_text(io_safe_output($row['nombre']), 40, true); - echo ""; - if ($row['quiet']) { - echo " "; - html_print_image("images/dot_green.disabled.png", false, array("border" => '0', "title" => __('Quiet'), "alt" => "")); - } - - /* - if (is_numeric($row["datos"])) - $data = format_numeric($row["datos"]); - else - $data = "".substr(io_safe_output($row["datos"]),0,12).""; - - echo ""; - if ($row['utimestamp'] != '') { - ui_print_help_tip ($row["timestamp"], '', 'images/clock2.png'); - echo " "; - } - echo $data; - if ($row['unit'] != '') { - echo " "; - echo '('.$row['unit'].')'; - } - * */ - echo "
  • "; - } - echo "
\n"; - if (defined ('METACONSOLE')) { - metaconsole_restore_db_force(); - } - break; - } - - return; -} -//End of AJAX code. - -include_once($config['homedir'] . "/include/functions_groups.php"); -include_once($config['homedir'] . "/include/functions_os.php"); -include_once($config['homedir'] . "/include/functions_modules.php"); -include_once($config['homedir'] . "/include/functions_servers.php"); -include_once($config['homedir'] . "/include/functions_reporting.php"); -include_once($config['homedir'] . "/include/functions_ui.php"); - -global $config; $pure = get_parameter('pure', 0); +$tab = get_parameter('tab', 'group'); +$search_agent = get_parameter('searchAgent', ''); +$status_agent = get_parameter('statusAgent', AGENT_STATUS_ALL); +$search_module = get_parameter('searchModule', ''); +$status_module = get_parameter('statusModule', -1); +// ---------------------Tabs ------------------------------------------- $enterpriseEnable = false; if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { $enterpriseEnable = true; } -///////// INI MENU AND TABS ///////////// -$img_style = array ("class" => "top", "width" => 16); -$activeTab = get_parameter('sort_by','group'); +$url = 'index.php?' . + 'sec=estado&' . + 'sec2=operation/tree&' . + 'refr=0&' . + 'pure='.$pure.'&' . + 'tab=%s'; -$os_tab = array('text' => "" - . html_print_image ("images/operating_system.png", true, array ("title" => __('OS'))) . "", 'active' => $activeTab == "os"); +$tabs = array(); -$group_tab = array('text' => "" - . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "", 'active' => $activeTab == "group"); +$tabs['tag'] = array( + 'text' => "" . + html_print_image("images/tag.png", true, + array("title" => __('Tags'))) . "", + 'active' => ($tab == "tag")); -$module_group_tab = array('text' => "" - . html_print_image ("images/module_group.png", true, array ("title" => __('Module groups'))) . "", 'active' => $activeTab == "module_group"); +$tabs['os'] = array( + 'text' => "" . + html_print_image("images/operating_system.png", true, + array("title" => __('OS'))) . "", + 'active' => ($tab == "os")); + +$tabs['group'] = array( + 'text' => "" . + html_print_image("images/group.png", true, + array("title" => __('Groups'))) . "", + 'active' => ($tab == "group")); + +$tabs['module_group'] = array( + 'text' => "" . + html_print_image("images/module_group.png", true, + array("title" => __('Module groups'))) . "", + 'active' => ($tab == "module_group")); + +$tabs['module'] = array( + 'text' => "" . + html_print_image("images/brick.png", true, + array("title" => __('Modules'))) . "", + 'active' => ($tab == "module")); if ($enterpriseEnable) { - $policies_tab = array('text' => "" - . html_print_image ("images/policies_mc.png", true, array ("title" => __('Policies'))) . "", 'active' => $activeTab == "policies"); -} -else { - $policies_tab = ''; + $tabs['policies'] = array( + 'text' => "" . + html_print_image("images/policies_mc.png", true, + array("title" => __('Policies'))) . "", + 'active' => ($tab == "policies")); } -$module_tab = array('text' => "" - . html_print_image("images/brick.png", - true, - array("title" => __('Modules'))) . "", - 'active' => $activeTab == "module"); - -$tags_tab = array('text' => "" - . html_print_image("images/tag.png", - true, - array("title" => __('Tags'))) . "", - 'active' => $activeTab == "tag"); - -switch ($activeTab) { - case 'group': - $order = __('groups'); - break; - case 'module_group': - $order = __('module groups'); - break; - case 'policies': - $order = __('policies'); - break; - case 'module': - $order = __('modules'); +$header_title = __('Tree view') . " - " . __('Sort the agents by %s'); +switch ($tab) { + case 'tag': + $header_title = sprintf($header_title, __('tags')); break; case 'os': - $order = __('OS'); + $header_title = sprintf($header_title, __('OS')); break; - case 'tag': - $order = __('tags'); + case 'group': + $header_title = sprintf($header_title, __('groups')); + break; + case 'module_group': + $header_title = sprintf($header_title, __('module groups')); + break; + case 'module': + $header_title = sprintf($header_title, __('modules')); + break; + case 'policies': + if ($enterpriseEnable) + $header_title = sprintf($header_title, __('policies')); break; } +if (defined('METACONSOLE')) + ui_meta_print_header($header_title, "", $tabs); +else + ui_print_page_header($header_title, "images/extensions.png", false, "", false, $tabs); +// ---------------------Tabs ------------------------------------------- + + if (! defined ('METACONSOLE')) { - $onheader = array('tag' => $tags_tab, - 'os' => $os_tab, - 'group' => $group_tab, - 'module_group' => $module_group_tab, - 'policies' => $policies_tab, - 'module' => $module_tab); - - ui_print_page_header( - __('Tree view') . " - " . __('Sort the agents by ') . $order, - "images/extensions.png", - false, "", false, $onheader); + } else { - - ui_meta_add_breadcrumb(array( - 'link' => 'index.php?sec=monitoring&sec2=operation/tree', - 'text' => __('Tree View'))); - ui_meta_print_page_header($nav_bar); - - $img_style = array ("class" => "top", "width" => 16); - $activeTab = get_parameter('tab','group'); - // Check if the loaded tab is allowed or not - $allowed_tabs = array('group'); + // $allowed_tabs = array('group'); - if ($config['enable_tags_tree']) { - $allowed_tabs[] = 'tag'; - } + // if ($config['enable_tags_tree']) { + // $allowed_tabs[] = 'tag'; + // } - if (!in_array($activeTab, $allowed_tabs)) { - db_pandora_audit("HACK Attempt", - "Trying to access to not allowed tab on tree view"); - include ("general/noaccess.php"); + // if (!in_array($activeTab, $allowed_tabs)) { + // db_pandora_audit("HACK Attempt", + // "Trying to access to not allowed tab on tree view"); + // include ("general/noaccess.php"); - exit; - } + // exit; + // } // End of tab check - - $group_tab = array('text' => "" - . html_print_image ("images/group.png", true, - array ("title" => __('Groups'))) . "", - 'active' => $activeTab == "group"); - - $subsections['group'] = $group_tab; - - if ($config['enable_tags_tree']) { - $tags_tab = array( - 'text' => "" . - html_print_image ("images/tag.png", true, - array ("title" => __('Tags'))) . "", - 'active' => $activeTab == "tag"); - - $subsections['tag'] = $tags_tab; - } - - switch ($activeTab) { - case 'group': - $subsection = __('Groups'); - $tab = 'group'; - break; - case 'tag': - $subsection = __('Tags'); - $tab = 'tag'; - break; - } - ui_meta_print_header(__("Tree view"), $subsection, $subsections); } +// --------------------- form filter ----------------------------------- +$table = new StdClass(); +// $table->class = "blank"; +$table->width = "100%"; +$table->data = array(); +$table->rowspan = array(); + +// Agent filter +$agent_status_arr = array(); +$agent_status_arr[AGENT_STATUS_ALL] = __('All'); //default +$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal'); +$agent_status_arr[AGENT_STATUS_WARNING] = __('Warning'); +$agent_status_arr[AGENT_STATUS_CRITICAL] = __('Critical'); +$agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); +$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init'); + +$row = array(); +$row[] = __('Agent status'); +$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true); +$row[] = __('Search agent'); +$row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true); + +// Button +$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true); +$table->rowspan[][count($row)-1] = 2; + +$table->data[] = $row; + +// Module filter +$module_status_arr = array(); +$module_status_arr[-1] = __('All'); //default +$module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); +$module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning'); +$module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); +$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); +$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); + +$row = array(); +$row[] = __('Module status'); +$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); +$row[] = __('Search module'); +$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true); + +$table->data[] = $row; + enterprise_hook('open_meta_frame'); -if (tags_has_user_acl_tags()) { - ui_print_tags_warning(); -} - -echo "
"; -if (! defined ('METACONSOLE')) { - echo '"; -echo "
"; -echo "
"; -echo "
"; -///////// END MENU AND TABS ///////////// - -echo "
"; -ui_require_javascript_file('pandora_modules'); - -treeview_printTree($activeTab); - - -enterprise_hook('close_meta_frame'); +echo ''; +// --------------------- form filter ----------------------------------- ui_include_time_picker(); ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); +ui_require_javascript_file("TreeController", "include/javascript/tree/"); + +html_print_image('images/spinner.gif', false, + array('class' => "loading_tree", + 'style' => 'display: none;')); + +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; +echo "
"; + +enterprise_hook('close_meta_frame'); + ?> - diff --git a/pandora_console/operation/tree2.php b/pandora_console/operation/tree2.php deleted file mode 100644 index 58056ce40c..0000000000 --- a/pandora_console/operation/tree2.php +++ /dev/null @@ -1,345 +0,0 @@ - "" . - html_print_image("images/operating_system.png", true, - array("title" => __('OS'))) . "", - 'active' => ($tab == "os")); - -$tabs['group'] = array( - 'text' => "" . - html_print_image("images/group.png", true, - array("title" => __('Groups'))) . "", - 'active' => ($tab == "group")); - -$tabs['module_group'] = array( - 'text' => "" . - html_print_image("images/module_group.png", true, - array("title" => __('Module groups'))) . "", - 'active' => ($tab == "module_group")); - -$tabs['module'] = array( - 'text' => "" . - html_print_image("images/brick.png", true, - array("title" => __('Modules'))) . "", - 'active' => ($tab == "module")); - -$tabs['tag'] = array( - 'text' => "" . - html_print_image("images/tag.png", true, - array("title" => __('Tags'))) . "", - 'active' => ($tab == "tag")); - -if ($enterpriseEnable) { - $tabs['policies'] = array( - 'text' => "" . - html_print_image("images/policies_mc.png", true, - array("title" => __('Policies'))) . "", - 'active' => ($tab == "policies")); -} - -$header_title = ""; -switch ($tab) { - case 'os': - $header_title = - __('Tree view - Sort the agents by OS'); - break; - case 'group': - $header_title = - __('Tree view - Sort the agents by groups'); - break; - case 'module_group': - $header_title = - __('Tree view - Sort the agents by module groups'); - break; - case 'module': - $header_title = - __('Tree view - Sort the agents by modules'); - break; - case 'tag': - $header_title = - __('Tree view - Sort the agents by tags'); - break; -} - -ui_print_page_header( - $header_title, "images/extensions.png", false, "", false, $tabs); -// ---------------------Tabs ------------------------------------------- - - -// --------------------- form filter ----------------------------------- -$table = null; -$table->width = "100%"; -$table->data = array(); -$table->rowspan = array(); - -// Agent filter -$agent_status_arr = array(); -$agent_status_arr[AGENT_STATUS_ALL] = __('All'); //default -$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal'); -$agent_status_arr[AGENT_STATUS_WARNING] = __('Warning'); -$agent_status_arr[AGENT_STATUS_CRITICAL] = __('Critical'); -$agent_status_arr[AGENT_STATUS_UNKNOWN] = __('Unknown'); -$agent_status_arr[AGENT_STATUS_NOT_INIT] = __('Not init'); - -$row = array(); -$row[] = __('Agent status'); -$row[] = html_print_select($agent_status_arr, "status_agent", $status_agent, '', '', 0, true); -$row[] = __('Search agent'); -$row[] = html_print_input_text("search_agent", $search_agent, '', 40, 30, true); - -// Button -$row[] = html_print_submit_button(__('Filter'), "uptbutton", false, 'class="sub search"', true); -$table->rowspan[][count($row)-1] = 2; - -$table->data[] = $row; - -// Module filter -$module_status_arr = array(); -$module_status_arr[-1] = __('All'); //default -$module_status_arr[AGENT_MODULE_STATUS_NORMAL] = __('Normal'); -$module_status_arr[AGENT_MODULE_STATUS_WARNING] = __('Warning'); -$module_status_arr[AGENT_MODULE_STATUS_CRITICAL_BAD] = __('Critical'); -$module_status_arr[AGENT_MODULE_STATUS_UNKNOWN] = __('Unknown'); -$module_status_arr[AGENT_MODULE_STATUS_NOT_INIT] = __('Not init'); - -$row = array(); -$row[] = __('Module status'); -$row[] = html_print_select($module_status_arr, "status_module", $status_module, '', '', 0, true); -$row[] = __('Search module'); -$row[] = html_print_input_text("search_module", $search_module, '', 40, 30, true); - -$table->data[] = $row; - -echo ''; - -// --------------------- form filter ----------------------------------- -ui_include_time_picker(); -ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/"); - -ui_require_javascript_file("TreeController", "include/javascript/tree/"); -html_print_image('images/spinner.gif', false, - array('class' => "loading_tree", - 'style' => 'display: none;')); -echo "
"; -echo "
"; -echo "
"; -echo "
"; -?> - \ No newline at end of file