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:
parent
4ddac5736a
commit
06831a5e55
|
@ -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>
|
||||
|
||||
* include/functions_reporting.php: Improved several
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////
|
||||
////////////////////////////////////
|
||||
?>
|
|
@ -46,7 +46,7 @@ function custom_graphs_get_user ($id_user = 0, $only_names = false, $returnAllGr
|
|||
$id_user = $config['id_user'];
|
||||
}
|
||||
|
||||
$groups = users_get_groups ($id_user, $privileges, $returnAllGroup);
|
||||
$groups = users_get_groups ($id_user, $privileges, $returnAllGroup);
|
||||
|
||||
$all_graphs = db_get_all_rows_in_table ('tgraph', 'name');
|
||||
if ($all_graphs === false)
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
include_once($config["homedir"] . "/include/graphs/fgraph.php");
|
||||
include_once($config["homedir"] . "/include/functions_reporting.php");
|
||||
include_once($config['homedir'] . "/include/graphs/fgraph.php");
|
||||
include_once($config['homedir'] . "/include/functions_reporting.php");
|
||||
include_once($config['homedir'] . "/include/functions_agents.php");
|
||||
include_once($config['homedir'] . "/include/functions_modules.php");
|
||||
include_once($config['homedir'] . "/include/functions_users.php");
|
||||
|
@ -434,8 +434,8 @@ function graph_get_formatted_date($timestamp, $format1, $format2) {
|
|||
* @return Mixed
|
||||
*/
|
||||
function graphic_combined_module ($module_list, $weight_list, $period, $width, $height,
|
||||
$title, $unit_name, $show_events = 0, $show_alerts = 0, $pure = 0,
|
||||
$stacked = 0, $date = 0, $only_image = false, $homeurl = '', $ttl = 1, $projection = false, $prediction_period = false) {
|
||||
$title, $unit_name, $show_events = 0, $show_alerts = 0, $pure = 0,
|
||||
$stacked = 0, $date = 0, $only_image = false, $homeurl = '', $ttl = 1, $projection = false, $prediction_period = false) {
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
|
@ -470,13 +470,14 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
}
|
||||
|
||||
// Set variables
|
||||
if ($date == 0) $date = get_system_time();
|
||||
if ($date == 0)
|
||||
$date = get_system_time();
|
||||
$datelimit = $date - $period;
|
||||
$resolution = $config['graph_res'] * 50; //Number of points of the graph
|
||||
$interval = (int) ($period / $resolution);
|
||||
|
||||
// If projection graph, fill with zero previous data to projection interval
|
||||
if ($projection != false){
|
||||
if ($projection != false) {
|
||||
$j = $datelimit;
|
||||
$in_range = true;
|
||||
while ($in_range){
|
||||
|
@ -493,14 +494,15 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
}
|
||||
|
||||
// Added support for projection graphs (normal_module + 1(prediction data))
|
||||
if ($projection !== false){
|
||||
if ($projection !== false) {
|
||||
$module_number = count ($module_list) + 1;
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
$module_number = count ($module_list);
|
||||
}
|
||||
|
||||
// interval - This is the number of "rows" we are divided the time to fill data.
|
||||
// more interval, more resolution, and slower.
|
||||
// more interval, more resolution, and slower.
|
||||
// periodo - Gap of time, in seconds. This is now to (now-periodo) secs
|
||||
|
||||
// Init weights
|
||||
|
@ -509,25 +511,25 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
$weight_list[$i] = 1;
|
||||
}
|
||||
else if ($weight_list[$i] == 0) {
|
||||
$weight_list[$i] = 1;
|
||||
$weight_list[$i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Set data containers
|
||||
for ($i = 0; $i < $resolution; $i++) {
|
||||
$timestamp = $datelimit + ($interval * $i);/*
|
||||
$timestamp_short = date($time_format, $timestamp);
|
||||
$long_index[$timestamp_short] = date(
|
||||
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
||||
$timestamp = $timestamp_short;*/
|
||||
$timestamp = $datelimit + ($interval * $i);/*
|
||||
$timestamp_short = date($time_format, $timestamp);
|
||||
$long_index[$timestamp_short] = date(
|
||||
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
||||
$timestamp = $timestamp_short;*/
|
||||
|
||||
$graph[$timestamp]['count'] = 0;
|
||||
$graph[$timestamp]['timestamp_bottom'] = $timestamp;
|
||||
$graph[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
||||
$graph[$timestamp]['min'] = 0;
|
||||
$graph[$timestamp]['max'] = 0;
|
||||
$graph[$timestamp]['event'] = 0;
|
||||
$graph[$timestamp]['alert'] = 0;
|
||||
$graph[$timestamp]['count'] = 0;
|
||||
$graph[$timestamp]['timestamp_bottom'] = $timestamp;
|
||||
$graph[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
||||
$graph[$timestamp]['min'] = 0;
|
||||
$graph[$timestamp]['max'] = 0;
|
||||
$graph[$timestamp]['event'] = 0;
|
||||
$graph[$timestamp]['alert'] = 0;
|
||||
}
|
||||
|
||||
$long_index = array();
|
||||
|
@ -538,22 +540,47 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
// Calculate data for each module
|
||||
for ($i = 0; $i < $module_number; $i++) {
|
||||
// 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_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);
|
||||
$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);
|
||||
$module_type = modules_get_moduletype_name ($id_module_type);
|
||||
$uncompressed_module = is_module_uncompressed ($module_type);
|
||||
}
|
||||
else {
|
||||
$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);
|
||||
$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);
|
||||
$module_type = modules_get_moduletype_name ($id_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;
|
||||
|
||||
// Compressed module data
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Get previous data
|
||||
$previous_data = modules_get_previous_data ($agent_module_id, $datelimit);
|
||||
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)) {
|
||||
if ($data[$j]['datos'] > $interval_max) {
|
||||
$interval_max = $data[$j]['datos'];
|
||||
} else if ($data[$j]['datos'] < $interval_max) {
|
||||
}
|
||||
else if ($data[$j]['datos'] < $interval_max) {
|
||||
$interval_min = $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];
|
||||
|
||||
$previous_data = $total;
|
||||
// Compressed data
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Compressed data
|
||||
if ($uncompressed_module || ($timestamp > time ())) {
|
||||
//$graph_values[$i][$timestamp] = 0;
|
||||
$temp_graph_values[$timestamp_short] = 0;
|
||||
|
@ -728,12 +758,12 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
|
||||
// Added to support projection graphs
|
||||
if ($projection != false and $i != 0) {
|
||||
$projection_data = array();
|
||||
$projection_data = array_merge($before_projection, $projection);
|
||||
$graph_values[$i] = $projection_data;
|
||||
$projection_data = array();
|
||||
$projection_data = array_merge($before_projection, $projection);
|
||||
$graph_values[$i] = $projection_data;
|
||||
}
|
||||
else {
|
||||
$graph_values[$i] = $temp_graph_values;
|
||||
$graph_values[$i] = $temp_graph_values;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,7 +788,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
//unset($graph_values[$i]);
|
||||
|
||||
//$graph_values[$i] = $graph_values[$i];
|
||||
|
||||
}
|
||||
$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",
|
||||
'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) {
|
||||
case GRAPH_AREA:
|
||||
$color = null;
|
||||
return area_graph($flash_charts, $graph_values, $width, $height,
|
||||
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
|
||||
"", "", $homeurl, $water_mark,
|
||||
$config['fontpath'], $config['font_size'], "", $ttl);
|
||||
$config['fontpath'], $fixed_font_size, "", $ttl);
|
||||
break;
|
||||
default:
|
||||
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,
|
||||
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
|
||||
"", "", $water_mark,
|
||||
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl);
|
||||
$config['fontpath'], $fixed_font_size, "", $ttl, $homeurl);
|
||||
break;
|
||||
case GRAPH_LINE:
|
||||
$color = null;
|
||||
return line_graph($flash_charts, $graph_values, $width, $height,
|
||||
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
|
||||
"", "", $water_mark,
|
||||
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl);
|
||||
$config['fontpath'], $fixed_font_size, "", $ttl, $homeurl);
|
||||
break;
|
||||
case GRAPH_STACKED_LINE:
|
||||
$color = null;
|
||||
return stacked_line_graph($flash_charts, $graph_values, $width, $height,
|
||||
$color, $module_name_list, $long_index, $homeurl."images/image_problem.opaque.png",
|
||||
"", "", $water_mark,
|
||||
$config['fontpath'], $config['font_size'], "", $ttl, $homeurl);
|
||||
$config['fontpath'], $fixed_font_size, "", $ttl, $homeurl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue