diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index db155e6f61..6e019fcf57 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -25,13 +25,12 @@ if ($get_image_path_status){ $only_src = get_parameter("only_src", 0); $result = array(); - + $result['bad'] = html_print_image($img_src . '_bad.png', true, '', $only_src); $result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src); $result['warning'] = html_print_image($img_src . '_warning.png', true, '', $only_src); - $result['ok'] = html_print_image($img_src . '_ok.png', true, '', $only_src); $result['normal'] = html_print_image($img_src . '.png', true, '', $only_src); - + echo json_encode($result); return; } diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index afcfe1d604..2dc7c32afb 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1633,78 +1633,11 @@ function visual_map_print_item($mode = "read", $layoutData, break; case STATIC_GRAPH: case GROUP_ITEM: - - - if (! defined ('METACONSOLE')) { - } - else { - // For each server defined and not disabled: - $servers = db_get_all_rows_sql ('SELECT * - FROM tmetaconsole_setup - WHERE disabled = 0'); - if ($servers === false) - $servers = array(); - - $result = array(); - $count_modules = 0; - foreach ($servers as $server) { - // If connection was good then retrieve all data server - if (metaconsole_connect($server) == NOERR) - $connection = true; - else - $connection = false; - - $result_server = db_get_all_rows_sql ($sql); - - if (!empty($result_server)) { - - // Create HASH login info - $pwd = $server['auth_token']; - $auth_serialized = json_decode($pwd,true); - - if (is_array($auth_serialized)) { - $pwd = $auth_serialized['auth_token']; - $api_password = $auth_serialized['api_password']; - $console_user = $auth_serialized['console_user']; - $console_password = $auth_serialized['console_password']; - } - - $user = $config['id_user']; - $user_rot13 = str_rot13($config['id_user']); - $hashdata = $user.$pwd; - $hashdata = md5($hashdata); - $url_hash = '&' . - 'loginhash=auto&' . - 'loginhash_data=' . $hashdata . '&' . - 'loginhash_user=' . $user_rot13; - - foreach ($result_server as $result_element_key => $result_element_value) { - - $result_server[$result_element_key]['server_id'] = $server['id']; - $result_server[$result_element_key]['server_name'] = $server['server_name']; - $result_server[$result_element_key]['server_url'] = $server['server_url'].'/'; - $result_server[$result_element_key]['hashdata'] = $hashdata; - $result_server[$result_element_key]['user'] = $config['id_user']; - - $count_modules++; - - } - - $result = array_merge($result, $result_server); - } - - if ($connection) { - metaconsole_restore_db(); - } - } - } - if (($layoutData['image'] != null && $layoutData['image'] != 'none') || $layoutData['show_statistics'] == 1) { $img_style_title = strip_tags($label); if ($layoutData['type'] == STATIC_GRAPH) { if ($layoutData['id_agente_modulo'] != 0) { - if ($layoutData['id_metaconsole'] != 0) { //Metaconsole db connection $connection = db_get_row_filter ('tmetaconsole_setup', @@ -1780,83 +1713,84 @@ function visual_map_print_item($mode = "read", $layoutData, else if($layoutData['label_position']=='right'){ $imgpos = 'float:left'; } - $varsize = getimagesize($config['homedir'] . '/' . $img); - - - if($layoutData['show_statistics'] == 1){ - + + if($layoutData['show_statistics'] == 1) { if (get_parameter('action') == 'edit') { - if ($width == 0 || $height == 0) { - - echo ''; + echo ''; } else{ - echo ''; + echo ''; } - } else{ - - $agents_critical = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_CRITICAL), - array ('COUNT(*) as total'), 'AR', false); - - $agents_warning = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_WARNING), - array ('COUNT(*) as total'), 'AR', false); - - $agents_unknown = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_UNKNOWN), - array ('COUNT(*) as total'), 'AR', false); - - $agents_ok = agents_get_agents(array ( - 'disabled' => 0, - 'id_grupo' => $layoutData['id_group'], - 'status' => AGENT_STATUS_OK), - array ('COUNT(*) as total'), 'AR', false); - - $total_agents = $agents_critical[0]['total'] + $agents_warning[0]['total'] + $agents_unknown[0]['total'] + $agents_ok[0]['total']; - - $stat_agent_ok = $agents_ok[0]['total']/$total_agents*100; - $stat_agent_wa = $agents_warning[0]['total']/$total_agents*100; - $stat_agent_cr = $agents_critical[0]['total']/$total_agents*100; - $stat_agent_un = $agents_unknown[0]['total']/$total_agents*100; - - if($width == 0 || $height == 0){ - $dyn_width = 520; - $dyn_height = 80; - } - else{ - $dyn_width = $width; - $dyn_height = $height; - } - - - echo ''; - - echo ""; - echo ""; - - echo ""; - echo ""; - echo ""; + echo ""; + echo "
" .groups_get_name($layoutData['id_group'],true) . "
"; + $agents_critical = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_CRITICAL + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $agents_warning = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_WARNING + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $agents_unknown = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_UNKNOWN + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $agents_ok = agents_get_agents( + array ( + 'disabled' => 0, + 'id_grupo' => $layoutData['id_group'], + 'status' => AGENT_STATUS_OK + ), + array ('COUNT(*) as total'), + 'AR', + false + ); + $total_agents = $agents_critical[0]['total'] + $agents_warning[0]['total'] + $agents_unknown[0]['total'] + $agents_ok[0]['total']; + $stat_agent_ok = $agents_ok[0]['total']/$total_agents*100; + $stat_agent_wa = $agents_warning[0]['total']/$total_agents*100; + $stat_agent_cr = $agents_critical[0]['total']/$total_agents*100; + $stat_agent_un = $agents_unknown[0]['total']/$total_agents*100; + if($width == 0 || $height == 0){ + $dyn_width = 520; + $dyn_height = 80; + } else { + $dyn_width = $width; + $dyn_height = $height; + } + echo ''; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; - echo ""; - echo "
" .groups_get_name($layoutData['id_group'],true) . "
"; echo "
". remove_right_zeros(number_format($stat_agent_cr, 2)) ."%
"; echo "
Critical
"; echo "
". remove_right_zeros(number_format($stat_agent_wa, 2)) ."%
"; @@ -1865,68 +1799,38 @@ function visual_map_print_item($mode = "read", $layoutData, echo "
Normal
"; echo "
". remove_right_zeros(number_format($stat_agent_un, 2)) ."%
"; echo "
Unknown
"; - - echo "
"; - - + echo "
"; } - - } - else{ - + } else { + $options = array( + "class" => "image", + "id" => "image_" . $id, + "title" => $img_style_title, + "style" => $borderStyle.$imgpos + ); if ($width == 0 || $height == 0) { if($varsize[0] > 150 || $varsize[1] > 150){ - echo html_print_image($img, true, - array("class" => "image", - "id" => "image_" . $id, - "width" => "70px", - "height" => "70px", - "title" => $img_style_title, - "style" => $borderStyle.$imgpos), false, - false, false, $isExternalLink); - } - else{ - echo html_print_image($img, true, - array("class" => "image", - "id" => "image_" . $id, - "title" => $img_style_title, - "style" => $borderStyle.$imgpos), false, - false, false, $isExternalLink); + $options['width'] = "70px"; + $options['height'] = "70px"; } } else{ - echo html_print_image($img, true, - array("class" => "image", - "id" => "image_" . $id, - "width" => $width, - "height" => $height, - "title" => $img_style_title, - "style" => $borderStyle.$imgpos), false, - false, false, $isExternalLink); + $options['width'] = $width; + $options['height'] = $height; } - + echo html_print_image($img, true, $options, + false, false, false, $isExternalLink); } - } - - if($layoutData['label_position']=='down'){ - echo io_safe_output($text); - } - else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){ + + if ($layoutData['label_position'] != 'up') { echo io_safe_output($text); } - - if (! defined ('METACONSOLE')) { - } - else { - metaconsole_restore_db(); - } - - - break; - + + if (is_metaconsole()) metaconsole_restore_db(); + break; case PERCENTILE_BAR: if (($layoutData['image'] == 'value') && ($value_text !== false)) { $unit_text = db_get_sql ('SELECT unit