'; echo $text; echo ''; echo ''; } function visual_map_print_user_line_handles($layoutData) { $id = $layoutData['id']; $start_x = $layoutData['pos_x']; $start_y = $layoutData['pos_y']; $end_x = $layoutData['width']; $end_y = $layoutData['height']; $z_index = 2; $sizeStyle = ""; $radious_handle = 12 / 2; //Handle of start echo '
'.$agent_label . " - " . $module_label.'
'; break; case 'module': $module_label = ui_print_truncate_text(modules_get_agentmodule_name($id_module), 'module_small', false, true, false, '…', false); $label = ''.$module_label.'
'; break; case 'agent': $agent_label = ui_print_truncate_text(agents_get_name ($id_agent), 'agent_small', false, true, false, '…', false); $label = ''.$agent_label.'
'; break; case 'none': $label = ''; break; } $label = io_safe_input($label); //Restore db connection if ($id_server != 0) { metaconsole_restore_db(); } $value_height = $height; $value_image = $image; $value_type = $type; $value_width = $width; switch ($type) { case PERCENTILE_BAR: case PERCENTILE_BUBBLE: $value_height = $max_value; $value_width = $percentileitem_width; $value_image = $value_show; if ($type_percentile == 'percentile') { $value_type = PERCENTILE_BAR; } else { $value_type = PERCENTILE_BUBBLE; } break; case SIMPLE_VALUE: $label = !empty($label) ? $label . ' (_VALUE_)' : '(_VALUE_)'; $value_image = ''; switch ($process_value) { case PROCESS_VALUE_NONE: $value_type = SIMPLE_VALUE; break; case PROCESS_VALUE_MIN: $value_type = SIMPLE_VALUE_MIN; break; case PROCESS_VALUE_MAX: $value_type = SIMPLE_VALUE_MAX; break; case PROCESS_VALUE_AVG: $value_type = SIMPLE_VALUE_AVG; break; } break; } $parent_item = 0; switch ($kind_relationship) { case VISUAL_MAP_WIZARD_PARENTS_ITEM_MAP: $parent_item = $item_in_the_map; break; } $values = array ('type' => $value_type, 'id_layout' => $id_layout, 'pos_x' => $pos_x, 'pos_y' => $pos_y, 'label' => $label, 'image' => $value_image, 'id_agent' => $id_agent, 'id_agente_modulo' => $id_module, 'width' => $value_width, 'period' => $period, 'height' => $value_height, 'enable_link' => $enable_link, 'id_metaconsole' => $id_server, 'parent_item' => $parent_item); db_process_sql_insert ('tlayout_data', $values); $pos_x = $pos_x + $range; } $return = ui_print_success_message (__('Modules successfully added to layout'), '', true); return $return; } /** * The function to save the new elements of agents make as wizard. * * @param array $id_agents The list of id of agents. * @param string $image The image to set the elements. * @param integer $id_layout The id of visual console to insert the elements. * @param integer $range The distance between elements. * @param integer $width Width of image. * @param integer $height Height of image. * * @return string Return the message status to insert DB. */ function visual_map_process_wizard_add_agents ($id_agents, $image, $id_layout, $range, $width = 0, $height = 0, $period, $process_value, $percentileitem_width, $max_value, $type_percentile, $value_show, $label_type, $type, $enable_link = 1, $id_server = 0, $kind_relationship = VISUAL_MAP_WIZARD_PARENTS_NONE, $item_in_the_map = 0,$fontf = 'arial',$fonts = '12pt') { global $config; if (empty ($id_agents)) { $return = ui_print_error_message( __('No agents selected'), '', true); return $return; } $id_agents = (array)$id_agents; $error = false; $pos_y = 10; $pos_x = 10; $relationship = true; $relationships_agents = array(); //Check if the set a none relationship if (($kind_relationship == VISUAL_MAP_WIZARD_PARENTS_NONE) || ($kind_relationship == VISUAL_MAP_WIZARD_PARENTS_AGENT_RELANTIONSHIP && $item_in_the_map = 0)) { $relationship = false; } foreach ($id_agents as $id_agent) { if (is_array($id_agent)) { $id_a = $id_agent['id_agent']; $id_server = $id_agent['id_server']; $id_agent = $id_a; } if ($pos_x > 600) { $pos_x = 10; $pos_y = $pos_y + $range; } $value_height = $height; $value_image = $image; $value_type = $type; $value_width = $width; switch ($type) { case PERCENTILE_BAR: case PERCENTILE_BUBBLE: $value_height = $max_value; $value_width = $percentileitem_width; $value_image = $value_show; if ($type_percentile == 'percentile') { $value_type = PERCENTILE_BAR; } else { $value_type = PERCENTILE_BUBBLE; } break; case SIMPLE_VALUE: $value_image = ''; switch ($process_value) { case PROCESS_VALUE_NONE: $value_type = SIMPLE_VALUE; break; case PROCESS_VALUE_MIN: $value_type = SIMPLE_VALUE_MIN; break; case PROCESS_VALUE_MAX: $value_type = SIMPLE_VALUE_MAX; break; case PROCESS_VALUE_AVG: $value_type = SIMPLE_VALUE_AVG; break; } break; } if ($id_server != 0) { $connection = db_get_row_filter('tmetaconsole_setup', array('id' => $id_server)); if (metaconsole_load_external_db($connection) != NOERR) { $return = ui_print_error_message( "Error connecting to " . $server_name, '', true); return $return; } } switch ($label_type) { case 'agent': $agent_label = ui_print_truncate_text( agents_get_name($id_agent), 'agent_small', false, true, false, '…', false); $label = $agent_label; break; case 'none': $label = ''; break; } $label = io_safe_input($label); if ($type === SIMPLE_VALUE) $label = !empty($label) ? $label . ' (_VALUE_)' : '(_VALUE_)'; //Restore db connection if ($id_server != 0) { metaconsole_restore_db(); } $parent_item = 0; if ($relationship) { switch ($kind_relationship) { case VISUAL_MAP_WIZARD_PARENTS_ITEM_MAP: $parent_item = $item_in_the_map; break; } } $values = array ('type' => $value_type, 'id_layout' => $id_layout, 'pos_x' => $pos_x, 'pos_y' => $pos_y, 'label' => $label, 'image' => $value_image, 'id_agent' => $id_agent, 'id_agente_modulo' => 0, 'width' => $value_width, 'period' => $period, 'height' => $value_height, 'enable_link' => $enable_link, 'id_metaconsole' => $id_server, 'parent_item' => $parent_item); $id_item = db_process_sql_insert ('tlayout_data', $values); if ($relationship) { switch ($kind_relationship) { case VISUAL_MAP_WIZARD_PARENTS_AGENT_RELANTIONSHIP: if (!isset($relationships_agents[$id_agent])) { $relationships_agents[$id_agent]['id_layout_data_parent'] = $id_item; $relationships_agents[$id_agent]['id_layout_data_children'] = array(); } else { $relationships_agents[$id_agent]['id_layout_data_parent'] = $id_item; } $agent_id_parent = db_get_value('id_parent', 'tagente', 'id_agente', $id_agent); //Check in the group of new items is the father if (array_search($agent_id_parent, $id_agents) !== false) { if (isset($relationships_agents[$agent_id_parent])) { $relationships_agents[$agent_id_parent]['id_layout_data_children'][] = $id_item; } else { $relationships_agents[$agent_id_parent] = array(); $relationships_agents[$agent_id_parent]['id_layout_data_parent'] = null; $relationships_agents[$agent_id_parent]['id_layout_data_children'] = array(); $relationships_agents[$agent_id_parent]['id_layout_data_children'][] = $id_item; } } break; } } $pos_x = $pos_x + $range; } foreach ($relationships_agents as $relationship_item) { foreach ($relationship_item['id_layout_data_children'] as $children) { db_process_sql_update('tlayout_data', array('parent_item' => $relationship_item['id_layout_data_parent']), array('id' => $children)); } } $return = ui_print_success_message( __('Agents successfully added to layout'), '', true); return $return; } /** * Get the color of line between elements in the visual map. * * @param array $layoutData The row of element in DB. * * @return string The color as hexadecimal color in html. */ function visual_map_get_color_line_status($layoutData) { if (($layoutData['type'] == 5) || ($layoutData['type'] == 4)) { //ICON ELEMENT OR LABEL ELEMENT $color = "#cccccc"; } else { switch (visual_map_get_status_element($layoutData)) { case 3: $color = "#cccccc"; // Gray break; case 2: $color = "#20f6f6"; // Yellow break; case 0: $color = "#00ff00"; // Green break; case 4: case 1: $color = "#ff0000"; // Red break; } } return $color; } /** * Get image of element in the visual console with status. * * @param array $layoutData The row of element in DB. * * @return string The image with the relative path to pandora console directory. */ function visual_map_get_image_status_element($layoutData, $status = false) { $img = "images/console/icons/" . $layoutData["image"]; if ($layoutData['type'] == 5) { //ICON ELEMENT $img .= ".png"; } else { if ($status === false) { $status = visual_map_get_status_element($layoutData); } switch ($status) { case 1: //Critical (BAD) $img .= "_bad.png"; break; case 4: //Critical (ALERT) $img = "4" . $img . "_bad.png"; break; case 0: //Normal (OK) $img .= "_ok.png"; break; case 2: //Warning $img .= "_warning.png"; break; case 10: //Warning (ALERT) $img = "4" . $img . "_warning.png"; break; case 3: //Unknown default: $img .= ".png"; // Default is Grey (Other) } } return $img; } /** * Get the status of element in visual console. Check the agent state or * module or layout linked. * * @param array $layoutData The row of element in DB. * * @return integer */ function visual_map_get_status_element($layoutData) { enterprise_include_once('include/functions_visual_map.php'); if (enterprise_installed()) { $status = enterprise_visual_map_get_status_element($layoutData); //The function return value. if ($status !== false) { //Return this value as call of open function. return $status; } } $module_value = db_get_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); //Linked to other layout ?? - Only if not module defined if ($layoutData['id_layout_linked'] != 0) { $status = visual_map_get_layout_status ($layoutData['id_layout_linked']); } else { switch ($layoutData["type"]) { case STATIC_GRAPH: //Enter the correct img if the graph has a module selected or not //Module if ($layoutData['id_agente_modulo'] != 0) { $module_status = db_get_sql ('SELECT estado FROM tagente_estado WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); switch($module_status) { case AGENT_STATUS_NORMAL: $layoutData['status_calculated'] = VISUAL_MAP_STATUS_NORMAL; break; case AGENT_MODULE_STATUS_WARNING: $layoutData['status_calculated'] = VISUAL_MAP_STATUS_WARNING; break; case AGENT_STATUS_CRITICAL: $layoutData['status_calculated'] = VISUAL_MAP_STATUS_CRITICAL_BAD; break; case AGENT_MODULE_STATUS_NO_DATA: default: $layoutData['status_calculated'] = VISUAL_MAP_STATUS_UNKNOWN; break; } } //No module else if ($layoutData['id_agent'] != 0) { $agent = db_get_row ("tagente", "id_agente", $layoutData['id_agent']); if ($agent['total_count'] == 0 || $agent['total_count'] == $agent['notinit_count']) { $layoutData['status_calculated'] = VISUAL_MAP_STATUS_UNKNOWN; } else if ($agent['critical_count'] > 0) { $layoutData['status_calculated'] = VISUAL_MAP_STATUS_CRITICAL_BAD; } else if ($agent['warning_count'] > 0) { $layoutData['status_calculated'] = VISUAL_MAP_STATUS_WARNING; } else if ($agent['unknown_count'] > 0) { $layoutData['status_calculated'] = VISUAL_MAP_STATUS_UNKNOWN; } else { $layoutData['status_calculated'] = VISUAL_MAP_STATUS_NORMAL; } } //In other case else { $layoutData['status_calculated'] = VISUAL_MAP_STATUS_UNKNOWN; } $status = $layoutData['status_calculated']; if ($layoutData['id_metaconsole'] != 0) { //Metaconsole db connection $connection = db_get_row_filter ('tmetaconsole_setup', array('id' => $layoutData['id_metaconsole'])); if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } } if ($layoutData['id_metaconsole'] != 0) { //Restore db connection metaconsole_restore_db(); } break; case PERCENTILE_BAR: case PERCENTILE_BUBBLE: if (empty($module_value) || $module_value == '') { return VISUAL_MAP_STATUS_UNKNOWN; } if ($layoutData['id_metaconsole'] != 0) { //Metaconsole db connection $connection = db_get_row_filter ('tmetaconsole_setup', array('id' => $layoutData['id_metaconsole'])); if (metaconsole_load_external_db($connection) != NOERR) { //ui_print_error_message ("Error connecting to ".$server_name); continue; } } //Status for a simple module if ($layoutData['id_agente_modulo'] != 0) { $status = modules_get_agentmodule_status ($layoutData['id_agente_modulo']); //We need to get the diference between warning and critical alerts!!! $real_status = db_get_row ("tagente_estado", "id_agente_modulo", $layoutData["id_agente_modulo"]); //Status for a whole agent, if agente_modulo was == 0 } else if ($layoutData['id_agent'] != 0) { //-------------------------------------------------- // ADDED NO CHECK ACL FOR AVOID CHECK TAGS THAT // MAKE VERY SLOW THE VISUALMAPS WITH ACL TAGS //-------------------------------------------------- $status = agents_get_status ($layoutData["id_agent"], true); if ($status == -1) // agents_get_status return -1 for unknown! $status = VISUAL_MAP_STATUS_UNKNOWN; } else { $status = VISUAL_MAP_STATUS_UNKNOWN; $id_agent = 0; } if ($layoutData['id_metaconsole'] != 0) { //Restore db connection metaconsole_restore_db(); } break; case GROUP_ITEM: $group_status = groups_get_status($layoutData['id_group']); switch ($group_status) { case AGENT_STATUS_ALERT_FIRED: return VISUAL_MAP_STATUS_CRITICAL_ALERT; break; case AGENT_STATUS_CRITICAL: return VISUAL_MAP_STATUS_CRITICAL_BAD; break; case AGENT_STATUS_WARNING: return VISUAL_MAP_STATUS_WARNING; break; case AGENT_STATUS_UNKNOWN: return VISUAL_MAP_STATUS_UNKNOWN; break; case AGENT_STATUS_NORMAL: default: return VISUAL_MAP_STATUS_NORMAL; break; } break; default: //If it's a graph, a progress bar or a data tag, ALWAYS report status OK //(=0) to avoid confussions here. $status = VISUAL_MAP_STATUS_NORMAL; break; } } switch ($status) { case AGENT_MODULE_STATUS_CRITICAL_ALERT: $status = VISUAL_MAP_STATUS_CRITICAL_ALERT; break; case AGENT_MODULE_STATUS_WARNING_ALERT: $status = VISUAL_MAP_STATUS_WARNING_ALERT; break; } return $status; } function visual_map_print_user_lines($layout_data, $proportion = null) { if (empty($proportion)) { $line = array(); $line["id"] = $layout_data['id']; $line["start_x"] = $layout_data['pos_x']; $line["start_y"] = $layout_data['pos_y']; $line["end_x"] = $layout_data['width']; $line["end_y"] = $layout_data['height']; $line["line_width"] = $layout_data['border_width']; $line["line_color"] = $layout_data['border_color']; } else { $proportion_width = $proportion['proportion_width']; $proportion_height = $proportion['proportion_height']; $proportion_line = $proportion_height; if ($proportion_width > $proportion_height) { $proportion_line = $proportion_width; } $line = array(); $line["id"] = $layout_data['id']; $line["start_x"] = $layout_data['pos_x'] * $proportion_width; $line["start_y"] = $layout_data['pos_y'] * $proportion_height; $line["end_x"] = $layout_data['width'] * $proportion_width; $line["end_y"] = $layout_data['height'] * $proportion_height; $line["line_width"] = $layout_data['border_width'] * $proportion_line; $line["line_color"] = $layout_data['border_color']; } echo ''; } /** * Prints visual map * * @param int $id_layout Layout id * @param bool $show_links * @param bool $draw_lines */ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_lines = true, $width = null, $height = null, $home_url = '', $isExternalLink = false, $graph_javascript = true, $keep_aspect_ratio = false) { enterprise_include_once('include/functions_visual_map.php'); global $config; $metaconsole_hack = '/'; if (defined('METACONSOLE')) { $metaconsole_hack = '../../'; } enterprise_include_once("meta/include/functions_ui_meta.php"); require_once ($config["homedir"] . '/include/functions_custom_graphs.php'); $layout = db_get_row ('tlayout', 'id', $id_layout); if (empty($layout)) { ui_print_error_message(__('Cannot load the visualmap')); return; } ?> "; } echo '