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
2fbb104851
commit
684d204b39
|
@ -196,23 +196,18 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
||||||
|
|
||||||
// Set the title and time format
|
// Set the title and time format
|
||||||
if ($period <= 21600) {
|
if ($period <= 21600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'H:i:s';
|
$time_format = 'H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period < 86400) {
|
elseif ($period < 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'H:i';
|
$time_format = 'H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 1296000) {
|
elseif ($period < 1296000) {
|
||||||
$title_period = __('Last week');
|
|
||||||
$time_format = 'M d H:i';
|
$time_format = 'M d H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 2592000) {
|
elseif ($period < 2592000) {
|
||||||
$title_period = __('Last month');
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
||||||
$time_format = 'M d H\h';
|
$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);
|
$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
|
* Produces a combined/user defined graph
|
||||||
*
|
*
|
||||||
|
@ -378,27 +389,25 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
global $graphic_type;
|
||||||
|
|
||||||
|
$time_format_2 = '';
|
||||||
|
|
||||||
// Set the title and time format
|
// Set the title and time format
|
||||||
if ($period <= 21600) {
|
if ($period <= 21600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'H:i:s';
|
$time_format = 'H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period < 86400) {
|
elseif ($period < 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'H:i';
|
$time_format = 'H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 1296000) {
|
elseif ($period < 1296000) {
|
||||||
$title_period = __('Last week');
|
$time_format = 'M d';
|
||||||
$time_format = 'M d H:i';
|
$time_format_2 = 'H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 2592000) {
|
elseif ($period <= 2592000) {
|
||||||
$title_period = __('Last month');
|
$time_format = 'M d';
|
||||||
$time_format = 'M d H\h';
|
$time_format_2 = 'H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
$time_format = 'M d';
|
||||||
$time_format = 'M d H\h';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
|
@ -412,7 +421,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
||||||
$j = $datelimit;
|
$j = $datelimit;
|
||||||
$in_range = true;
|
$in_range = true;
|
||||||
while ($in_range){
|
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);
|
//$timestamp_f = date('d M Y H:i:s', $j);
|
||||||
$before_projection[$timestamp_f] = 0;
|
$before_projection[$timestamp_f] = 0;
|
||||||
|
|
||||||
|
@ -433,7 +443,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
||||||
// interval - This is the number of "rows" we are divided the time to fill data.
|
// 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
|
// periodo - Gap of time, in seconds. This is now to (now-periodo) secs
|
||||||
|
|
||||||
// Init weights
|
// Init weights
|
||||||
for ($i = 0; $i < $module_number; $i++) {
|
for ($i = 0; $i < $module_number; $i++) {
|
||||||
if (! isset ($weight_list[$i])) {
|
if (! isset ($weight_list[$i])) {
|
||||||
|
@ -461,28 +471,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
||||||
}
|
}
|
||||||
|
|
||||||
$long_index = array();
|
$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();
|
$graph_values = array();
|
||||||
$module_name_list = array();
|
$module_name_list = array();
|
||||||
|
@ -603,7 +591,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
||||||
$countAvg ++;
|
$countAvg ++;
|
||||||
|
|
||||||
$timestamp = $datelimit + ($interval * $l);
|
$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(
|
$long_index[$timestamp_short] = date(
|
||||||
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
||||||
//$timestamp = $timestamp_short;
|
//$timestamp = $timestamp_short;
|
||||||
|
@ -725,28 +714,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'];
|
$flash_charts = $config['flash_charts'];
|
||||||
|
|
||||||
|
@ -755,10 +722,6 @@ function graphic_combined_module ($module_list, $weight_list, $period, $width, $
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($flash_charts){
|
|
||||||
include_flash_chart_script();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($flash_charts){
|
if ($flash_charts){
|
||||||
include_flash_chart_script();
|
include_flash_chart_script();
|
||||||
}
|
}
|
||||||
|
@ -1808,23 +1771,18 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
||||||
|
|
||||||
// Set the title and time format
|
// Set the title and time format
|
||||||
if ($period <= 21600) {
|
if ($period <= 21600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'H:i:s';
|
$time_format = 'H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period < 86400) {
|
elseif ($period < 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'H:i';
|
$time_format = 'H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 1296000) {
|
elseif ($period < 1296000) {
|
||||||
$title_period = __('Last week');
|
|
||||||
$time_format = 'M d H:i';
|
$time_format = 'M d H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 2592000) {
|
elseif ($period < 2592000) {
|
||||||
$title_period = __('Last month');
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
||||||
$time_format = 'M d H\h';
|
$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
|
// Set the title and time format
|
||||||
if ($period <= 21600) {
|
if ($period <= 21600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'H:i:s';
|
$time_format = 'H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period < 86400) {
|
elseif ($period < 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'H:i';
|
$time_format = 'H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 1296000) {
|
elseif ($period < 1296000) {
|
||||||
$title_period = __('Last week');
|
|
||||||
$time_format = 'M d H:i';
|
$time_format = 'M d H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 2592000) {
|
elseif ($period < 2592000) {
|
||||||
$title_period = __('Last month');
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1989,23 +1942,18 @@ echo"<h4>Gráfica de área</h4>";
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Set the title and time format
|
// Set the title and time format
|
||||||
if ($period <= 3600) {
|
if ($period <= 3600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'G:i:s';
|
$time_format = 'G:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period <= 86400) {
|
elseif ($period <= 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'G:i:s';
|
$time_format = 'G:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period <= 604800) {
|
elseif ($period <= 604800) {
|
||||||
$title_period = __('Last week');
|
|
||||||
$time_format = 'M d H:i:s';
|
$time_format = 'M d H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period <= 2419200) {
|
elseif ($period <= 2419200) {
|
||||||
$title_period = __('Last month');
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
$timestamp_short = date($time_format, $date);
|
$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
|
// Set the title and time format
|
||||||
if ($period <= 3600) {
|
if ($period <= 3600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'G:i:s';
|
$time_format = 'G:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period <= 86400) {
|
elseif ($period <= 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'G:i:s';
|
$time_format = 'G:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period <= 604800) {
|
elseif ($period <= 604800) {
|
||||||
$title_period = __('Last week');
|
|
||||||
$time_format = 'M d H:i:s';
|
$time_format = 'M d H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period <= 2419200) {
|
elseif ($period <= 2419200) {
|
||||||
$title_period = __('Last month');
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
$timestamp_short = date($time_format, $date);
|
$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
|
// Set the title and time format
|
||||||
if ($period <= 21600) {
|
if ($period <= 21600) {
|
||||||
$title_period = __('Last hour');
|
|
||||||
$time_format = 'H:i:s';
|
$time_format = 'H:i:s';
|
||||||
}
|
}
|
||||||
elseif ($period < 86400) {
|
elseif ($period < 86400) {
|
||||||
$title_period = __('Last day');
|
|
||||||
$time_format = 'H:i';
|
$time_format = 'H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 1296000) {
|
elseif ($period < 1296000) {
|
||||||
$title_period = __('Last week');
|
|
||||||
$time_format = 'M d H:i';
|
$time_format = 'M d H:i';
|
||||||
}
|
}
|
||||||
elseif ($period < 2592000) {
|
elseif ($period < 2592000) {
|
||||||
$title_period = __('Last month');
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
||||||
$time_format = 'M d H\h';
|
$time_format = 'M d H\h';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2507,302 +2445,296 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
||||||
|
|
||||||
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
||||||
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0,
|
$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;'>");
|
grafico_modulo_log4x_trace("<pre style='text-align:left;'>");
|
||||||
|
|
||||||
if ($date == "")
|
if ($date == "")
|
||||||
$now = time ();
|
$now = time ();
|
||||||
else
|
else
|
||||||
$now = $date;
|
$now = $date;
|
||||||
|
|
||||||
$fechatope = $now - $periodo; // limit date
|
$fechatope = $now - $periodo; // limit date
|
||||||
|
|
||||||
$nombre_agente = modules_get_agentmodule_agent_name ($id_agente_modulo);
|
$nombre_agente = modules_get_agentmodule_agent_name ($id_agente_modulo);
|
||||||
$nombre_modulo = modules_get_agentmodule_name ($id_agente_modulo);
|
$nombre_modulo = modules_get_agentmodule_name ($id_agente_modulo);
|
||||||
$id_agente = agents_get_agent_id ($nombre_agente);
|
$id_agente = agents_get_agent_id ($nombre_agente);
|
||||||
|
|
||||||
|
$one_second = 1;
|
||||||
|
$one_minute = 60 * $one_second;
|
||||||
|
$one_hour = 60 * $one_minute;
|
||||||
|
$one_day = 24 * $one_hour;
|
||||||
|
$one_week = 7 * $one_day;
|
||||||
|
|
||||||
$one_second = 1;
|
$adjust_time = $one_minute; // 60 secs
|
||||||
$one_minute = 60 * $one_second;
|
|
||||||
$one_hour = 60 * $one_minute;
|
|
||||||
$one_day = 24 * $one_hour;
|
|
||||||
$one_week = 7 * $one_day;
|
|
||||||
|
|
||||||
$adjust_time = $one_minute; // 60 secs
|
if ($periodo == 86400) // day
|
||||||
|
$adjust_time = $one_hour;
|
||||||
|
elseif ($periodo == 604800) // week
|
||||||
|
$adjust_time =$one_day;
|
||||||
|
elseif ($periodo == 3600) // hour
|
||||||
|
$adjust_time = 10 * $one_minute;
|
||||||
|
elseif ($periodo == 2419200) // month
|
||||||
|
$adjust_time = $one_week;
|
||||||
|
else
|
||||||
|
$adjust_time = $periodo / 12.0;
|
||||||
|
|
||||||
if ($periodo == 86400) // day
|
$num_slices = $periodo / $adjust_time;
|
||||||
$adjust_time = $one_hour;
|
|
||||||
elseif ($periodo == 604800) // week
|
|
||||||
$adjust_time =$one_day;
|
|
||||||
elseif ($periodo == 3600) // hour
|
|
||||||
$adjust_time = 10 * $one_minute;
|
|
||||||
elseif ($periodo == 2419200) // month
|
|
||||||
$adjust_time = $one_week;
|
|
||||||
else
|
|
||||||
$adjust_time = $periodo / 12.0;
|
|
||||||
|
|
||||||
$num_slices = $periodo / $adjust_time;
|
$fechatope_index = grafico_modulo_log4x_index($fechatope, $adjust_time);
|
||||||
|
|
||||||
$fechatope_index = grafico_modulo_log4x_index($fechatope, $adjust_time);
|
$sql1="SELECT utimestamp, SEVERITY " .
|
||||||
|
" FROM tagente_datos_log4x " .
|
||||||
|
" WHERE id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope and utimestamp < $now";
|
||||||
|
|
||||||
$sql1="SELECT utimestamp, SEVERITY " .
|
$valores = array();
|
||||||
" FROM tagente_datos_log4x " .
|
|
||||||
" WHERE id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope and utimestamp < $now";
|
|
||||||
|
|
||||||
$valores = array();
|
$max_count = -1;
|
||||||
|
$min_count = 9999999;
|
||||||
|
|
||||||
$max_count = -1;
|
grafico_modulo_log4x_trace("$sql1");
|
||||||
$min_count = 9999999;
|
|
||||||
|
|
||||||
grafico_modulo_log4x_trace("$sql1");
|
$rows = 0;
|
||||||
|
|
||||||
|
$first = true;
|
||||||
|
while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)){
|
||||||
|
$first = false;
|
||||||
|
|
||||||
|
$rows++;
|
||||||
|
$utimestamp = $row[0];
|
||||||
|
$severity = $row[1];
|
||||||
|
$severity_num = $row[2];
|
||||||
|
|
||||||
$rows = 0;
|
if (!isset($valores[$severity]))
|
||||||
|
$valores[$severity] = array();
|
||||||
$first = true;
|
|
||||||
while ($row = get_db_all_row_by_steps_sql($first, $result, $sql1)){
|
|
||||||
$first = false;
|
|
||||||
|
|
||||||
$rows++;
|
|
||||||
$utimestamp = $row[0];
|
|
||||||
$severity = $row[1];
|
|
||||||
$severity_num = $row[2];
|
|
||||||
|
|
||||||
if (!isset($valores[$severity]))
|
$dest = grafico_modulo_log4x_index($utimestamp, $adjust_time);
|
||||||
$valores[$severity] = array();
|
|
||||||
|
|
||||||
$dest = grafico_modulo_log4x_index($utimestamp, $adjust_time);
|
$index = (($dest - $fechatope_index) / $adjust_time) - 1;
|
||||||
|
|
||||||
$index = (($dest - $fechatope_index) / $adjust_time) - 1;
|
if (!isset($valores[$severity][$index])) {
|
||||||
|
$valores[$severity][$index] = array();
|
||||||
|
$valores[$severity][$index]['pivot'] = $dest;
|
||||||
|
$valores[$severity][$index]['count'] = 0;
|
||||||
|
$valores[$severity][$index]['alerts'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($valores[$severity][$index])) {
|
$valores[$severity][$index]['count']++;
|
||||||
$valores[$severity][$index] = array();
|
|
||||||
$valores[$severity][$index]['pivot'] = $dest;
|
|
||||||
$valores[$severity][$index]['count'] = 0;
|
|
||||||
$valores[$severity][$index]['alerts'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$valores[$severity][$index]['count']++;
|
$max_count = max($max_count, $valores[$severity][$index]['count']);
|
||||||
|
$min_count = min($min_count, $valores[$severity][$index]['count']);
|
||||||
|
}
|
||||||
|
|
||||||
$max_count = max($max_count, $valores[$severity][$index]['count']);
|
grafico_modulo_log4x_trace("$rows rows");
|
||||||
$min_count = min($min_count, $valores[$severity][$index]['count']);
|
|
||||||
}
|
|
||||||
|
|
||||||
grafico_modulo_log4x_trace("$rows rows");
|
// Create graph
|
||||||
|
// *************
|
||||||
|
|
||||||
// Create graph
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
// *************
|
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
|
||||||
|
|
||||||
//set_error_handler("myErrorHandler");
|
//set_error_handler("myErrorHandler");
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . "/../../include");
|
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . "/../../include");
|
||||||
|
|
||||||
require_once 'Image/Graph.php';
|
require_once 'Image/Graph.php';
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
|
|
||||||
$Graph =& Image_Graph::factory('graph', array($width, $height));
|
$Graph =& Image_Graph::factory('graph', array($width, $height));
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
|
||||||
|
|
||||||
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
|
|
||||||
|
// add a TrueType font
|
||||||
|
$Font =& $Graph->addNew('font', $config['fontpath']); // C:\WINNT\Fonts\ARIAL.TTF
|
||||||
|
$Font->setSize(7);
|
||||||
|
|
||||||
|
$Graph->setFont($Font);
|
||||||
|
|
||||||
|
if ($periodo == 86400)
|
||||||
|
$title_period = $lang_label["last_day"];
|
||||||
|
elseif ($periodo == 604800)
|
||||||
|
$title_period = $lang_label["last_week"];
|
||||||
|
elseif ($periodo == 3600)
|
||||||
|
$title_period = $lang_label["last_hour"];
|
||||||
|
elseif ($periodo == 2419200)
|
||||||
|
$title_period = $lang_label["last_month"];
|
||||||
|
else {
|
||||||
|
$suffix = $lang_label["days"];
|
||||||
|
$graph_extension = $periodo / (3600*24); // in days
|
||||||
|
|
||||||
// add a TrueType font
|
if ($graph_extension < 1) {
|
||||||
$Font =& $Graph->addNew('font', $config['fontpath']); // C:\WINNT\Fonts\ARIAL.TTF
|
$graph_extension = $periodo / (3600); // in hours
|
||||||
$Font->setSize(7);
|
$suffix = $lang_label["hours"];
|
||||||
|
}
|
||||||
|
//$title_period = "Last ";
|
||||||
|
$title_period = format_numeric($graph_extension,2)." $suffix";
|
||||||
|
}
|
||||||
|
|
||||||
$Graph->setFont($Font);
|
$title_period = html_entity_decode($title_period);
|
||||||
|
|
||||||
if ($periodo == 86400)
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
$title_period = $lang_label["last_day"];
|
|
||||||
elseif ($periodo == 604800)
|
|
||||||
$title_period = $lang_label["last_week"];
|
|
||||||
elseif ($periodo == 3600)
|
|
||||||
$title_period = $lang_label["last_hour"];
|
|
||||||
elseif ($periodo == 2419200)
|
|
||||||
$title_period = $lang_label["last_month"];
|
|
||||||
else {
|
|
||||||
$suffix = $lang_label["days"];
|
|
||||||
$graph_extension = $periodo / (3600*24); // in days
|
|
||||||
|
|
||||||
if ($graph_extension < 1) {
|
if ($pure == 0){
|
||||||
$graph_extension = $periodo / (3600); // in hours
|
$Graph->add(
|
||||||
$suffix = $lang_label["hours"];
|
Image_Graph::horizontal(
|
||||||
}
|
Image_Graph::vertical(
|
||||||
//$title_period = "Last ";
|
Image_Graph::vertical(
|
||||||
$title_period = format_numeric($graph_extension,2)." $suffix";
|
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - " .$title_period, 10)),
|
||||||
}
|
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
|
||||||
|
90
|
||||||
|
),
|
||||||
|
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')),
|
||||||
|
15 // If you change this, change the 0.85 below
|
||||||
|
),
|
||||||
|
Image_Graph::vertical(
|
||||||
|
$Legend = Image_Graph::factory('legend'),
|
||||||
|
$PlotareaMinMax = Image_Graph::factory('plotarea'),
|
||||||
|
65
|
||||||
|
),
|
||||||
|
85 // If you change this, change the 0.85 below
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$title_period = html_entity_decode($title_period);
|
$Legend->setPlotarea($Plotarea);
|
||||||
|
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
|
||||||
|
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
|
||||||
|
} else { // Pure, without title and legends
|
||||||
|
$Graph->add($Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')));
|
||||||
|
}
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
|
|
||||||
if ($pure == 0){
|
$dataset = array();
|
||||||
$Graph->add(
|
|
||||||
Image_Graph::horizontal(
|
|
||||||
Image_Graph::vertical(
|
|
||||||
Image_Graph::vertical(
|
|
||||||
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - " .$title_period, 10)),
|
|
||||||
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
|
|
||||||
90
|
|
||||||
),
|
|
||||||
$Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')),
|
|
||||||
15 // If you change this, change the 0.85 below
|
|
||||||
),
|
|
||||||
Image_Graph::vertical(
|
|
||||||
$Legend = Image_Graph::factory('legend'),
|
|
||||||
$PlotareaMinMax = Image_Graph::factory('plotarea'),
|
|
||||||
65
|
|
||||||
),
|
|
||||||
85 // If you change this, change the 0.85 below
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$Legend->setPlotarea($Plotarea);
|
$severities = array("FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
|
||||||
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
|
$colors = array("black", "red", "orange", "yellow", "#3300ff", 'magenta');
|
||||||
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
|
|
||||||
} else { // Pure, without title and legends
|
|
||||||
$Graph->add($Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis', 'Image_Graph_Axis')));
|
|
||||||
}
|
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
$max_bubble_radius = $height * 0.6 / (count($severities) + 1); // this is the size for the max_count
|
||||||
|
$y = count($severities) - 1;
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
$dataset = array();
|
foreach($severities as $severity) {
|
||||||
|
$dataset[$i] = Image_Graph::factory('dataset');
|
||||||
|
$dataset[$i]->setName($severity);
|
||||||
|
|
||||||
$severities = array("FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
|
if (isset($valores[$severity])){
|
||||||
$colors = array("black", "red", "orange", "yellow", "#3300ff", 'magenta');
|
$data =& $valores[$severity];
|
||||||
|
while (list($index, $data2) = each($data)) {
|
||||||
|
$count = $data2['count'];
|
||||||
|
$pivot = $data2['pivot'];
|
||||||
|
|
||||||
$max_bubble_radius = $height * 0.6 / (count($severities) + 1); // this is the size for the max_count
|
//$x = $scale * $index;
|
||||||
$y = count($severities) - 1;
|
$x = 100.0 * ($pivot - $fechatope) / ($now - $fechatope);
|
||||||
$i = 0;
|
if ($x > 100) $x = 100;
|
||||||
|
|
||||||
foreach($severities as $severity) {
|
$size = grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius);
|
||||||
$dataset[$i] = Image_Graph::factory('dataset');
|
|
||||||
$dataset[$i]->setName($severity);
|
|
||||||
|
|
||||||
if (isset($valores[$severity])){
|
// pivot is the value in the X axis
|
||||||
$data =& $valores[$severity];
|
// y is the number of steps (from the bottom of the graphics) (zero based)
|
||||||
while (list($index, $data2) = each($data)) {
|
// x is the position of the bubble, in % from the left (0% = full left, 100% = full right)
|
||||||
$count = $data2['count'];
|
// size is the radius of the bubble
|
||||||
$pivot = $data2['pivot'];
|
// value is the value associated with the bubble (needed to calculate the leyend)
|
||||||
|
//
|
||||||
|
$dataset[$i]->addPoint($pivot, $y, array("x" => $x, "size" => $size, "value" => $count));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// There's a problem when we have no data ...
|
||||||
|
// This was the first try.. didnt work
|
||||||
|
//$dataset[$i]->addPoint($now, -1, array("x" => 0, "size" => 0));
|
||||||
|
}
|
||||||
|
|
||||||
//$x = $scale * $index;
|
$y--;
|
||||||
$x = 100.0 * ($pivot - $fechatope) / ($now - $fechatope);
|
$i++;
|
||||||
if ($x > 100) $x = 100;
|
}
|
||||||
|
|
||||||
$size = grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius);
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
|
|
||||||
// pivot is the value in the X axis
|
// create the 1st plot as smoothed area chart using the 1st dataset
|
||||||
// y is the number of steps (from the bottom of the graphics) (zero based)
|
$Plot =& $Plotarea->addNew('bubble', array(&$dataset));
|
||||||
// x is the position of the bubble, in % from the left (0% = full left, 100% = full right)
|
$Plot->setFont($Font);
|
||||||
// size is the radius of the bubble
|
|
||||||
// value is the value associated with the bubble (needed to calculate the leyend)
|
|
||||||
//
|
|
||||||
$dataset[$i]->addPoint($pivot, $y, array("x" => $x, "size" => $size, "value" => $count));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// There's a problem when we have no data ...
|
|
||||||
// This was the first try.. didnt work
|
|
||||||
//$dataset[$i]->addPoint($now, -1, array("x" => 0, "size" => 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$y--;
|
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||||
$i++;
|
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_x_axis'));
|
||||||
}
|
$AxisX->forceMinimum($fechatope);
|
||||||
|
$AxisX->forceMaximum($now);
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
$minIntervalWidth = $Plot->getTextWidth("88/88/8888");
|
||||||
|
$interval_x = $adjust_time;
|
||||||
|
|
||||||
// create the 1st plot as smoothed area chart using the 1st dataset
|
while (true) {
|
||||||
$Plot =& $Plotarea->addNew('bubble', array(&$dataset));
|
$intervalWidth = $width * 0.85 * $interval_x/ $periodo;
|
||||||
$Plot->setFont($Font);
|
if ($intervalWidth >= $minIntervalWidth)
|
||||||
|
break;
|
||||||
|
|
||||||
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
$interval_x *= 2;
|
||||||
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_x_axis'));
|
}
|
||||||
$AxisX->forceMinimum($fechatope);
|
|
||||||
$AxisX->forceMaximum($now);
|
|
||||||
|
|
||||||
$minIntervalWidth = $Plot->getTextWidth("88/88/8888");
|
$AxisX->setLabelInterval($interval_x);
|
||||||
$interval_x = $adjust_time;
|
$AxisX->setLabelOption("showtext",true);
|
||||||
|
|
||||||
while (true) {
|
//*
|
||||||
$intervalWidth = $width * 0.85 * $interval_x/ $periodo;
|
$GridY2 =& $Plotarea->addNew('line_grid');
|
||||||
if ($intervalWidth >= $minIntervalWidth)
|
$GridY2->setLineColor('gray');
|
||||||
break;
|
$GridY2->setFillColor('lightgray@0.05');
|
||||||
|
$GridY2->_setPrimaryAxis($AxisX);
|
||||||
|
//$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Dotted', array("white", "gray", "gray", "gray")));
|
||||||
|
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
|
||||||
|
//*/
|
||||||
|
//grafico_modulo_log4x_trace(print_r($AxisX, true));
|
||||||
|
|
||||||
$interval_x *= 2;
|
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||||
}
|
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_y_axis'));
|
||||||
|
$AxisY->setLabelOption("showtext",true);
|
||||||
|
//$AxisY->setLabelInterval(0);
|
||||||
|
//$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
|
||||||
|
|
||||||
$AxisX->setLabelInterval($interval_x);
|
//*
|
||||||
$AxisX->setLabelOption("showtext",true);
|
$GridY2 =& $Plotarea->addNew('line_grid');
|
||||||
|
$GridY2->setLineColor('gray');
|
||||||
|
$GridY2->setFillColor('lightgray@0.05');
|
||||||
|
$GridY2->_setPrimaryAxis($AxisY);
|
||||||
|
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
|
||||||
|
//*/
|
||||||
|
|
||||||
//*
|
$AxisY->forceMinimum(0);
|
||||||
$GridY2 =& $Plotarea->addNew('line_grid');
|
$AxisY->forceMaximum(count($severities) + 1) ;
|
||||||
$GridY2->setLineColor('gray');
|
|
||||||
$GridY2->setFillColor('lightgray@0.05');
|
|
||||||
$GridY2->_setPrimaryAxis($AxisX);
|
|
||||||
//$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Dotted', array("white", "gray", "gray", "gray")));
|
|
||||||
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
|
|
||||||
//*/
|
|
||||||
//grafico_modulo_log4x_trace(print_r($AxisX, true));
|
|
||||||
|
|
||||||
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
// set line colors
|
||||||
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'grafico_modulo_log4x_format_y_axis'));
|
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
||||||
$AxisY->setLabelOption("showtext",true);
|
|
||||||
//$AxisY->setLabelInterval(0);
|
|
||||||
//$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
|
|
||||||
|
|
||||||
//*
|
$Plot->setFillStyle($FillArray);
|
||||||
$GridY2 =& $Plotarea->addNew('line_grid');
|
foreach($colors as $color)
|
||||||
$GridY2->setLineColor('gray');
|
$FillArray->addColor($color);
|
||||||
$GridY2->setFillColor('lightgray@0.05');
|
|
||||||
$GridY2->_setPrimaryAxis($AxisY);
|
|
||||||
$GridY2->setLineStyle(Image_Graph::factory('Image_Graph_Line_Formatted', array(array("transparent", "transparent", "transparent", "gray"))));
|
|
||||||
//*/
|
|
||||||
|
|
||||||
$AxisY->forceMinimum(0);
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
$AxisY->forceMaximum(count($severities) + 1) ;
|
|
||||||
|
|
||||||
// set line colors
|
$FillArray->addColor('green@0.6');
|
||||||
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
//$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||||
|
|
||||||
$Plot->setFillStyle($FillArray);
|
// Show events !
|
||||||
foreach($colors as $color)
|
if ($show_event == 1){
|
||||||
$FillArray->addColor($color);
|
$Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event));
|
||||||
|
$Plot->setLineColor( 'red' );
|
||||||
|
$Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
||||||
|
$Plot->setMarker($Marker_event);
|
||||||
|
$Marker_event->setFillColor( 'red' );
|
||||||
|
$Marker_event->setLineColor( 'red' );
|
||||||
|
$Marker_event->setSize ( 5 );
|
||||||
|
}
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_X);
|
||||||
|
$Axis->Hide();
|
||||||
|
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_Y);
|
||||||
|
$Axis->Hide();
|
||||||
|
|
||||||
$FillArray->addColor('green@0.6');
|
$plotMinMax =& $PlotareaMinMax->addNew('bubble', array(&$dataset, true));
|
||||||
//$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
|
||||||
|
|
||||||
// Show events !
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
if ($show_event == 1){
|
|
||||||
$Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event));
|
|
||||||
$Plot->setLineColor( 'red' );
|
|
||||||
$Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross');
|
|
||||||
$Plot->setMarker($Marker_event);
|
|
||||||
$Marker_event->setFillColor( 'red' );
|
|
||||||
$Marker_event->setLineColor( 'red' );
|
|
||||||
$Marker_event->setSize ( 5 );
|
|
||||||
}
|
|
||||||
|
|
||||||
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_X);
|
$Graph->done();
|
||||||
$Axis->Hide();
|
|
||||||
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_Y);
|
|
||||||
$Axis->Hide();
|
|
||||||
|
|
||||||
$plotMinMax =& $PlotareaMinMax->addNew('bubble', array(&$dataset, true));
|
grafico_modulo_log4x_trace(__LINE__);
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
|
||||||
|
|
||||||
$Graph->done();
|
|
||||||
|
|
||||||
grafico_modulo_log4x_trace(__LINE__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function grafico_modulo_log4x_index($x, $interval)
|
function grafico_modulo_log4x_index($x, $interval)
|
||||||
|
|
|
@ -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,
|
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) {
|
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1) {
|
||||||
|
|
||||||
if (empty($chart_data)) {
|
if (empty($chart_data)) {
|
||||||
|
@ -199,7 +199,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
||||||
}
|
}
|
||||||
|
|
||||||
if($flash_chart) {
|
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 {
|
else {
|
||||||
$graph = array();
|
$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);
|
$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);
|
$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);
|
$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);
|
$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;
|
$step = 1;
|
||||||
if ($force_steps) {
|
if ($force_steps) {
|
||||||
$pixels_between_xdata = 40;
|
$pixels_between_xdata = 50;
|
||||||
$max_xdata_display = round($width / $pixels_between_xdata);
|
$max_xdata_display = round($width / $pixels_between_xdata);
|
||||||
$ndata = count($data);
|
$ndata = count($data);
|
||||||
if($max_xdata_display > $ndata) {
|
if($max_xdata_display > $ndata) {
|
||||||
|
@ -139,7 +139,7 @@ if ($force_steps) {
|
||||||
$step = round($ndata/$xdata_display);
|
$step = round($ndata/$xdata_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
$c = 0;
|
$c = 1;
|
||||||
|
|
||||||
switch($graph_type) {
|
switch($graph_type) {
|
||||||
case 'hbar':
|
case 'hbar':
|
||||||
|
@ -336,8 +336,6 @@ function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colo
|
||||||
$myPicture->drawRoundedFilledRectangle ($i, 0, $ratio+$i,
|
$myPicture->drawRoundedFilledRectangle ($i, 0, $ratio+$i,
|
||||||
$height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
|
$height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
|
||||||
$i+=$ratio;
|
$i+=$ratio;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($round_corner) {
|
if ($round_corner) {
|
||||||
|
@ -408,16 +406,8 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
|
||||||
|
|
||||||
/* Write down the legend next to the 2nd chart*/
|
/* Write down the legend next to the 2nd chart*/
|
||||||
//Calculate the bottom margin from the size of string in each index
|
//Calculate the bottom margin from the size of string in each index
|
||||||
$max_chars = 0;
|
$max_chars = graph_get_max_index($legend_values);
|
||||||
foreach ($legend_values as $string_legend) {
|
$legend_with_aprox = 32 + (7 * $max_chars);
|
||||||
if (empty($string_legend)) continue;
|
|
||||||
|
|
||||||
$len = strlen($string_legend);
|
|
||||||
if ($len > $max_chars) {
|
|
||||||
$max_chars = $len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$legend_with_aprox = 32 + (7 * $max_chars);
|
|
||||||
|
|
||||||
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
|
$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
|
// 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
|
//Calculate the top margin from the size of string in each index
|
||||||
$max_chars = 0;
|
$max_chars = graph_get_max_index($index);
|
||||||
foreach ($index as $string_index) {
|
|
||||||
if (empty($string_index)) continue;
|
|
||||||
|
|
||||||
$len = strlen($string_index);
|
|
||||||
if ($len > $max_chars) {
|
|
||||||
$max_chars = $len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$margin_top = 10 * $max_chars;
|
$margin_top = 10 * $max_chars;
|
||||||
|
|
||||||
switch($graph_type) {
|
switch($graph_type) {
|
||||||
|
@ -640,7 +622,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
else {
|
else {
|
||||||
$point_id = $i;
|
$point_id = $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
$MyData->addPoints($values,$point_id);
|
$MyData->addPoints($values,$point_id);
|
||||||
if (!empty($rgb_color)) {
|
if (!empty($rgb_color)) {
|
||||||
$MyData->setPalette($point_id,
|
$MyData->setPalette($point_id,
|
||||||
|
@ -670,7 +652,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
$MyData->setPalette($point_id, $palette_color);*/
|
$MyData->setPalette($point_id, $palette_color);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$MyData->setSerieWeight($point_id, 1);
|
$MyData->setSerieWeight($point_id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//$MyData->addPoints($data,"Yaxis");
|
//$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
|
//Calculate the bottom margin from the size of string in each index
|
||||||
$max_chars = 0;
|
$max_chars = graph_get_max_index($index);
|
||||||
foreach ($index as $string_index) {
|
|
||||||
if (empty($string_index)) continue;
|
|
||||||
|
|
||||||
$len = strlen($string_index);
|
|
||||||
if ($len > $max_chars) {
|
|
||||||
$max_chars = $len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$margin_bottom = $font_size * $max_chars;
|
$margin_bottom = $font_size * $max_chars;
|
||||||
|
|
||||||
$water_mark_height = 0;
|
$water_mark_height = 0;
|
||||||
|
|
|
@ -113,4 +113,22 @@ function stack_data(&$chart_data, &$legend = null, &$color = null) {
|
||||||
ksort($color);
|
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);
|
$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)){
|
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);
|
$statusCell = ui_print_status_image(STATUS_MODULE_NO_DATA, __('NOT INIT'), true);
|
||||||
|
|
Loading…
Reference in New Issue