2011-04-13 Miguel de Dios <miguel.dedios@artica.es>

* 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.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4199 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-04-13 09:29:10 +00:00
parent 309f6623b8
commit b72d775e42
14 changed files with 150 additions and 92 deletions

View File

@ -1,3 +1,14 @@
2011-04-13 Miguel de Dios <miguel.dedios@artica.es>
* 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 <sergio.martin@artica.es>
* include/graphs/functions_pchart.php

View File

@ -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] ='<b>'.__('Monitor health').'</b>';
$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] = '<b>'.__('Module sanity').'</b>';
$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] = '<b>'.__('Alert level').'</b>';
$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);

View File

@ -142,20 +142,9 @@ echo "<tr><td>";
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 "<img src='include/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=" . base64_encode ("Combined%20Sample%20Graph") . "&height=$height&width=$width&stacked=$stacked&period=$period&date=$unixdate' border=1 alt=''>";
//}
//////////////////////////////////////////////////////////////////////////////
echo graphic_combined_module2(explode (',', $modules), explode (',', $weights), $period, $width, $height,
'Combined%20Sample%20Graph', '', $events, 0, 0, $stacked, $unixdate);
///////////////////////////////////////////////////////
}
else {
echo "<div class='nf'>".__('Empty graph')."</div>";

View File

@ -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)

View File

@ -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 "<img title='" . $title . "' alt='" . $title . "' src='include/graphs/fgraph.php?graph_type=progressbar&width=".$width."&height=".$height."&progress=".$progress.
"&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str."&title=".$title."&font=".$config['fontpath']."' />";
}
?>

View File

@ -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 = '<img class="image" id="image_' . $id . '" src="include/fgraph.php?tipo=progress&height=15&width=' . $width . '&mode=1&percent=' . $percentile . '" />';
echo '<div id="' . $id . '" class="item percentile_bar" style="left: 0px; top: 0px; color: ' . $color . '; text-align: center; position: absolute; ' . $sizeStyle . ' margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">';
echo $text . '<br />';
echo $text . '<br />';
echo progress_bar2($percentile, $width, 15);
echo $img;
echo '</div>';
@ -744,10 +745,9 @@ function print_pandora_visual_map ($id_layout, $show_links = true, $draw_lines =
echo "<br>";
if ($resizedMap)
echo "<img src='".$config["homeurl"]."/include/fgraph.php?tipo=progress&height=15&width=".((integer)($proportion * $width))."&mode=1&percent=$percentile'>";
else
echo "<img src='".$config["homeurl"]."/include/fgraph.php?tipo=progress&height=15&width=$width&mode=1&percent=$percentile'>";
echo progress_bar2($percentile, ((integer)($proportion * $width)), 15);
else
echo progress_bar2($percentile, $width, 15);
echo '</div>';
break;
case 1;

View File

@ -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;
}

View File

@ -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;
}
}
?>

View File

@ -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] = "<h3 class='title_h3_server'>" . __('Status') . "</h3>" ;
$table->data[1][0] = '<span title="' . __('Global health') . '" alt="' . __('Global health') . '">' . __('G') . '</span> ';
$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] = '<span title="' . __('Monitor health') . '" alt="' . __('Monitor health') . '">' . __('M') . '</span> ';
$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] = '<span title="' . __('Module sanity') . '" alt="' . __('Module sanity') . '">' . __('M') . '</span> ';
$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] = '<span title="' . __('Alert level') . '" alt="' . __('Alert level') . '">' . __('A') . '</span> ';
$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] = '';

View File

@ -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 '<div style="height:25px">&nbsp;</div>';
echo '<b>'.__('Events generated -by module-').'</b><br />';
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 '<img border="1" src="include/fgraph.php?tipo=event_module&width=290&height=180&id_agent='.$id_agente.'" />';
}
echo '</div>';
@ -182,7 +173,7 @@ if ($agent['timezone_offset'] != 0) {
$progress = getNextAgentContact($id_agente);
echo '<tr><td class="datos"><b>'.__('Next agent contact').'</b></td>';
echo '<td class="datos f9" colspan="2"><img src="include/fgraph.php?tipo=progress&amp;percent='.$progress.'&amp;height=20&amp;width=200"></td></tr>';
echo '<td class="datos f9" colspan="2">' . progress_bar2($progress, 200, 20) . '</td></tr>';
// Custom fields
$fields = get_db_all_rows_filter('tagent_custom_fields', array('display_on_front' => 1));

View File

@ -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 ();
?>

View File

@ -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] ='<b>'.__('Global health').'</b>';
$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] ='<b>'.__('Monitor health').'</b>';
$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] = '<b>'.__('Module sanity').'</b>';
$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] = '<b>'.__('Alert level').'</b>';
$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"];

View File

@ -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] = '<span style="white-space:nowrap;">'.$server["lag_txt"].'</span>';
$data[6] = $server['threads'].' : '.$server['queued_modules'];

View File

@ -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 = "<li><a href='index.php?sec=estado_server&sec2=operation/servers/view_server_detail&server_id=$id_server'>" . print_image("images/refresh.png", true) . "</a></li>";
@ -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);