diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2d53b1b00d..a3d6197410 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2011-04-13 Miguel de Dios + + * include/functions_graph.php, include/graphs/functions_gd.php, + include/graphs/fgraph.php, include/functions_visual_map.php, + include/fgraph.php, operation/agentes/estado_generalagente.php, + operation/agentes/tactical.php. operation/agentes/stat_win.php, + operation/servers/view_server.php, operation/servers/view_server_detail.php, + mobile/operation/agents/tactical.php, general/logon_ok.php, + godmode/reporting/graph_builder.preview.php: added function "progress_bar2" + and changed in source code of Pandora. + 2011-04-13 Sergio Martin * include/graphs/functions_pchart.php diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index c07ece8a38..da643fbcef 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -26,6 +26,7 @@ check_login (); extensions_call_login_function (); require_once ("include/functions_reporting.php"); +require_once ($config["homedir"] . '/include/functions_graph.php'); print_page_header (__('Welcome to Pandora FMS Web Console')); @@ -75,16 +76,15 @@ $table->head = array (); $table->data = array (); $table->width = "100%"; -$img = "include/fgraph.php?tipo=progress&height=20&width=280&mode=0&percent="; - $table->data[0][0] =''.__('Monitor health').''; -$table->data[1][0] = print_image ($img.$data["monitor_health"], true, array ("title" => $data["monitor_health"].'% '.__('of monitors up'))); - +$table->data[1][0] = + progress_bar2($data["monitor_health"], 280, 20, $data["monitor_health"].'% '.__('of monitors up'), 0); $table->data[2][0] = ''.__('Module sanity').''; -$table->data[3][0] = print_image ($img.$data["module_sanity"], true, array ("title" => $data["module_sanity"].'% '.__('of total modules inited'))); - +$table->data[3][0] = + progress_bar2($data["module_sanity"], 280, 20, $data["module_sanity"].'% '.__('of total modules inited'), 0); $table->data[4][0] = ''.__('Alert level').''; -$table->data[5][0] = print_image ($img.$data["alert_level"], true, array ("title" => $data["alert_level"].'% '.__('of defined alerts not fired'))); +$table->data[5][0] = + progress_bar2($data["alert_level"], 280, 20, $data["alert_level"].'% '.__('of defined alerts not fired'), 0); print_table ($table); unset ($table); diff --git a/pandora_console/godmode/reporting/graph_builder.preview.php b/pandora_console/godmode/reporting/graph_builder.preview.php index 0355e77f62..20f54d83ca 100644 --- a/pandora_console/godmode/reporting/graph_builder.preview.php +++ b/pandora_console/godmode/reporting/graph_builder.preview.php @@ -142,20 +142,9 @@ echo ""; if(!empty($modules)) { require_once ($config["homedir"] . '/include/functions_graph.php'); - - //if ($config['flash_charts']) { - //echo graphic_combined_module (explode (',', $modules), explode (',', $weights), $period, $width, $height, - // 'Combined%20Sample%20Graph', '', $events, 0, 0, $stacked, $unixdate); - //} - //else { - //echo ""; - //} - - ////////////////////////////////////////////////////////////////////////////// + echo graphic_combined_module2(explode (',', $modules), explode (',', $weights), $period, $width, $height, 'Combined%20Sample%20Graph', '', $events, 0, 0, $stacked, $unixdate); - - /////////////////////////////////////////////////////// } else { echo "
".__('Empty graph')."
"; diff --git a/pandora_console/include/fgraph.php b/pandora_console/include/fgraph.php index 205635f09d..9f9061f06c 100644 --- a/pandora_console/include/fgraph.php +++ b/pandora_console/include/fgraph.php @@ -2287,12 +2287,6 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, $Graph->done(); grafico_modulo_log4x_trace(__LINE__); - - - //$image = "../../include/fgraph.php?tipo=graphic_error"; - //grafico_modulo_log4x_trace(__LINE__); - //print_image ($image, false, array ("border" => 0)); - //grafico_modulo_log4x_trace(__LINE__); } function grafico_modulo_log4x_index($x, $interval) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 0341ecc991..d10d9814f6 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -290,7 +290,7 @@ function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events, $legend['min'] = __('Min') . ' (' . $min_value . ')'; $legend['baseline'] = __('Baseline'); - return area_graph($config['flash_charts'], $chart, $width, $height, $color,$legend, $long_index); + return area_graph($config['flash_charts'], $chart, $width, $height, $color,$legend, $long_index, "images/image_problem.opaque.png"); } /** @@ -716,4 +716,13 @@ function graph_event_module2 ($width = 300, $height = 200, $id_agent) { return pie3d_graph(0, $data, $width, $height, __("other")); } + +function progress_bar2($progress, $width, $height, $title = '', $mode = 1) { + global $config; + + $out_of_lim_str = __("Out of limits"); + $title = ""; + return "" . $title . ""; +} ?> \ No newline at end of file diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 1e746d500b..703bcc9be5 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -49,6 +49,8 @@ function printButtonEditorVisualConsole($idDiv, $label, $float = 'left', $disabl } function printItemInVisualConsole($layoutData) { + require_once ($config["homedir"] . '/include/functions_graph.php'); + $width = $layoutData['width']; $height = $max_percentile = $layoutData['height']; $top = $layoutData['pos_y']; @@ -99,10 +101,9 @@ function printItemInVisualConsole($layoutData) { else $percentile = 100; - $img = ''; - echo '
'; - echo $text . '
'; + echo $text . '
'; + echo progress_bar2($percentile, $width, 15); echo $img; echo '
'; @@ -744,10 +745,9 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines = echo "
"; if ($resizedMap) - echo ""; - else - echo ""; - + echo progress_bar2($percentile, ((integer)($proportion * $width)), 15); + else + echo progress_bar2($percentile, $width, 15); echo ''; break; case 1; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 74111e7603..1fff5de261 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -49,7 +49,10 @@ switch($graph_type) { $font = get_parameter('font'); $title = get_parameter('title'); - gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image); + + $mode = get_parameter('mode', 1); + + gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode); break; } diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 1c39b1f519..46ef6125ba 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -89,7 +89,7 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title) // Draw a dynamic progress bar using GDlib directly // *************************************************************************** -function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image) { +function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode = 1) { if($out_of_lim_str === false) { $out_of_lim_str = "Out of limits"; } @@ -102,7 +102,7 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim // http://us3.php.net/manual/en/function.imagefilledrectangle.php // With some adds from sdonie at lgc dot com // Get from official documentation PHP.net website. Thanks guys :-) - function drawRating($rating, $width, $height, $font, $out_of_lim_str) { + function drawRating($rating, $width, $height, $font, $out_of_lim_str, $mode) { global $config; global $REMOTE_ADDR; @@ -126,38 +126,90 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim $text = ImageColorAllocate($image,74,74,74); $red = ImageColorAllocate($image,255,60,75); $green = ImageColorAllocate($image,50,205,50); - $fill = ImageColorAllocate($image,44,81,120); + $blue = ImageColorAllocate($image,44,81,120); + + $soft_green = ImageColorAllocate($image,176, 255, 84); + $soft_yellow = ImageColorAllocate($image,255, 230, 84); + $soft_red = ImageColorAllocate($image,255, 154, 84); + $other_red = ImageColorAllocate($image,238, 0, 0); ImageFilledRectangle($image,0,0,$width-1,$height-1,$back); - if ($rating > 100) - ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$red); - elseif ($rating == 100) - ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$green); - else - ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill); - - ImageRectangle($image,0,0,$width-1,$height-1,$border); - if ($rating > 50) - if ($rating > 100) - ImageTTFText($image, 8, 0, ($width/4), ($height/2)+($height/5), $back, $font, $out_of_lim_str); - else - ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $font, $rating."%"); - else - ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $text, $font, $rating."%"); + switch ($mode) + { + case 0: + if ($rating > 70) + ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_green); + elseif ($rating > 50) + ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_yellow); + elseif ($rating > 30) + ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_red); + else + ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $other_red); + + ImageRectangle($image,0,0,$width-1,$height-1,$border); + break; + case 1: + if ($rating > 100) + ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$red); + elseif ($rating == 100) + ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$green); + else + ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$blue); + + ImageRectangle($image,0,0,$width-1,$height-1,$border); + + if ($rating > 50) + if ($rating > 100) + ImageTTFText($image, 8, 0, ($width/4), ($height/2)+($height/5), $back, $font, $out_of_lim_str); + else + ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $font, $rating."%"); + else + ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $text, $font, $rating."%"); + break; + } imagePNG($image); imagedestroy($image); } Header("Content-type: image/png"); - if ($progress > 100 || $progress < 0) { - // HACK: This report a static image... will increase render in about 200% :-) useful for - // high number of realtime statusbar images creation (in main all agents view, for example - $imgPng = imageCreateFromPng($out_of_lim_image); - imageAlphaBlending($imgPng, true); - imageSaveAlpha($imgPng, true); - imagePng($imgPng); - } else - drawRating($progress, $width, $height, $font, $out_of_lim_str); + + switch ($mode) + { + case 0: + drawRating($progress, $width, $height, $font, $out_of_lim_str, $mode); + /* +if ($mode == 0) { + $engine->background_color = '#E6E6D2'; + $engine->show_title = false; + if ($progress > 70) + $color = '#B0FF54'; + elseif ($progress > 50) + $color = '#FFE654'; + elseif ($progress > 30) + $color = '#FF9A54'; + else + $color = '#EE0000'; + } else { + $engine->background_color = '#FFFFFF'; + $engine->show_title = true; + $engine->title = format_numeric ($progress).' %'; + $color = '#2C5196'; } + */ + break; + case 1: + if ($progress > 100 || $progress < 0) { + // HACK: This report a static image... will increase render in about 200% :-) useful for + // high number of realtime statusbar images creation (in main all agents view, for example + $imgPng = imageCreateFromPng($out_of_lim_image); + imageAlphaBlending($imgPng, true); + imageSaveAlpha($imgPng, true); + imagePng($imgPng); + } + else + drawRating($progress, $width, $height, $font, $out_of_lim_str, $mode); + break; + } +} ?> diff --git a/pandora_console/mobile/operation/agents/tactical.php b/pandora_console/mobile/operation/agents/tactical.php index c638358c8b..7c0cdc84be 100644 --- a/pandora_console/mobile/operation/agents/tactical.php +++ b/pandora_console/mobile/operation/agents/tactical.php @@ -22,7 +22,9 @@ class Tactical { } function show() { - $img = "../include/fgraph.php?tipo=progress&height=8&width=70&mode=0&percent="; + global $config; + + require_once ($config["homedir"] . '/include/functions_graph.php'); $data = get_group_stats(); @@ -40,13 +42,17 @@ class Tactical { $table->data[0][0] = "

" . __('Status') . "

" ; $table->data[1][0] = '' . __('G') . ' '; - $table->data[1][1] = print_image ($img.$data["global_health"], true); + $table->data[1][1] = + progress_bar2($data["global_health"], 70, 8, '', 0); $table->data[2][0] = '' . __('M') . ' '; - $table->data[2][1] = print_image ($img.$data["monitor_health"], true); + $table->data[2][1] = + progress_bar2($data["monitor_health"], 70, 8, '', 0); $table->data[3][0] = '' . __('M') . ' '; - $table->data[3][1] = print_image ($img.$data["module_sanity"], true); + $table->data[3][1] = + progress_bar2($data["module_sanity"], 70, 8, '', 0); $table->data[4][0] = '' . __('A') . ' '; - $table->data[4][1] = print_image ($img.$data["alert_level"], true); + $table->data[4][1] = + progress_bar2($data["alert_level"], 70, 8, '', 0); $table->data[5][0] = $table->data[5][1] = ''; $table->data[6][0] = $table->data[6][1] = ''; $table->data[7][0] = $table->data[7][1] = ''; diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 442a9a4f68..f7497d076b 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -22,10 +22,6 @@ require_once ("include/functions_agents.php"); require_once ($config["homedir"] . '/include/functions_graph.php'); -if ($config['flash_charts']) { - require_once ("include/fgraph.php"); -} - check_login (); $id_agente = get_parameter_get ("id_agente", -1); @@ -56,14 +52,9 @@ graphic_agentaccess2($id_agente, 280, 110, 86400); echo '
 
'; echo ''.__('Events generated -by module-').'
'; +echo graph_event_module2 (290, 120, $id_agente); if ($config['flash_charts']) { - /////// echo graphic_agentevents ($id_agente, 290, 60, 86400); - /////// - echo graph_event_module2 (290, 120, $id_agente); - -} else { - echo ''; } echo ''; @@ -182,7 +173,7 @@ if ($agent['timezone_offset'] != 0) { $progress = getNextAgentContact($id_agente); echo ''.__('Next agent contact').''; -echo ''; +echo '' . progress_bar2($progress, 200, 20) . ''; // Custom fields $fields = get_db_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1)); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 70e7bba588..a866e86fdf 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -28,7 +28,6 @@ require_once ($config["homedir"] . '/include/functions.php'); require_once ($config["homedir"] . '/include/functions_db.php'); require_once ($config["homedir"] . '/include/functions_reporting.php'); require_once ($config["homedir"] . '/include/functions_graph.php'); -//require_once ($config["homedir"] . '/include/fgraph.php'); check_login (); ?> diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 1f3b2059bf..ce07ba2e2f 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -20,6 +20,7 @@ global $config; require_once ("include/functions_events.php"); require_once ("include/functions_servers.php"); require_once ("include/functions_reporting.php"); +require_once ($config["homedir"] . '/include/functions_graph.php'); check_login (); @@ -80,36 +81,33 @@ $table->head = array (); $table->data = array (); $table->style = array (); -$img = "include/fgraph.php?tipo=progress&height=20&width=140&mode=0&percent="; - - $table->style[0] = "padding-top:4px; padding-bottom:4px;"; $table->data[0][0] =''.__('Global health').''; $table->style[1] = "padding-top:4px; padding-bottom:4px;"; -$table->data[1][0] = print_image ($img.$data["global_health"], true, - array ("width" => '100%', "height" => 20, "title" => $data["global_health"].'% '.__('of monitors OK'))); +$table->data[1][0] = + progress_bar2($data["global_health"], 140, 20, $data["global_health"].'% '.__('of monitors OK'), 0); $table->style[2] = "padding-top:4px; padding-bottom:4px;"; $table->data[2][0] =''.__('Monitor health').''; $table->style[3] = "padding-top:4px; padding-bottom:4px;"; -$table->data[3][0] = print_image ($img.$data["monitor_health"], true, - array ("width" => '100%', "height" => 20, "title" => $data["monitor_health"].'% '.__('of monitors up'))); +$table->data[3][0] = + progress_bar2($data["monitor_health"], 140, 20, $data["monitor_health"].'% '.__('of monitors up'), 0); $table->style[4] = "padding-top:4px; padding-bottom:4px;"; $table->data[4][0] = ''.__('Module sanity').''; $table->style[5] = "padding-top:4px; padding-bottom:4px;"; -$table->data[5][0] = print_image ($img.$data["module_sanity"], true, - array ("width" => '100%', "height" => 20, "title" => $data["module_sanity"].'% '.__('of total modules inited'))); +$table->data[5][0] = + progress_bar2($data["module_sanity"], 140, 20, $data["module_sanity"].'% '.__('of total modules inited'), 0); $table->style[6] = "padding-top:4px; padding-bottom:4px;"; $table->data[6][0] = ''.__('Alert level').''; $table->style[7] = "padding-top:4px; padding-bottom:4px;"; -$table->data[7][0] = print_image ($img.$data["alert_level"], true, - array ("width" => '100%', "height" => 20, "title" => $data["alert_level"].'% '.__('of defined alerts not fired'))); +$table->data[7][0] = + progress_bar2($data["alert_level"], 140, 20, $data["alert_level"].'% '.__('of defined alerts not fired'), 0); print_table ($table); unset ($table); @@ -276,7 +274,8 @@ if($is_admin) { } if ($server["type"] != "snmp") { - $data[3] = print_image ("include/fgraph.php?tipo=progress&percent=".$server["load"]."&height=20&width=80", true, ''); + $data[3] = + progress_bar2($server["load"], 80, 20); if ($server["type"] != "recon"){ $data[4] = $server["lag_txt"]; diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index c093a20aa6..ef9644f678 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -17,7 +17,9 @@ // Load global vars global $config; + require_once ("include/functions_servers.php"); +require_once ($config["homedir"] . '/include/functions_graph.php'); check_login (); @@ -76,7 +78,8 @@ foreach ($servers as $server) { $data[2] .= print_help_tip (__("This is a master server"), true); // Load - $data[3] = print_image ("include/fgraph.php?tipo=progress&percent=".$server["load"]."&height=20&width=60", true, array ("title" => $server["lag_txt"])); + $data[3] = + progress_bar2($server["load"], 60, 20, $server["lag_txt"], 0); $data[4] = $server["modules"] . " ".__('of')." ". $server["modules_total"]; $data[5] = ''.$server["lag_txt"].''; $data[6] = $server['threads'].' : '.$server['queued_modules']; diff --git a/pandora_console/operation/servers/view_server_detail.php b/pandora_console/operation/servers/view_server_detail.php index 0150a98bbc..816f4d1886 100644 --- a/pandora_console/operation/servers/view_server_detail.php +++ b/pandora_console/operation/servers/view_server_detail.php @@ -19,6 +19,8 @@ global $config; check_login (); +require_once ($config["homedir"] . '/include/functions_graph.php'); + $id_server = (int) get_parameter ("server_id", -1); $options = "
  • " . print_image("images/refresh.png", true) . "
  • "; @@ -132,7 +134,7 @@ foreach ($recon_tasks as $task) { $data[6] = "-"; } else { - $data[6] = print_image ("include/fgraph.php?tipo=progress&percent=".$task['status']."&height=20&width=100", true, array ("title" => __('Progress').':'.$task["status"].'%')); + $data[6] = progress_bar2($task['status'], 100, 20, __('Progress').':'.$task["status"].'%', 0); } $data[7] = print_timestamp ($task["utimestamp"], true);