2012-06-25 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_graph.php: cleaned source code style.
	
	* include/functions_custom_graphs.php: fixed into the function
	"graphic_combined_module" the show html entities in the name of
	agents in legends, show better the legend for long size names of
	agents and modules.
	
	Merged from 4.0.2
	
	* extensions/update_manager/debug.php: upload lost file from old
	commit.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6688 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-06-25 10:42:52 +00:00
parent 4ddac5736a
commit 06831a5e55
4 changed files with 210 additions and 97 deletions

View File

@ -1,3 +1,17 @@
2012-06-25 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_graph.php: cleaned source code style.
* include/functions_custom_graphs.php: fixed into the function
"graphic_combined_module" the show html entities in the name of
agents in legends, show better the legend for long size names of
agents and modules.
Merged from 4.0.2
* extensions/update_manager/debug.php: upload lost file from old
commit.
2012-06-22 Sergio Martin <sergio.martin@artica.es> 2012-06-22 Sergio Martin <sergio.martin@artica.es>
* include/functions_reporting.php: Improved several * include/functions_reporting.php: Improved several

View File

@ -0,0 +1,66 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
////////////////////////////////////
///////PLEASE DONT TOUCH
global $debug_update_manager;
////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
///////PLEASE ONLY CHANGE THIS VALUE
$debug_update_manager = 0;
////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
///////PLEASE DONT TOUCH
function print_debug_message_trace($message) {
global $debug_update_manager;
if ($debug_update_manager) {
trigger_error("PRINT DEBUG TRACE",
E_USER_NOTICE);
trigger_error($message, E_USER_NOTICE);
$backtrace = json_encode(debug_backtrace());
$backtrace_chunks = str_split($backtrace, 1024);
trigger_error("INIT DEBUG BACKTRACE (JSON ENCODE) CHUNKS " .
count($backtrace_chunks), E_USER_NOTICE);
foreach ($backtrace_chunks as $chunk)
trigger_error($chunk, E_USER_NOTICE);
trigger_error("END DEBUG BACKTRACE (JSON ENCODE)",
E_USER_NOTICE);
}
}
////////////////////////////////////
////////////////////////////////////
?>

View File

