column of the global modules search
2011-12-22 Sergio Martin <sergio.martin@artica.es> * include/functions_graph.php: Fixed Date formats in graph axis to avoid loss data * include/functions_custom_graphs.php: Fixed number of hours of a week in the graphs combo git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5298 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
12afb58564
commit
fb977dd4ce
|
@ -196,23 +196,18 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
|
@ -353,6 +348,22 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$config['fontpath'], $config['font_size'], $unit, $ttl);
|
||||
}
|
||||
|
||||
function graph_get_formatted_date($timestamp, $format1, $format2) {
|
||||
global $config;
|
||||
|
||||
if($config['flash_charts']) {
|
||||
$date = date("$format1 $format2", $timestamp);
|
||||
}
|
||||
else {
|
||||
$date = date($format1, $timestamp);
|
||||
if($format2 != '') {
|
||||
$date .= "\n".date($format2, $timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces a combined/user defined graph
|
||||
*
|
||||
|
@ -378,27 +389,25 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$time_format_2 = '';
|
||||
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
$time_format = 'M d';
|
||||
$time_format_2 = 'H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
elseif ($period <= 2592000) {
|
||||
$time_format = 'M d';
|
||||
$time_format_2 = 'H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
$time_format = 'M d';
|
||||
}
|
||||
|
||||
// Set variables
|
||||
|
@ -412,7 +421,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
$j = $datelimit;
|
||||
$in_range = true;
|
||||
while ($in_range){
|
||||
$timestamp_f = date($time_format, $j);
|
||||
$timestamp_f = graph_get_formatted_date($j, $time_format, $time_format_2);
|
||||
|
||||
//$timestamp_f = date('d M Y H:i:s', $j);
|
||||
$before_projection[$timestamp_f] = 0;
|
||||
|
||||
|
@ -462,28 +472,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
|
||||
$long_index = array();
|
||||
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
$graph_values = array();
|
||||
$module_name_list = array();
|
||||
|
||||
|
@ -603,7 +591,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
$countAvg ++;
|
||||
|
||||
$timestamp = $datelimit + ($interval * $l);
|
||||
$timestamp_short = date($time_format, $timestamp);
|
||||
$timestamp_short = graph_get_formatted_date($timestamp, $time_format, $time_format_2);
|
||||
|
||||
$long_index[$timestamp_short] = date(
|
||||
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
||||
//$timestamp = $timestamp_short;
|
||||
|
@ -726,28 +715,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
}
|
||||
*/
|
||||
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
$flash_charts = $config['flash_charts'];
|
||||
|
||||
if ($only_image) {
|
||||
|
@ -755,10 +722,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
|||
}
|
||||
|
||||
|
||||
if ($flash_charts){
|
||||
include_flash_chart_script();
|
||||
}
|
||||
|
||||
if ($flash_charts){
|
||||
include_flash_chart_script();
|
||||
}
|
||||
|
@ -1808,23 +1771,18 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
|
@ -1907,23 +1865,18 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||
///////////////////////////////////////////////////
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
|
@ -1989,23 +1942,18 @@ echo"<h4>Gráfica de área</h4>";
|
|||
/////////////////////////////////////////////////////////////////
|
||||
// Set the title and time format
|
||||
if ($period <= 3600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'G:i:s';
|
||||
}
|
||||
elseif ($period <= 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'G:i:s';
|
||||
}
|
||||
elseif ($period <= 604800) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i:s';
|
||||
}
|
||||
elseif ($period <= 2419200) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
$timestamp_short = date($time_format, $date);
|
||||
|
@ -2109,23 +2057,18 @@ function grafico_netflow_total_area ($data, $period,$width, $height , $title, $u
|
|||
/////////////////////////////////////////////////////////////////
|
||||
// Set the title and time format
|
||||
if ($period <= 3600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'G:i:s';
|
||||
}
|
||||
elseif ($period <= 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'G:i:s';
|
||||
}
|
||||
elseif ($period <= 604800) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i:s';
|
||||
}
|
||||
elseif ($period <= 2419200) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
$timestamp_short = date($time_format, $date);
|
||||
|
@ -2420,23 +2363,18 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||
/////////////////////////////////////////////////////////////////
|
||||
// Set the title and time format
|
||||
if ($period <= 21600) {
|
||||
$title_period = __('Last hour');
|
||||
$time_format = 'H:i:s';
|
||||
}
|
||||
elseif ($period < 86400) {
|
||||
$title_period = __('Last day');
|
||||
$time_format = 'H:i';
|
||||
}
|
||||
elseif ($period < 1296000) {
|
||||
$title_period = __('Last week');
|
||||
$time_format = 'M d H:i';
|
||||
}
|
||||
elseif ($period < 2592000) {
|
||||
$title_period = __('Last month');
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
else {
|
||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
||||
$time_format = 'M d H\h';
|
||||
}
|
||||
|
||||
|
@ -2507,8 +2445,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||
|
||||
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
||||
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0,
|
||||
$date = 0)
|
||||
{
|
||||
$date = 0) {
|
||||
|
||||
grafico_modulo_log4x_trace("<pre style='text-align:left;'>");
|
||||
|
||||
|
@ -2523,7 +2460,6 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
|||
$nombre_modulo = modules_get_agentmodule_name ($id_agente_modulo);
|
||||
$id_agente = agents_get_agent_id ($nombre_agente);
|
||||
|
||||
|
||||
$one_second = 1;
|
||||
$one_minute = 60 * $one_second;
|
||||
$one_hour = 60 * $one_minute;
|
||||
|
@ -2609,10 +2545,6 @@ function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
|||
|
||||
grafico_modulo_log4x_trace(__LINE__);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// add a TrueType font
|
||||
$Font =& $Graph->addNew('font', $config['fontpath']); // C:\WINNT\Fonts\ARIAL.TTF
|
||||
$Font->setSize(7);
|
||||
|
|
|
@ -191,7 +191,7 @@ function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) {
|
|||
}
|
||||
|
||||
function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
||||
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homedir="",
|
||||
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="",
|
||||
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1) {
|
||||
|
||||
if (empty($chart_data)) {
|
||||
|
@ -199,7 +199,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
|||
}
|
||||
|
||||
if($flash_chart) {
|
||||
return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homedir, $unit);
|
||||
return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit);
|
||||
}
|
||||
else {
|
||||
$graph = array();
|
||||
|
@ -216,7 +216,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
|||
|
||||
$id_graph = serialize_in_temp($graph, null, $ttl);
|
||||
|
||||
return "<img src='".$homedir."include/graphs/functions_pchart.php?graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
|
||||
return "<img src='".$homeurl."include/graphs/functions_pchart.php?graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
|
|||
|
||||
$id_graph = serialize_in_temp($graph, null, $ttl);
|
||||
|
||||
return "<img src='" . $homeurl . "/include/graphs/functions_pchart.php?graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
|
||||
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=stacked_area&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
|
|||
|
||||
$id_graph = serialize_in_temp($graph, null, $ttl);
|
||||
|
||||
return "<img src='" . $homeurl . "/include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
|
||||
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
|||
|
||||
$id_graph = serialize_in_temp($graph, null, $ttl);
|
||||
|
||||
return "<img src='" . $homeurl . "/include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
|
||||
return "<img src='" . $homeurl . "include/graphs/functions_pchart.php?graph_type=line&ttl=".$ttl."&id_graph=" . $id_graph . "' />";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ $colors['pep4'] = array('border' => '#000000', 'color' => '#0000ff', 'alpha' =>
|
|||
|
||||
$step = 1;
|
||||
if ($force_steps) {
|
||||
$pixels_between_xdata = 40;
|
||||
$pixels_between_xdata = 50;
|
||||
$max_xdata_display = round($width / $pixels_between_xdata);
|
||||
$ndata = count($data);
|
||||
if($max_xdata_display > $ndata) {
|
||||
|
@ -139,7 +139,7 @@ if ($force_steps) {
|
|||
$step = round($ndata/$xdata_display);
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
$c = 1;
|
||||
|
||||
switch($graph_type) {
|
||||
case 'hbar':
|
||||
|
@ -336,8 +336,6 @@ function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colo
|
|||
$myPicture->drawRoundedFilledRectangle ($i, 0, $ratio+$i,
|
||||
$height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
|
||||
$i+=$ratio;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($round_corner) {
|
||||
|
@ -408,15 +406,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
|
|||
|
||||
/* Write down the legend next to the 2nd chart*/
|
||||
//Calculate the bottom margin from the size of string in each index
|
||||
$max_chars = 0;
|
||||
foreach ($legend_values as $string_legend) {
|
||||
if (empty($string_legend)) continue;
|
||||
|
||||
$len = strlen($string_legend);
|
||||
if ($len > $max_chars) {
|
||||
$max_chars = $len;
|
||||
}
|
||||
}
|
||||
$max_chars = graph_get_max_index($legend_values);
|
||||
$legend_with_aprox = 32 + (7 * $max_chars);
|
||||
|
||||
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
|
||||
|
@ -540,15 +530,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
|
|||
// TODO: AvoidTickWhenEmpty = TRUE When the distance between two ticks will be greater than 50 px
|
||||
|
||||
//Calculate the top margin from the size of string in each index
|
||||
$max_chars = 0;
|
||||
foreach ($index as $string_index) {
|
||||
if (empty($string_index)) continue;
|
||||
|
||||
$len = strlen($string_index);
|
||||
if ($len > $max_chars) {
|
||||
$max_chars = $len;
|
||||
}
|
||||
}
|
||||
$max_chars = graph_get_max_index($index);
|
||||
$margin_top = 10 * $max_chars;
|
||||
|
||||
switch($graph_type) {
|
||||
|
@ -670,7 +652,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
|||
$MyData->setPalette($point_id, $palette_color);*/
|
||||
}
|
||||
|
||||
$MyData->setSerieWeight($point_id, 1);
|
||||
$MyData->setSerieWeight($point_id, 0);
|
||||
}
|
||||
|
||||
//$MyData->addPoints($data,"Yaxis");
|
||||
|
@ -705,15 +687,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
|||
}
|
||||
|
||||
//Calculate the bottom margin from the size of string in each index
|
||||
$max_chars = 0;
|
||||
foreach ($index as $string_index) {
|
||||
if (empty($string_index)) continue;
|
||||
|
||||
$len = strlen($string_index);
|
||||
if ($len > $max_chars) {
|
||||
$max_chars = $len;
|
||||
}
|
||||
}
|
||||
$max_chars = graph_get_max_index($index);
|
||||
$margin_bottom = $font_size * $max_chars;
|
||||
|
||||
$water_mark_height = 0;
|
||||
|
|
|
@ -113,4 +113,22 @@ function stack_data(&$chart_data, &$legend = null, &$color = null) {
|
|||
ksort($color);
|
||||
}
|
||||
}
|
||||
|
||||
function graph_get_max_index($legend_values) {
|
||||
$max_chars = 0;
|
||||
foreach ($legend_values as $string_legend) {
|
||||
if (empty($string_legend)) continue;
|
||||
|
||||
$string_legend = explode("\n",$string_legend);
|
||||
|
||||
foreach($string_legend as $st_lg) {
|
||||
$len = strlen($st_lg);
|
||||
if ($len > $max_chars) {
|
||||
$max_chars = $len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $max_chars;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -204,7 +204,7 @@ else {
|
|||
|
||||
$typeCell = ui_print_moduletype_icon($module["id_tipo_modulo"], true);
|
||||
|
||||
$intervalCell = ($module['module_interval'] == 0) ? $module['agent_interval'] : $module['intervalo'];
|
||||
$intervalCell = modules_get_interval ($module['id_agente_modulo']);
|
||||
|
||||
if($module['utimestamp'] == 0 && (($module['module_type'] < 21 || $module['module_type'] > 23) && $module['module_type'] != 100)){
|
||||
$statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true);
|
||||
|
|
Loading…
Reference in New Issue