|
|
|
@ -630,7 +630,7 @@ function graphic_combined_module2 ($module_list, $weight_list, $period, $width,
|
|
|
|
|
if ($only_image) {
|
|
|
|
|
$flash_charts = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$flash_charts = false;
|
|
|
|
|
switch ($stacked) {
|
|
|
|
|
case GRAPH_AREA:
|
|
|
|
|
$color = null;
|
|
|
|
@ -1421,4 +1421,901 @@ function fs_error_image () {
|
|
|
|
|
|
|
|
|
|
return print_image("images/image_problem.png", true, array("border" => '0'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_boolean2 ($agent_module_id, $period, $show_events,
|
|
|
|
|
$width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0,
|
|
|
|
|
$date = 0, $only_image = false, $homeurl = '') {
|
|
|
|
|
global $config;
|
|
|
|
|
global $graphic_type;
|
|
|
|
|
|
|
|
|
|
include_flash_chart_script($homeurl);
|
|
|
|
|
|
|
|
|
|
// Set variables
|
|
|
|
|
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);
|
|
|
|
|
$agent_name = get_agentmodule_agent_name ($agent_module_id);
|
|
|
|
|
$agent_id = get_agent_id ($agent_name);
|
|
|
|
|
$module_name = get_agentmodule_name ($agent_module_id);
|
|
|
|
|
$id_module_type = get_agentmodule_type ($agent_module_id);
|
|
|
|
|
$module_type = get_moduletype_name ($id_module_type);
|
|
|
|
|
$uncompressed_module = is_module_uncompressed ($module_type);
|
|
|
|
|
if ($uncompressed_module) {
|
|
|
|
|
$avg_only = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get event data (contains alert data too)
|
|
|
|
|
if ($show_events == 1 || $show_alerts == 1) {
|
|
|
|
|
$events = get_db_all_rows_filter ('tevento',
|
|
|
|
|
array ('id_agentmodule' => $agent_module_id,
|
|
|
|
|
"utimestamp > $datelimit",
|
|
|
|
|
"utimestamp < $date",
|
|
|
|
|
'order' => 'utimestamp ASC'),
|
|
|
|
|
array ('evento', 'utimestamp', 'event_type'));
|
|
|
|
|
if ($events === false) {
|
|
|
|
|
$events = array ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get module data
|
|
|
|
|
$data = get_db_all_rows_filter ('tagente_datos',
|
|
|
|
|
array ('id_agente_modulo' => $agent_module_id,
|
|
|
|
|
"utimestamp > $datelimit",
|
|
|
|
|
"utimestamp < $date",
|
|
|
|
|
'order' => 'utimestamp ASC'),
|
|
|
|
|
array ('datos', 'utimestamp'));
|
|
|
|
|
if ($data === false) {
|
|
|
|
|
$data = array ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Uncompressed module data
|
|
|
|
|
if ($uncompressed_module) {
|
|
|
|
|
$min_necessary = 1;
|
|
|
|
|
|
|
|
|
|
// Compressed module data
|
|
|
|
|
} else {
|
|
|
|
|
// Get previous data
|
|
|
|
|
$previous_data = get_previous_data ($agent_module_id, $datelimit);
|
|
|
|
|
if ($previous_data !== false) {
|
|
|
|
|
$previous_data['utimestamp'] = $datelimit;
|
|
|
|
|
array_unshift ($data, $previous_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get next data
|
|
|
|
|
$nextData = get_next_data ($agent_module_id, $date);
|
|
|
|
|
if ($nextData !== false) {
|
|
|
|
|
array_push ($data, $nextData);
|
|
|
|
|
} else if (count ($data) > 0) {
|
|
|
|
|
// Propagate the last known data to the end of the interval
|
|
|
|
|
$nextData = array_pop ($data);
|
|
|
|
|
array_push ($data, $nextData);
|
|
|
|
|
$nextData['utimestamp'] = $date;
|
|
|
|
|
array_push ($data, $nextData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$min_necessary = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check available data
|
|
|
|
|
if (count ($data) < $min_necessary) {
|
|
|
|
|
if (!$graphic_type) {
|
|
|
|
|
return fs_error_image ();
|
|
|
|
|
}
|
|
|
|
|
graphic_error ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Data iterator
|
|
|
|
|
$j = 0;
|
|
|
|
|
|
|
|
|
|
// Event iterator
|
|
|
|
|
$k = 0;
|
|
|
|
|
|
|
|
|
|
// Set initial conditions
|
|
|
|
|
$chart = array();
|
|
|
|
|
if ($data[0]['utimestamp'] == $datelimit) {
|
|
|
|
|
$previous_data = $data[0]['datos'];
|
|
|
|
|
$j++;
|
|
|
|
|
} else {
|
|
|
|
|
$previous_data = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate chart data
|
|
|
|
|
for ($i = 0; $i < $resolution; $i++) {
|
|
|
|
|
$timestamp = $datelimit + ($interval * $i);
|
|
|
|
|
|
|
|
|
|
$zero = 0;
|
|
|
|
|
$total = 0;
|
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
|
|
// Read data that falls in the current interval
|
|
|
|
|
while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] <= ($timestamp + $interval)) {
|
|
|
|
|
if ($data[$j]['datos'] == 0) {
|
|
|
|
|
$zero = 1;
|
|
|
|
|
} else {
|
|
|
|
|
$total += $data[$j]['datos'];
|
|
|
|
|
$count++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$j++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Average
|
|
|
|
|
if ($count > 0) {
|
|
|
|
|
$total /= $count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read events and alerts that fall in the current interval
|
|
|
|
|
$event_value = 0;
|
|
|
|
|
$alert_value = 0;
|
|
|
|
|
while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] < ($timestamp + $interval)) {
|
|
|
|
|
if ($show_events == 1) {
|
|
|
|
|
$event_value++;
|
|
|
|
|
}
|
|
|
|
|
if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') {
|
|
|
|
|
$alert_value++;
|
|
|
|
|
}
|
|
|
|
|
$k++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// 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';
|
|
|
|
|
}
|
|
|
|
|
elseif ($period <= 604800) {
|
|
|
|
|
$title_period = __('Last week');
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
elseif ($period <= 2419200) {
|
|
|
|
|
$title_period = __('Last month');
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Data and zeroes (draw a step)
|
|
|
|
|
if ($zero == 1 && $count > 0) {
|
|
|
|
|
$chart[$timestamp]['sum'] = $total;
|
|
|
|
|
$chart[$timestamp + 1] = array ('sum' => 0,
|
|
|
|
|
//'count' => 0,
|
|
|
|
|
//'timestamp_bottom' => $timestamp,
|
|
|
|
|
//'timestamp_top' => $timestamp + $interval,
|
|
|
|
|
'min' => 0,
|
|
|
|
|
'max' => 0,
|
|
|
|
|
'event' => $event_value,
|
|
|
|
|
'alert' => $alert_value);
|
|
|
|
|
$previous_data = 0;
|
|
|
|
|
// Just zeros
|
|
|
|
|
} else if ($zero == 1) {
|
|
|
|
|
$chart[$timestamp]['sum'] = 0;
|
|
|
|
|
$previous_data = 0;
|
|
|
|
|
// No zeros
|
|
|
|
|
} else if ($count > 0) {
|
|
|
|
|
$chart[$timestamp]['sum'] = $total;
|
|
|
|
|
$previous_data = $total;
|
|
|
|
|
// Compressed data
|
|
|
|
|
} else {
|
|
|
|
|
if ($uncompressed_module || ($timestamp > time ())) {
|
|
|
|
|
$chart[$timestamp]['sum'] = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$chart[$timestamp]['sum'] = $previous_data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//$chart[$timestamp]['count'] = 0;
|
|
|
|
|
//$chart[$timestamp]['timestamp_bottom'] = $timestamp;
|
|
|
|
|
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
|
|
|
|
$chart[$timestamp]['min'] = 0;
|
|
|
|
|
$chart[$timestamp]['max'] = 0;
|
|
|
|
|
if($show_events) {
|
|
|
|
|
$chart[$timestamp]['event'] = $event_value;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
unset($chart[$timestamp]['event']);
|
|
|
|
|
}
|
|
|
|
|
if ($show_alerts) {
|
|
|
|
|
$chart[$timestamp]['alert'] = $alert_value;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
unset($chart[$timestamp]['alert']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get min, max and avg (less efficient but centralized for all modules and reports)
|
|
|
|
|
$min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
|
|
|
|
|
$max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
|
|
|
|
|
$avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
|
|
|
|
|
|
|
|
|
|
// Fix event and alert scale
|
|
|
|
|
$event_max = $max_value * 1.25;
|
|
|
|
|
foreach ($chart as $timestamp => $chart_data) {
|
|
|
|
|
if($show_events) {
|
|
|
|
|
if ($chart_data['event'] > 0) {
|
|
|
|
|
$chart[$timestamp]['event'] = $event_max;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($show_alerts) {
|
|
|
|
|
if ($chart_data['alert'] > 0) {
|
|
|
|
|
$chart[$timestamp]['alert'] = $event_max;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
|
// 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';
|
|
|
|
|
}
|
|
|
|
|
elseif ($period <= 604800) {
|
|
|
|
|
$title_period = __('Last week');
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
elseif ($period <= 2419200) {
|
|
|
|
|
$title_period = __('Last month');
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Flash chart
|
|
|
|
|
$caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') .
|
|
|
|
|
': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value;
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
$legend = array();
|
|
|
|
|
$legend['sum'] = __('Avg') . ' (' . $avg_value . ')';
|
|
|
|
|
if($show_events) {
|
|
|
|
|
$legend['event'] = __('Events');
|
|
|
|
|
}
|
|
|
|
|
if($show_alerts) {
|
|
|
|
|
$legend['alert'] = __('Alerts');
|
|
|
|
|
}
|
|
|
|
|
$legend['max'] = __('Max') . ' (' .format_for_graph($max_value) . ')';
|
|
|
|
|
$legend['min'] = __('Min') . ' (' . format_for_graph($min_value) . ')';
|
|
|
|
|
$legend['baseline'] = __('Baseline');
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
$color = array();
|
|
|
|
|
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
|
|
|
|
if($show_events) {
|
|
|
|
|
$color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
|
|
|
|
}
|
|
|
|
|
if($show_alerts) {
|
|
|
|
|
$color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
|
|
|
|
}
|
|
|
|
|
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
|
|
|
|
|
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
|
|
|
|
|
$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$flash_chart = $config['flash_charts'];
|
|
|
|
|
if ($only_image) {
|
|
|
|
|
$flash_chart = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
|
|
|
|
|
$long_index, "images/image_problem.opaque.png", "", "", $homeurl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw a graph of Module string data of agent
|
|
|
|
|
*
|
|
|
|
|
* @param integer id_agent_modulo Agent Module ID
|
|
|
|
|
* @param integer show_event show event (1 or 0)
|
|
|
|
|
* @param integer height graph height
|
|
|
|
|
* @param integer width graph width
|
|
|
|
|
* @param string title graph title
|
|
|
|
|
* @param string unit_name String of unit name
|
|
|
|
|
* @param integer show alerts (1 or 0)
|
|
|
|
|
* @param integer avg_only calcules avg only (1 or 0)
|
|
|
|
|
* @param integer pure Fullscreen (1 or 0)
|
|
|
|
|
* @param integer date date
|
|
|
|
|
*/
|
|
|
|
|
function grafico_modulo_string2 ($agent_module_id, $period, $show_events,
|
|
|
|
|
$width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0,
|
|
|
|
|
$date = 0, $only_image = false, $homeurl = '') {
|
|
|
|
|
global $config;
|
|
|
|
|
global $graphic_type;
|
|
|
|
|
|
|
|
|
|
include_flash_chart_script($homeurl);
|
|
|
|
|
|
|
|
|
|
// Set variables
|
|
|
|
|
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);
|
|
|
|
|
$agent_name = get_agentmodule_agent_name ($agent_module_id);
|
|
|
|
|
$agent_id = get_agent_id ($agent_name);
|
|
|
|
|
$module_name = get_agentmodule_name ($agent_module_id);
|
|
|
|
|
$id_module_type = get_agentmodule_type ($agent_module_id);
|
|
|
|
|
$module_type = get_moduletype_name ($id_module_type);
|
|
|
|
|
$uncompressed_module = is_module_uncompressed ($module_type);
|
|
|
|
|
if ($uncompressed_module) {
|
|
|
|
|
$avg_only = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get event data (contains alert data too)
|
|
|
|
|
if ($show_events == 1 || $show_alerts == 1) {
|
|
|
|
|
$events = get_db_all_rows_filter ('tevento',
|
|
|
|
|
array ('id_agentmodule' => $agent_module_id,
|
|
|
|
|
"utimestamp > $datelimit",
|
|
|
|
|
"utimestamp < $date",
|
|
|
|
|
'order' => 'utimestamp ASC'),
|
|
|
|
|
array ('evento', 'utimestamp', 'event_type'));
|
|
|
|
|
if ($events === false) {
|
|
|
|
|
$events = array ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get module data
|
|
|
|
|
$data = get_db_all_rows_filter ('tagente_datos_string',
|
|
|
|
|
array ('id_agente_modulo' => $agent_module_id,
|
|
|
|
|
"utimestamp > $datelimit",
|
|
|
|
|
"utimestamp < $date",
|
|
|
|
|
'order' => 'utimestamp ASC'),
|
|
|
|
|
array ('datos', 'utimestamp'));
|
|
|
|
|
if ($data === false) {
|
|
|
|
|
$data = array ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Uncompressed module data
|
|
|
|
|
if ($uncompressed_module) {
|
|
|
|
|
$min_necessary = 1;
|
|
|
|
|
|
|
|
|
|
// Compressed module data
|
|
|
|
|
} else {
|
|
|
|
|
// Get previous data
|
|
|
|
|
$previous_data = get_previous_data ($agent_module_id, $datelimit, 1);
|
|
|
|
|
if ($previous_data !== false) {
|
|
|
|
|
$previous_data['utimestamp'] = $datelimit;
|
|
|
|
|
array_unshift ($data, $previous_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get next data
|
|
|
|
|
$nextData = get_next_data ($agent_module_id, $date, 1);
|
|
|
|
|
if ($nextData !== false) {
|
|
|
|
|
array_push ($data, $nextData);
|
|
|
|
|
} else if (count ($data) > 0) {
|
|
|
|
|
// Propagate the last known data to the end of the interval
|
|
|
|
|
$nextData = array_pop ($data);
|
|
|
|
|
array_push ($data, $nextData);
|
|
|
|
|
$nextData['utimestamp'] = $date;
|
|
|
|
|
array_push ($data, $nextData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$min_necessary = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check available data
|
|
|
|
|
if (count ($data) < $min_necessary) {
|
|
|
|
|
if (!$graphic_type) {
|
|
|
|
|
return fs_error_image ();
|
|
|
|
|
}
|
|
|
|
|
graphic_error ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Data iterator
|
|
|
|
|
$j = 0;
|
|
|
|
|
|
|
|
|
|
// Event iterator
|
|
|
|
|
$k = 0;
|
|
|
|
|
|
|
|
|
|
// Set initial conditions
|
|
|
|
|
$chart = array();
|
|
|
|
|
if ($data[0]['utimestamp'] == $datelimit) {
|
|
|
|
|
$previous_data = 1;
|
|
|
|
|
$j++;
|
|
|
|
|
} else {
|
|
|
|
|
$previous_data = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate chart data
|
|
|
|
|
for ($i = 0; $i < $resolution; $i++) {
|
|
|
|
|
$timestamp = $datelimit + ($interval * $i);
|
|
|
|
|
|
|
|
|
|
$count = 0;
|
|
|
|
|
$total = 0;
|
|
|
|
|
// Read data that falls in the current interval
|
|
|
|
|
while (isset ($data[$j]) !== null && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] <= ($timestamp + $interval)) {
|
|
|
|
|
$count++;
|
|
|
|
|
$j++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read events and alerts that fall in the current interval
|
|
|
|
|
$event_value = 0;
|
|
|
|
|
$alert_value = 0;
|
|
|
|
|
while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) {
|
|
|
|
|
if ($show_events == 1) {
|
|
|
|
|
$event_value++;
|
|
|
|
|
}
|
|
|
|
|
if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') {
|
|
|
|
|
$alert_value++;
|
|
|
|
|
}
|
|
|
|
|
$k++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
// 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';
|
|
|
|
|
}
|
|
|
|
|
elseif ($period <= 604800) {
|
|
|
|
|
$title_period = __('Last week');
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
elseif ($period <= 2419200) {
|
|
|
|
|
$title_period = __('Last month');
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$title_period = __('Last %s days', format_numeric (($period / (3600 * 24)), 2));
|
|
|
|
|
$time_format = 'M j';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Data in the interval
|
|
|
|
|
if ($count > 0) {
|
|
|
|
|
$chart[$timestamp]['sum'] = $count;
|
|
|
|
|
$previous_data = $total;
|
|
|
|
|
// Compressed data
|
|
|
|
|
} else {
|
|
|
|
|
$chart[$timestamp]['sum'] = $previous_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//$chart[$timestamp]['count'] = 0;
|
|
|
|
|
//$chart[$timestamp]['timestamp_bottom'] = $timestamp;
|
|
|
|
|
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
|
|
|
|
$chart[$timestamp]['min'] = 0;
|
|
|
|
|
$chart[$timestamp]['max'] = 0;
|
|
|
|
|
$chart[$timestamp]['event'] = $event_value;
|
|
|
|
|
$chart[$timestamp]['alert'] = $alert_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get min, max and avg (less efficient but centralized for all modules and reports)
|
|
|
|
|
$min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
|
|
|
|
|
$max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
|
|
|
|
|
$avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
|
|
|
|
|
|
|
|
|
|
// Fix event and alert scale
|
|
|
|
|
$event_max = $max_value * 1.25;
|
|
|
|
|
foreach ($chart as $timestamp => $chart_data) {
|
|
|
|
|
if ($chart_data['event'] > 0) {
|
|
|
|
|
$chart[$timestamp]['event'] = $event_max;
|
|
|
|
|
}
|
|
|
|
|
if ($chart_data['alert'] > 0) {
|
|
|
|
|
$chart[$timestamp]['alert'] = $event_max;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
$color = array();
|
|
|
|
|
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
|
|
|
|
if($show_events) {
|
|
|
|
|
$color['event'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
|
|
|
|
}
|
|
|
|
|
if($show_alerts) {
|
|
|
|
|
$color['alert'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
|
|
|
|
}
|
|
|
|
|
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
|
|
|
|
|
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
|
|
|
|
|
//$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
$flash_chart = $config['flash_charts'];
|
|
|
|
|
if ($only_image) {
|
|
|
|
|
$flash_chart = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$legend = null;
|
|
|
|
|
|
|
|
|
|
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
|
|
|
|
|
$long_index, "images/image_problem.opaque.png", "", "", $homeurl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_log4x_2 ($id_agente_modulo, $periodo, $show_event,
|
|
|
|
|
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0,
|
|
|
|
|
$date = 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace("<pre style='text-align:left;'>");
|
|
|
|
|
|
|
|
|
|
if ($date == "")
|
|
|
|
|
$now = time ();
|
|
|
|
|
else
|
|
|
|
|
$now = $date;
|
|
|
|
|
|
|
|
|
|
$fechatope = $now - $periodo; // limit date
|
|
|
|
|
|
|
|
|
|
$nombre_agente = get_agentmodule_agent_name ($id_agente_modulo);
|
|
|
|
|
$nombre_modulo = get_agentmodule_name ($id_agente_modulo);
|
|
|
|
|
$id_agente = 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;
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
|
|
$num_slices = $periodo / $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";
|
|
|
|
|
|
|
|
|
|
$valores = array();
|
|
|
|
|
|
|
|
|
|
$max_count = -1;
|
|
|
|
|
$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];
|
|
|
|
|
|
|
|
|
|
if (!isset($valores[$severity]))
|
|
|
|
|
$valores[$severity] = array();
|
|
|
|
|
|
|
|
|
|
$dest = grafico_modulo_log4x_index($utimestamp, $adjust_time);
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$valores[$severity][$index]['count']++;
|
|
|
|
|
|
|
|
|
|
$max_count = max($max_count, $valores[$severity][$index]['count']);
|
|
|
|
|
$min_count = min($min_count, $valores[$severity][$index]['count']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace("$rows rows");
|
|
|
|
|
|
|
|
|
|
// Create graph
|
|
|
|
|
// *************
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
|
|
|
|
|
//set_error_handler("myErrorHandler");
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
set_include_path(get_include_path() . PATH_SEPARATOR . getcwd() . "/../../include");
|
|
|
|
|
|
|
|
|
|
require_once 'Image/Graph.php';
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
|
|
|
|
|
$Graph =& Image_Graph::factory('graph', array($width, $height));
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
if ($graph_extension < 1) {
|
|
|
|
|
$graph_extension = $periodo / (3600); // in hours
|
|
|
|
|
$suffix = $lang_label["hours"];
|
|
|
|
|
}
|
|
|
|
|
//$title_period = "Last ";
|
|
|
|
|
$title_period = format_numeric($graph_extension,2)." $suffix";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$title_period = html_entity_decode($title_period);
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
|
|
|
|
|
if ($pure == 0){
|
|
|
|
|
$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);
|
|
|
|
|
$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__);
|
|
|
|
|
|
|
|
|
|
$dataset = array();
|
|
|
|
|
|
|
|
|
|
$severities = array("FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
|
|
|
|
|
$colors = array("black", "red", "orange", "yellow", "#3300ff", 'magenta');
|
|
|
|
|
|
|
|
|
|
$max_bubble_radius = $height * 0.6 / (count($severities) + 1); // this is the size for the max_count
|
|
|
|
|
$y = count($severities) - 1;
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
foreach($severities as $severity) {
|
|
|
|
|
$dataset[$i] = Image_Graph::factory('dataset');
|
|
|
|
|
$dataset[$i]->setName($severity);
|
|
|
|
|
|
|
|
|
|
if (isset($valores[$severity])){
|
|
|
|
|
$data =& $valores[$severity];
|
|
|
|
|
while (list($index, $data2) = each($data)) {
|
|
|
|
|
$count = $data2['count'];
|
|
|
|
|
$pivot = $data2['pivot'];
|
|
|
|
|
|
|
|
|
|
//$x = $scale * $index;
|
|
|
|
|
$x = 100.0 * ($pivot - $fechatope) / ($now - $fechatope);
|
|
|
|
|
if ($x > 100) $x = 100;
|
|
|
|
|
|
|
|
|
|
$size = grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius);
|
|
|
|
|
|
|
|
|
|
// pivot is the value in the X axis
|
|
|
|
|
// y is the number of steps (from the bottom of the graphics) (zero based)
|
|
|
|
|
// x is the position of the bubble, in % from the left (0% = full left, 100% = full right)
|
|
|
|
|
// 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--;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
|
|
|
|
|
// create the 1st plot as smoothed area chart using the 1st dataset
|
|
|
|
|
$Plot =& $Plotarea->addNew('bubble', array(&$dataset));
|
|
|
|
|
$Plot->setFont($Font);
|
|
|
|
|
|
|
|
|
|
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
|
|
|
|
|
$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");
|
|
|
|
|
$interval_x = $adjust_time;
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
$intervalWidth = $width * 0.85 * $interval_x/ $periodo;
|
|
|
|
|
if ($intervalWidth >= $minIntervalWidth)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
$interval_x *= 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$AxisX->setLabelInterval($interval_x);
|
|
|
|
|
$AxisX->setLabelOption("showtext",true);
|
|
|
|
|
|
|
|
|
|
//*
|
|
|
|
|
$GridY2 =& $Plotarea->addNew('line_grid');
|
|
|
|
|
$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);
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
//*
|
|
|
|
|
$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);
|
|
|
|
|
$AxisY->forceMaximum(count($severities) + 1) ;
|
|
|
|
|
|
|
|
|
|
// set line colors
|
|
|
|
|
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
|
|
|
|
|
|
|
|
|
|
$Plot->setFillStyle($FillArray);
|
|
|
|
|
foreach($colors as $color)
|
|
|
|
|
$FillArray->addColor($color);
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
|
|
|
|
|
$FillArray->addColor('green@0.6');
|
|
|
|
|
//$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
|
|
|
|
|
|
|
|
|
|
// Show events !
|
|
|
|
|
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);
|
|
|
|
|
$Axis->Hide();
|
|
|
|
|
$Axis =& $PlotareaMinMax->getAxis(IMAGE_GRAPH_AXIS_Y);
|
|
|
|
|
$Axis->Hide();
|
|
|
|
|
|
|
|
|
|
$plotMinMax =& $PlotareaMinMax->addNew('bubble', array(&$dataset, true));
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
|
|
|
|
|
$Graph->done();
|
|
|
|
|
|
|
|
|
|
grafico_modulo_log4x_trace(__LINE__);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_log4x_index($x, $interval)
|
|
|
|
|
{
|
|
|
|
|
return $x + $interval - (($x - 1) % $interval) - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_log4x_trace($str)
|
|
|
|
|
{
|
|
|
|
|
//echo "$str\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_log4x_bubble_size($count, $max_count, $max_bubble_radius)
|
|
|
|
|
{
|
|
|
|
|
//Superformula de ROA
|
|
|
|
|
$r0 = 1.5;
|
|
|
|
|
$r1 = $max_bubble_radius;
|
|
|
|
|
$v2 = pow($max_count,1/2.0);
|
|
|
|
|
|
|
|
|
|
return $r1*pow($count,1/2.0)/($v2)+$r0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Esta custion no sirve paaaaaaaaaaaa naaaaaaaaaaaaaaaadaaaaaaaaaaaaaa
|
|
|
|
|
//Cementerio de formulas ... QEPD
|
|
|
|
|
$a = pow(($r1 - $r0)/(pow($v2,1/4.0)-1),4);
|
|
|
|
|
$b = $r0 - pow($a,1/4.0);
|
|
|
|
|
|
|
|
|
|
return pow($a * $count, 1/4.0) + $b;
|
|
|
|
|
|
|
|
|
|
$r = pow($count / pow(3.1415, 3), 0.25);
|
|
|
|
|
|
|
|
|
|
$q = 0.9999;
|
|
|
|
|
$x = $count;
|
|
|
|
|
$x0 = $max_count;
|
|
|
|
|
$y0 = $max_size;
|
|
|
|
|
|
|
|
|
|
$y = 4 * $y0 * $x * (((1 - 2 * $q) / (2 * $x0))* $x + ((4 * $q - 1) / 4)) / $x0;
|
|
|
|
|
|
|
|
|
|
return $y;
|
|
|
|
|
|
|
|
|
|
return 3 * (0.3796434104 + pow($count * 0.2387394557, 0.333333333));
|
|
|
|
|
|
|
|
|
|
return sqrt($count / 3.1415);
|
|
|
|
|
return 5 + log($count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_log4x_format_x_axis ( $number , $decimals=2, $dec_point=".", $thousands_sep=",")
|
|
|
|
|
{
|
|
|
|
|
// $number is the unix time in the local timezone
|
|
|
|
|
|
|
|
|
|
//$dtZone = new DateTimeZone(date_default_timezone_get());
|
|
|
|
|
//$d = new DateTime("now", $dtZone);
|
|
|
|
|
//$offset = $dtZone->getOffset($d);
|
|
|
|
|
//$number -= $offset;
|
|
|
|
|
|
|
|
|
|
return date("d/m", $number) . "\n" . date("H:i", $number);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function grafico_modulo_log4x_format_y_axis ( $number , $decimals=2, $dec_point=".", $thousands_sep=",")
|
|
|
|
|
{
|
|
|
|
|
$n = "";
|
|
|
|
|
|
|
|
|
|
switch($number) {
|
|
|
|
|
case 6: $n = "FATAL"; break;
|
|
|
|
|
case 5: $n = "ERROR"; break;
|
|
|
|
|
case 4: $n = "WARN"; break;
|
|
|
|
|
case 3: $n = "INFO"; break;
|
|
|
|
|
case 2: $n = "DEBUG"; break;
|
|
|
|
|
case 1: $n = "TRACE"; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "$n";
|
|
|
|
|
}
|
|
|
|
|
?>
|