@ -14,8 +14,8 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
include_once($config["homedir"] . "/include/graphs/fgraph.php"); include_once($config['homedir'] . "/include/graphs/fgraph.php");
include_once($config["homedir"] . "/include/functions_reporting.php"); include_once($config['homedir'] . "/include/functions_reporting.php");
include_once($config['homedir'] . "/include/functions_agents.php"); include_once($config['homedir'] . "/include/functions_agents.php");
include_once($config['homedir'] . "/include/functions_modules.php"); include_once($config['homedir'] . "/include/functions_modules.php");
include_once($config['homedir'] . "/include/functions_users.php"); include_once($config['homedir'] . "/include/functions_users.php");
@ -470,13 +470,14 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
} }
// Set variables // Set variables
if ($date == 0) $date = get_system_time(); if ($date == 0)
$date = get_system_time();
$datelimit = $date - $period; $datelimit = $date - $period;
$resolution = $config['graph_res'] * 50; //Number of points of the graph $resolution = $config['graph_res'] * 50; //Number of points of the graph
$interval = (int) ($period / $resolution); $interval = (int) ($period / $resolution);
// If projection graph, fill with zero previous data to projection interval // If projection graph, fill with zero previous data to projection interval
if ($projection != false){ if ($projection != false) {
$j = $datelimit; $j = $datelimit;
$in_range = true; $in_range = true;
while ($in_range){ while ($in_range){
@ -493,9 +494,10 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
} }
// Added support for projection graphs (normal_module + 1(prediction data)) // Added support for projection graphs (normal_module + 1(prediction data))
if ($projection !== false){ if ($projection !== false) {
$module_number = count ($module_list) + 1; $module_number = count ($module_list) + 1;
}else{ }
else {
$module_number = count ($module_list); $module_number = count ($module_list);
} }
@ -538,22 +540,47 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
// Calculate data for each module // Calculate data for each module
for ($i = 0; $i < $module_number; $i++) { for ($i = 0; $i < $module_number; $i++) {
// If its a projection graph, first module will be data and second will be the projection // If its a projection graph, first module will be data and second will be the projection
if ($projection != false and $i != 0) { if ($projection != false && $i != 0) {
$agent_module_id = $module_list[0]; $agent_module_id = $module_list[0];
$agent_name = modules_get_agentmodule_agent_name ($agent_module_id);
//Get and process agent name
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($agent_module_id));
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
$agent_id = agents_get_agent_id ($agent_name); $agent_id = agents_get_agent_id ($agent_name);
$module_name = "projection for " . io_safe_output(modules_get_agentmodule_name ($agent_module_id));
$module_name_list[$i] = substr($agent_name, 0,80) ." / ".substr ($module_name, 0, 40);
//Get and process module name
$module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id));
$module_name = sprintf(__("projection for %s"), $module_name);
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name ." / ". $module_name;
$id_module_type = modules_get_agentmodule_type ($agent_module_id); $id_module_type = modules_get_agentmodule_type ($agent_module_id);
$module_type = modules_get_moduletype_name ($id_module_type); $module_type = modules_get_moduletype_name ($id_module_type);
$uncompressed_module = is_module_uncompressed ($module_type); $uncompressed_module = is_module_uncompressed ($module_type);
} }
else { else {
$agent_module_id = $module_list[$i]; $agent_module_id = $module_list[$i];
$agent_name = modules_get_agentmodule_agent_name ($agent_module_id);
//Get and process agent name
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($agent_module_id));
$agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false);
$agent_id = agents_get_agent_id ($agent_name); $agent_id = agents_get_agent_id ($agent_name);
$module_name = io_safe_output(modules_get_agentmodule_name ($agent_module_id));
$module_name_list[$i] = substr($agent_name, 0,80) ." / ".substr ($module_name, 0, 40); //Get and process module name
$module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id));
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name . " / " . $module_name;
$id_module_type = modules_get_agentmodule_type ($agent_module_id); $id_module_type = modules_get_agentmodule_type ($agent_module_id);
$module_type = modules_get_moduletype_name ($id_module_type); $module_type = modules_get_moduletype_name ($id_module_type);
$uncompressed_module = is_module_uncompressed ($module_type); $uncompressed_module = is_module_uncompressed ($module_type);
@ -592,7 +619,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$min_necessary = 1; $min_necessary = 1;
// Compressed module data // Compressed module data
} else { }
else {
// Get previous data // Get previous data
$previous_data = modules_get_previous_data ($agent_module_id, $datelimit); $previous_data = modules_get_previous_data ($agent_module_id, $datelimit);
if ($previous_data !== false) { if ($previous_data !== false) {
@ -667,7 +695,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) { while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) {
if ($data[$j]['datos'] > $interval_max) { if ($data[$j]['datos'] > $interval_max) {
$interval_max = $data[$j]['datos']; $interval_max = $data[$j]['datos'];
} else if ($data[$j]['datos'] < $interval_max) { }
else if ($data[$j]['datos'] < $interval_max) {
$interval_min = $data[$j]['datos']; $interval_min = $data[$j]['datos'];
} }
$total += $data[$j]['datos']; $total += $data[$j]['datos'];
@ -699,8 +728,9 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$temp_graph_values[$timestamp_short] = $total * $weight_list[$i]; $temp_graph_values[$timestamp_short] = $total * $weight_list[$i];
$previous_data = $total; $previous_data = $total;
}
else {
// Compressed data // Compressed data
} else {
if ($uncompressed_module || ($timestamp > time ())) { if ($uncompressed_module || ($timestamp > time ())) {
//$graph_values[$i][$timestamp] = 0; //$graph_values[$i][$timestamp] = 0;
$temp_graph_values[$timestamp_short] = 0; $temp_graph_values[$timestamp_short] = 0;
@ -758,7 +788,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
//unset($graph_values[$i]); //unset($graph_values[$i]);
//$graph_values[$i] = $graph_values[$i]; //$graph_values[$i] = $graph_values[$i];
} }
$temp = array(); $temp = array();
@ -786,13 +815,17 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => $config['homeurl'] . "/images/logo_vertical_water.png"); 'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
//Work around for fixed the agents name with huge size chars.
$fixed_font_size = $config['font_size'] - 1;
switch ($stacked) { switch ($stacked) {
case GRAPH_AREA: case GRAPH_AREA:
$color = null; $color = null;
return area_graph($flash_charts, $graph_values, $width, $height, return area_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png", $color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $homeurl, $water_mark, "", "", $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl); $config['fontpath'], $fixed_font_size, "", $ttl);
break; break;
default: default:
case GRAPH_STACKED_AREA: case GRAPH_STACKED_AREA:
@ -800,21 +833,21 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
return stacked_area_graph($flash_charts, $graph_values, $width, $height, return stacked_area_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png", $color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $water_mark, "", "", $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl); $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl);
break; break;
case GRAPH_LINE: case GRAPH_LINE:
$color = null; $color = null;
return line_graph($flash_charts, $graph_values, $width, $height, return line_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png", $color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $water_mark, "", "", $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl); $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl);
break; break;
case GRAPH_STACKED_LINE: case GRAPH_STACKED_LINE:
$color = null; $color = null;
return stacked_line_graph($flash_charts, $graph_values, $width, $height, return stacked_line_graph($flash_charts, $graph_values, $width, $height,
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png", $color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
"", "", $water_mark, "", "", $water_mark,
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl); $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl);
break; break;
} }
} }