fixed errors in graph update version

This commit is contained in:
daniel 2018-05-21 17:25:09 +02:00
parent 79354a0ebf
commit b323d524d6
7 changed files with 270 additions and 364 deletions

View File

@ -2991,111 +2991,110 @@ function color_graph_array($series_suffix, $compare = false){
return $color;
}
function legend_graph_array(
$max, $min, $avg,
$series_suffix,
$series_suffix_str,
$format_graph,
$show_elements_graph,
$percentil_value,
$data_module_graph){
global $config;
global $legend;
$unit = $format_graph['unit'];
if (isset($show_elements_graph['labels']) && is_array($show_elements_graph['labels']) && (count($show_elements_graph['labels']) > 0)){
$legend['sum'.$series_suffix] = $show_elements_graph['labels'][$data_module_graph['module_id']] . ' ' ;
}
else{
$legend['sum'.$series_suffix] = $data_module_graph['agent_name'] . ' / ' .
$data_module_graph['module_name'] . ': ';
}
$legend['sum'.$series_suffix] .=
__('Min:') . remove_right_zeros(
number_format(
$min,
$config['graph_precision']
)
) . ' ' .
__('Max:') . remove_right_zeros(
number_format(
$max,
$config['graph_precision']
)
) . ' ' .
_('Avg:') . remove_right_zeros(
number_format(
$max,
$config['graph_precision']
)
) . ' ' . $series_suffix_str;
if($show_elements_graph['show_unknown']){
$legend['unknown'.$series_suffix] = __('Unknown') . ' ' . $series_suffix_str;
}
if($show_elements_graph['show_events']){
$legend['event'.$series_suffix] = __('Events') . ' ' . $series_suffix_str;
}
if($show_elements_graph['show_alerts']){
$legend['alert'.$series_suffix] = __('Alert') . ' ' . $series_suffix_str;
}
if($show_elements_graph['percentil']){
$legend['percentil'.$series_suffix] =
__('Percentil') . ' ' .
$config['percentil'] .
'º ' . __('of module') . ' ';
if (isset($show_elements_graph['labels']) && is_array($show_elements_graph['labels'])){
$legend['percentil'.$series_suffix] .= $show_elements_graph['labels'][$data_module_graph['module_id']] . ' ' ;
}
else{
$legend['percentil'.$series_suffix] .= $data_module_graph['agent_name'] . ' / ' .
$data_module_graph['module_name'] . ': ' . ' Value: ';
}
$legend['percentil'.$series_suffix] .= remove_right_zeros(
number_format(
$percentil_value,
$config['graph_precision']
)
) . ' ' . $series_suffix_str;
}
return $legend;
}
function series_type_graph_array($data){
function series_type_graph_array($data, $show_elements_graph){
global $config;
foreach ($data as $key => $value) {
if(strpos($key, 'sum') !== false){
if(strpos($key, 'summatory') !== false){
$data_return['series_type'][$key] = 'area';
$data_return['legend'][$key] = __('Summatory series') . ' ' . $series_suffix_str;
}
elseif(strpos($key, 'average') !== false){
$data_return['series_type'][$key] = 'area';
$data_return['legend'][$key] = __('Average series') . ' ' . $series_suffix_str;
}
elseif(strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false){
switch ($value['id_module_type']) {
case 21: case 2: case 6:
case 18: case 9: case 31:
$series_type[$key] = 'boolean';
$data_return['series_type'][$key] = 'boolean';
break;
default:
$series_type[$key] = 'area';
$data_return['series_type'][$key] = 'area';
break;
}
if (isset($show_elements_graph['labels']) &&
is_array($show_elements_graph['labels']) &&
(count($show_elements_graph['labels']) > 0)){
$data_return['legend'][$key] = $show_elements_graph['labels'][$value['id_module_type']] . ' ' ;
}
else{
if(strpos($key, 'baseline') !== false){
$data_return['legend'][$key] = $value['agent_name'] . ' / ' .
$value['module_name'] . ' Baseline ';
}
else{
$data_return['legend'][$key] = $value['agent_name'] . ' / ' .
$value['module_name'] . ': ';
}
}
if(strpos($key, 'baseline') === false){
$data_return['legend'][$key] .=
__('Min:') . remove_right_zeros(
number_format(
$value['min'],
$config['graph_precision']
)
) . ' ' .
__('Max:') . remove_right_zeros(
number_format(
$value['max'],
$config['graph_precision']
)
) . ' ' .
_('Avg:') . remove_right_zeros(
number_format(
$value['avg'],
$config['graph_precision']
)
) . ' ' . $series_suffix_str;
}
}
elseif(strpos($key, 'event') !== false){
$series_type[$key] = 'points';
$data_return['series_type'][$key] = 'points';
if($show_elements_graph['show_events']){
$data_return['legend'][$key] = __('Events') . ' ' . $series_suffix_str;
}
}
elseif(strpos($key, 'alert') !== false){
$series_type[$key] = 'points';
$data_return['series_type'][$key] = 'points';
if($show_elements_graph['show_alerts']){
$data_return['legend'][$key] = __('Alert') . ' ' . $series_suffix_str;
}
}
elseif(strpos($key, 'unknown') !== false){
$series_type[$key] = 'unknown';
$data_return['series_type'][$key] = 'unknown';
if($show_elements_graph['show_unknown']){
$data_return['legend'][$key] = __('Unknown') . ' ' . $series_suffix_str;
}
}
elseif(strpos($key, 'percentil') !== false){
$series_type[$key] = 'percentil';
$data_return['series_type'][$key] = 'percentil';
if($show_elements_graph['percentil']){
$data_return['legend'][$key] =
__('Percentil') . ' ' .
$config['percentil'] .
'º ' . __('of module') . ' ';
if (isset($show_elements_graph['labels']) && is_array($show_elements_graph['labels'])){
$data_return['legend'][$key] .= $show_elements_graph['labels'][$value['id_module_type']] . ' ' ;
}
else{
$data_return['legend'][$key] .= $value['agent_name'] . ' / ' .
$value['module_name'] . ': ' . ' Value: ';
}
$data_return['legend'][$key] .= remove_right_zeros(
number_format(
$value['data'][0][1],
$config['graph_precision']
)
) . ' ' . $series_suffix_str;
}
}
else{
$series_type[$key] = 'area';
$data_return['series_type'][$key] = 'area';
}
}
return $series_type;
return $data_return;
}
?>

View File

@ -327,11 +327,12 @@ function grafico_modulo_sparse_data_chart (
}
}
$array_data["sum" . $series_suffix]['min'] = $min_value;
$array_data["sum" . $series_suffix]['max'] = $max_value;
$array_data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
$array_data["sum" . $series_suffix]['id_module_type'] = $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['min'] = $min_value;
$array_data["sum" . $series_suffix]['max'] = $max_value;
$array_data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
$array_data["sum" . $series_suffix]['id_module_type']= $data_module_graph['id_module_type'];
$array_data["sum" . $series_suffix]['agent_name'] = $data_module_graph['agent_name'];
$array_data["sum" . $series_suffix]['module_name'] = $data_module_graph['module_name'];
if (!is_null($show_elements_graph['percentil']) &&
$show_elements_graph['percentil'] &&
@ -356,10 +357,6 @@ function grafico_modulo_sparse_data(
$series_suffix, $str_series_suffix) {
global $config;
//global $array_data;
global $caption;
global $color;
global $legend;
global $array_events_alerts;
if($show_elements_graph['fullscale']){
@ -553,19 +550,6 @@ function grafico_modulo_sparse_data(
return $array_data;
}
// Only show caption if graph is not small
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT){
//Flash chart
$caption =
__('Max. Value') . $series_suffix_str . ': ' . $max . ' ' .
__('Avg. Value') . $series_suffix_str . ': ' . $avg . ' ' .
__('Min. Value') . $series_suffix_str . ': ' . $min . ' ' .
__('Units. Value') . $series_suffix_str . ': ' . $format_graph['unit'];
}
else{
$caption = array();
}
$color = color_graph_array(
$series_suffix,
$show_elements_graph['flag_overlapped']
@ -577,16 +561,6 @@ function grafico_modulo_sparse_data(
}
}
legend_graph_array(
$max, $min, $avg,
$series_suffix,
$str_series_suffix,
$format_graph,
$show_elements_graph,
$percentil_value,
$data_module_graph
);
$array_events_alerts[$series_suffix] = $events;
return $array_data;
@ -605,20 +579,12 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
global $config;
global $graphic_type;
//global $array_data;
global $caption;
global $color;
global $legend;
global $array_events_alerts;
$array_data = array();
$caption = array();
$color = array();
$legend = array();
$array_events_alerts = array();
//date start final period
@ -743,10 +709,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
case 'separated':
case 'overlapped':
// Store the chart calculated
$array_data_prev = $array_data;
$legend_prev = $legend;
$color_prev = $color;
$caption_prev = $caption;
$array_data_prev = $array_data;
$legend_prev = $legend;
break;
}
}
@ -766,7 +730,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
if ($show_elements_graph['compare'] === 'overlapped') {
$array_data = array_merge($array_data, $array_data_prev);
$legend = array_merge($legend, $legend_prev);
$color = array_merge($color, $color_prev);
}
}
}
@ -790,10 +753,14 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
)
);
$series_type = series_type_graph_array(
$array_data
$series_type_array = series_type_graph_array(
$array_data,
$show_elements_graph
);
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
//esto la sparse
//setup_watermark($water_mark, $water_mark_file, $water_mark_url);
@ -805,7 +772,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$return = area_graph(
$agent_module_id,
$array_data,
$color,
$legend,
$series_type,
$date_array,
@ -823,14 +789,17 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$return .= '<br>';
if (!empty($array_data_prev)) {
$series_type = series_type_graph_array(
$array_data_prev
$series_type_array = series_type_graph_array(
$array_data_prev,
$show_elements_graph
);
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
$return .= area_graph(
$agent_module_id,
$array_data_prev,
$color,
$legend,
$series_type,
$date_array,
@ -851,7 +820,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$return = area_graph(
$agent_module_id,
$array_data,
$color,
$legend,
$series_type,
$date_array,
@ -951,10 +919,8 @@ function graphic_combined_module (
global $config;
global $graphic_type;
global $legend;
$legend = array();
$caption = array();
$series_type = array();
//date start final period
@ -971,16 +937,8 @@ function graphic_combined_module (
$show_max
$show_min
$show_avg
$from_interface
$summatory
$average
$modules_series
*/
/*
html_debug_print($name_list);
html_debug_print($unit_list);
html_debug_print($from_interface);
*/
$date_array = array();
$date_array["period"] = $period;
$date_array["final_date"] = $date;
@ -1013,6 +971,8 @@ html_debug_print($from_interface);
$show_elements_graph['id_widget'] = $id_widget_dashboard;
$show_elements_graph['labels'] = $labels;
$show_elements_graph['stacked'] = $stacked;
$show_elements_graph['combined'] = true;
$show_elements_graph['from_interface'] = $from_interface;
$format_graph = array();
$format_graph['width'] = "90%";
@ -1109,16 +1069,6 @@ html_debug_print($from_interface);
}
}
legend_graph_array(
$max, $min, $avg,
$series_suffix,
$str_series_suffix,
$format_graph,
$show_elements_graph,
$percentil_value,
$data_module_graph
);
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
@ -1132,10 +1082,21 @@ html_debug_print($from_interface);
$i++;
}
$series_type = series_type_graph_array(
$array_data
//summatory and average series
if($stacked == CUSTOM_GRAPH_AREA || $stacked == CUSTOM_GRAPH_LINE) {
if($summatory || $average) {
$array_data = combined_graph_summatory_average ($array_data, $average, $summatory, $modules_series);
}
}
$series_type_array = series_type_graph_array(
$array_data,
$show_elements_graph
);
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
if ($flash_charts === false && $stacked == CUSTOM_GRAPH_GAUGE)
$stacked = CUSTOM_GRAPH_BULLET_CHART;
@ -1496,14 +1457,10 @@ html_debug_print($from_interface);
$module_name_list[$i] .= " (x". format_numeric ($weight_list[$i], 1).")";
}
*/
// $temp = array();
$graph_values = $temp;
//Set graph color
$threshold_data = array();
if ($from_interface) {
@ -1527,9 +1484,10 @@ html_debug_print($from_interface);
$do_it_warning_inverse = true;
$do_it_critical_inverse = true;
foreach ($module_list as $index => $id_module) {
// Get module warning_min and critical_min
$warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$id_module);
$warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$id_module);
$critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$id_module);
if ($index == 0) {
@ -1553,7 +1511,7 @@ html_debug_print($from_interface);
if ($do_it_warning_min || $do_it_critical_min) {
foreach ($module_list as $index => $id_module) {
$warning_max = db_get_value('max_warning','tagente_modulo','id_agente_modulo',$id_module);
$warning_max = db_get_value('max_warning','tagente_modulo','id_agente_modulo',$id_module);
$critical_max = db_get_value('max_critical','tagente_modulo','id_agente_modulo',$id_module);
if ($index == 0) {
@ -1578,7 +1536,7 @@ html_debug_print($from_interface);
if ($do_it_warning_min || $do_it_critical_min) {
foreach ($module_list as $index => $id_module) {
$warning_inverse = db_get_value('warning_inverse','tagente_modulo','id_agente_modulo',$id_module);
$warning_inverse = db_get_value('warning_inverse','tagente_modulo','id_agente_modulo',$id_module);
$critical_inverse = db_get_value('critical_inverse','tagente_modulo','id_agente_modulo',$id_module);
if ($index == 0) {
@ -1603,111 +1561,17 @@ html_debug_print($from_interface);
if ($do_it_warning_min && $do_it_warning_max && $do_it_warning_inverse) {
$yellow_threshold = $compare_warning;
$threshold_data['yellow_up'] = $yellow_up;
$threshold_data['yellow_up'] = $yellow_up;
$threshold_data['yellow_inverse'] = (bool)$yellow_inverse;
}
if ($do_it_critical_min && $do_it_critical_max && $do_it_critical_inverse) {
$red_threshold = $compare_critical;
$threshold_data['red_up'] = $red_up;
$threshold_data['red_up'] = $red_up;
$threshold_data['red_inverse'] = (bool)$red_inverse;
}
}
//summatory and average series
if($stacked == CUSTOM_GRAPH_AREA || $stacked == CUSTOM_GRAPH_LINE) {
if($summatory || $average) {
if(isset($array_data) && is_array($array_data)){
foreach ($array_data as $key => $value) {
if(strpos($key, 'sum') !== false){
$data_array_reverse[$key] = array_reverse($value['data']);
if(!$modules_series) {
unset($array_data[$key]);
unset($legend[$key]);
unset($series_type[$key]);
}
}
}
if(isset($data_array_reverse) && is_array($data_array_reverse)){
$array_sum_reverse = array();
$data_array_prev = false;
$data_array_pop = array();
$count = 0;
while(count($data_array_reverse['sum0']) > 0){
foreach ($data_array_reverse as $key_reverse => $value_reverse) {
if(is_array($value_reverse) && count($value_reverse) > 0){
$data_array_pop[$key_reverse] = array_pop($data_array_reverse[$key_reverse]);
}
}
if(isset($data_array_pop) && is_array($data_array_pop)){
$acum_data = 0;
$acum_array = array();
$sum_data = 0;
$count_pop = 0;
foreach ($data_array_pop as $key_pop => $value_pop) {
if( $value_pop[0] > $acum_data ){
if($acum_data != 0){
$sum_data = $sum_data + $data_array_prev[$key_pop][1];
$data_array_reverse[$key_pop][] = $value_pop;
$data_array_prev[$acum_key] = $acum_array;
}
else{
if($data_array_prev[$key_pop] == false){
$data_array_prev[$key_pop] = $value_pop;
}
$acum_key = $key_pop;
$acum_data = $value_pop[0];
$acum_array = $value_pop;
$sum_data = $value_pop[1];
}
}
elseif($value_pop[0] < $acum_data){
$sum_data = $sum_data + $data_array_prev[$key_pop][1];
$data_array_reverse[$acum_key][] = $acum_array;
$data_array_prev[$key_pop] = $value_pop;
$acum_key = $key_pop;
$acum_data = $value_pop[0];
$acum_array = $value_pop;
}
elseif($value_pop[0] == $acum_data){
$data_array_prev[$key_pop] = $value_pop;
$sum_data += $value_pop[1];
}
$count_pop++;
}
if($summatory){
$array_sum_reverse[$count][0] = $acum_data;
$array_sum_reverse[$count][1] = $sum_data;
}
if($average){
$array_avg_reverse[$count][0] = $acum_data;
$array_avg_reverse[$count][1] = $sum_data / $count_pop;
}
}
$count++;
}
}
}
//XXXXX color,type,title, opacity
if(isset($array_sum_reverse) && is_array($array_sum_reverse)){
$array_data['sumatory']['data'] = $array_sum_reverse;
$array_data['sumatory']['color'] = 'purple';
$legend['sumatory'] = __('Summatory');
$series_type['sumatory'] = 'area';
}
if(isset($array_avg_reverse) && is_array($array_avg_reverse)){
$array_data['sum_avg']['data'] = $array_avg_reverse;
$array_data['sum_avg']['color'] = 'orange';
$legend['sum_avg'] = __('AVG');
$series_type['sum_avg'] = 'area';
}
}
$show_elements_graph['threshold_data'] = $threshold_data;
}
switch ($stacked) {
@ -1716,7 +1580,7 @@ html_debug_print($from_interface);
case CUSTOM_GRAPH_STACKED_AREA:
case CUSTOM_GRAPH_AREA:
case CUSTOM_GRAPH_LINE:
return area_graph($agent_module_id, $array_data, $color,
return area_graph($agent_module_id, $array_data,
$legend, $series_type, $date_array,
$data_module_graph, $show_elements_graph,
$format_graph, $water_mark, $series_suffix_str,
@ -1759,18 +1623,14 @@ html_debug_print($from_interface);
}
}
function combined_graph_summatory_average ($array_data){
function combined_graph_summatory_average ($array_data, $average = false, $summatory = false, $modules_series = false, $baseline = false){
if(isset($array_data) && is_array($array_data)){
foreach ($array_data as $key => $value) {
if(strpos($key, 'sum') !== false){
$data_array_reverse[$key] = array_reverse($value['data']);
/*
if(!$modules_series) {
unset($array_data[$key]);
unset($legend[$key]);
unset($series_type[$key]);
}
*/
}
}
@ -1824,19 +1684,36 @@ function combined_graph_summatory_average ($array_data){
}
$count_pop++;
}
// if($summatory){
// $array_sum_reverse[$count][0] = $acum_data;
// $array_sum_reverse[$count][1] = $sum_data;
// }
// if($average){
if($summatory){
$array_sum_reverse[$count][0] = $acum_data;
$array_sum_reverse[$count][1] = $sum_data;
}
if($average){
$array_avg_reverse[$count][0] = $acum_data;
$array_avg_reverse[$count][1] = $sum_data / $count_pop;
// }
}
}
$count++;
}
if($summatory && isset($array_sum_reverse) && is_array($array_sum_reverse) && count($array_sum_reverse) > 0){
$array_data['summatory']['data'] = $array_sum_reverse;
$array_data['summatory']['color'] = 'purple';
}
if($average && isset($array_avg_reverse) && is_array($array_avg_reverse) && count($array_avg_reverse) > 0){
if($baseline){
$array_data['baseline']['data'] = $array_avg_reverse;
$array_data['baseline']['color'] = 'green';
}
else{
$array_data['average']['data'] = $array_avg_reverse;
$array_data['average']['color'] = 'orange';
}
}
}
return $array_avg_reverse;
return $array_data;
}
else{
return false;

View File

@ -221,7 +221,7 @@ function vbar_graph(
}
function area_graph(
$agent_module_id, $array_data, $color,
$agent_module_id, $array_data,
$legend, $series_type, $date_array,
$data_module_graph, $show_elements_graph,
$format_graph, $water_mark, $series_suffix_str,
@ -234,7 +234,6 @@ function area_graph(
return flot_area_graph(
$agent_module_id,
$array_data,
$color,
$legend,
$series_type,
$date_array,

View File

@ -24,7 +24,6 @@
// Throw errors
var retrieveDataOject = function (dataObjects, custom) {
var result;
if (typeof dataObjects === 'undefined')
throw new Error('Empty parameter');
@ -76,25 +75,36 @@
* }
*/
if (type === 'csv') {
result = {
head: ['date', 'value','label'],
head: ['timestap', 'date', 'value', 'label'],
data: []
};
dataObject.data.forEach(function (item, index) {
var date = '', value = item[1];
var timestap = item[0];
// Long labels are preferred
if (typeof plot.getOptions().export.labels_long[index] !== 'undefined')
date = plot.getOptions().export.labels_long[index];
else if (typeof labels[index] !== 'undefined')
date = labels[index];
var d = new Date(item[0]);
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun",
"Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"
];
var clean_label = dataObject.label;
clean_label = clean_label.replace( new RegExp("<.*?>", "g"), "");
clean_label = clean_label.replace( new RegExp(";", "g"), "");
result.data.push([date, value, clean_label]);
date_format = (d.getDate() <10?'0':'') + d.getDate() + " " +
monthNames[d.getMonth()] + " " +
d.getFullYear() + " " +
(d.getHours()<10?'0':'') + d.getHours() + ":" +
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
(d.getSeconds()<10?'0':'') + d.getSeconds();
var date = date_format;
var value = item[1];
var clean_label = plot.getOptions().export.labels_long[dataObject.label];
result.data.push([timestap, date, value, clean_label]);
});
}
/* [
@ -251,7 +261,7 @@
// Throw errors
var processDataObject = function (dataObject) {
var result;
console.log(dataObject);
if (typeof dataObject === 'undefined')
throw new Error('Empty parameter');

View File

@ -1576,15 +1576,14 @@ function pandoraFlotArea(
show: points_show,
radius: 3,
fillColor: fill_points
}
},
legend: legend.index
});
}
}
i++;
});
console.log(data_base);
console.log(legend);
// The first execution, the graph data is the base data
datas = data_base;
font_size = 8;
@ -1608,7 +1607,7 @@ function pandoraFlotArea(
},
export: {
export_data: true,
labels_long: labels_long,
labels_long: legend,
homeurl: homeurl
},
grid: {
@ -1701,7 +1700,7 @@ function pandoraFlotArea(
},
export: {
export_data: true,
labels_long: labels_long,
labels_long: legend,
homeurl: homeurl
},
grid: {
@ -2126,7 +2125,7 @@ function pandoraFlotArea(
// Get only two decimals
//XXXXXXXXXX
formatted = round_with_decimals(formatted, 100)
formatted = round_with_decimals(formatted, 100);
return '<div class='+font+' style="font-size:'+font_size+'pt;">'+formatted+'</div>';
}

View File

@ -101,7 +101,7 @@ function include_javascript_dependencies_flot_graph($return = false) {
////////// AREA GRAPHS ////////
///////////////////////////////
function flot_area_graph (
$agent_module_id, $array_data, $color,
$agent_module_id, $array_data,
$legend, $series_type, $date_array,
$data_module_graph, $show_elements_graph,
$format_graph, $water_mark, $series_suffix_str,
@ -133,20 +133,41 @@ function flot_area_graph (
$return = "<div class='parent_graph' style='width: " . ($format_graph['width']) . "; " . $background_style . "'>";
// Set some containers to legend, graph, timestamp tooltip, etc.
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:" . $format_graph['font_size'] ."pt !important;'></p>";
$yellow_threshold = $data_module_graph['w_min'];
$red_threshold = $data_module_graph['c_min'];
// Get other required module datas to draw warning and critical
if ($agent_module_id == 0) {
$yellow_up = 0;
$red_up = 0;
if(!isset($show_elements_graph['combined']) || !$show_elements_graph['combined']){
$yellow_threshold = $data_module_graph['w_min'];
$red_threshold = $data_module_graph['c_min'];
// Get other required module datas to draw warning and critical
if ($agent_module_id == 0) {
$yellow_up = 0;
$red_up = 0;
$yellow_inverse = false;
$red_inverse = false;
} else {
$yellow_up = $data_module_graph['w_max'];
$red_up = $data_module_graph['c_max'];
$yellow_inverse = !($data_module_graph['w_inv'] == 0);
$red_inverse = !($data_module_graph['c_inv'] == 0);
}
}
elseif(isset($show_elements_graph['from_interface']) && $show_elements_graph['from_interface']){
if( isset($show_elements_graph['threshold_data']) && is_array($show_elements_graph['threshold_data'])){
$yellow_up = $show_elements_graph['threshold_data']['yellow_up'];
$red_up = $show_elements_graph['threshold_data']['red_up'];
$yellow_inverse = $show_elements_graph['threshold_data']['yellow_inverse'];
$red_inverse = $show_elements_graph['threshold_data']['red_inverse'];
}
else{
$yellow_up = 0;
$red_up = 0;
$yellow_inverse = false;
$red_inverse = false;
}
}
else{
$yellow_up = 0;
$red_up = 0;
$yellow_inverse = false;
$red_inverse = false;
} else {
$yellow_up = $data_module_graph['w_max'];
$red_up = $data_module_graph['c_max'];
$yellow_inverse = !($data_module_graph['w_inv'] == 0);
$red_inverse = !($data_module_graph['c_inv'] == 0);
$red_inverse = false;
}
if ($show_elements_graph['menu']) {

View File

@ -75,7 +75,7 @@ $interface_traffic_modules = array(
$refresh = (int) get_parameter('refresh', SECONDS_5MINUTES);
if ($refresh > 0) {
$query = ui_get_url_refresh(false);
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
}
?>
@ -99,10 +99,10 @@ $interface_traffic_modules = array(
window.onload = function() {
// Hack to repeat the init process to period select
var periodSelectId = $('[name="period"]').attr('class');
period_select_init(periodSelectId);
};
function show_others() {
if (!$("#checkbox-avg_only").attr('checked')) {
$("#hidden-show_other").val(1);
@ -116,20 +116,18 @@ $interface_traffic_modules = array(
</head>
<body bgcolor="#ffffff" style='background:#ffffff;'>
<?php
// ACL
$permission = false;
$agent_group = (int) agents_get_agent_group($agent_id);
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
// The traffic modules should belong to the agent id
$in_agent_id = (int) db_get_value("id_agente", "tagente_modulo", "id_agente_modulo", $params['traffic_module_in']);
$out_agent_id = (int) db_get_value("id_agente", "tagente_modulo", "id_agente_modulo", $params['traffic_module_out']);
$traffic_modules_belong_to_agent = $agent_id == $in_agent_id && $agent_id == $out_agent_id;
if (!empty($agent_group) && !empty($params['traffic_module_in'])
&& !empty($params['traffic_module_out']) && $traffic_modules_belong_to_agent) {
if ($strict_user) {
if (tags_check_acl_by_module($params['traffic_module_in'], $config['id_user'], 'RR') === true
&& tags_check_acl_by_module($params['traffic_module_out'], $config['id_user'], 'RR') === true)
@ -139,12 +137,12 @@ $interface_traffic_modules = array(
$permission = check_acl($config['id_user'], $agent_group, "RR");
}
}
if (!$permission) {
require ($config['homedir'] . "/general/noaccess.php");
exit;
}
// Get input parameters
$period = get_parameter ("period", SECONDS_1DAY);
$width = (int) get_parameter("width", 555);
@ -155,10 +153,10 @@ $interface_traffic_modules = array(
$baseline = get_parameter ("baseline", 0);
$show_percentil = get_parameter ("show_percentil", 0);
$fullscale = get_parameter("fullscale");
if(!isset($_GET["fullscale_sent"]) ){
if(!isset($config['full_scale_option']) ||
$config['full_scale_option'] == 0 ||
if(!isset($config['full_scale_option']) ||
$config['full_scale_option'] == 0 ||
$config['full_scale_option'] == 2 ){
$fullscale = 0;
}
@ -170,12 +168,11 @@ $interface_traffic_modules = array(
if ($zoom > 1) {
$height = $height * ($zoom / 2.1);
$width = $width * ($zoom / 1.4);
echo "<script type='text/javascript'>window.resizeTo($width + 120, $height + 320);</script>";
}
/*$current = date("Y-m-d");
if ($start_date != $current)
$date = strtotime($start_date);
else
@ -183,19 +180,23 @@ $interface_traffic_modules = array(
*/
$date = strtotime("$start_date $start_time");
$now = time();
if ($date > $now){
$date = $now;
}
$urlImage = ui_get_full_url(false);
if ($config['flash_charts'] == 1)
echo '<div style="margin-left: 70px; padding-top: 10px;">';
else
echo '<div style="margin-left: 50px; padding-top: 10px;">';
custom_graphs_print(0,
$height = 400;
$width = '90%';
custom_graphs_print(
0,
$height,
$width,
$period,
@ -218,10 +219,11 @@ $interface_traffic_modules = array(
(($show_percentil)? $config['percentil'] : null),
true,
false,
$fullscale);
$fullscale
);
echo '</div>';
///////////////////////////
// SIDE MENU
///////////////////////////
@ -231,13 +233,12 @@ $interface_traffic_modules = array(
$side_layer_params['top_text'] = "<div style='color: white; width: 100%; text-align: center; font-weight: bold; vertical-align: top;'>" . html_print_image('/images/config.disabled.png', true, array('width' => '16px'),false,false,false,true) . ' ' . __('Pandora FMS Graph configuration menu') . "</div>";
$side_layer_params['body_text'] = "<div class='menu_sidebar_outer'>";
$side_layer_params['body_text'] .=__('Please, make your changes and apply with the <i>Reload</i> button');
// MENU
$side_layer_params['body_text'] .= '<form method="get" action="interface_traffic_graph_win.php">';
$side_layer_params['body_text'] .= html_print_input_hidden("params", base64_encode($params_json), true);
// FORM TABLE
$table = html_get_predefined_table('transparent', 2);
$table->width = '98%';
$table->id = 'stat_win_form_div';
@ -245,32 +246,32 @@ $interface_traffic_modules = array(
$table->style[1] = 'text-align:left;';
$table->styleTable = 'border-spacing: 4px;';
$table->class = 'alternate';
$data = array();
$data[0] = __('Refresh time');
$data[1] = html_print_extended_select_for_time("refresh", $refresh, '', '', 0, 7, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = __('Begin date');
$data[1] = html_print_input_text ("start_date", substr ($start_date, 0, 10),'', 15, 255, true);
$data[1] .= html_print_image ("/images/calendar_view_day.png", true, array ("onclick" => "scwShow(scwID('text-start_date'),this);", "style" => 'vertical-align: bottom;'),false,false,false,true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = __('Begin time');
$data[1] = html_print_input_text ("start_time", $start_time,'', 10, 10, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = __('Time range');
$data[1] = html_print_extended_select_for_time('period', $period, '', '', 0, 7, true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = __('Show percentil');
$data[1] = html_print_checkbox ("show_percentil", 1, (bool) $show_percentil, true);
@ -288,7 +289,7 @@ $interface_traffic_modules = array(
$data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, true);
$table->data[] = $data;
$table->rowclass[] ='';
$data = array();
$data[0] = __('Zoom factor');
$options = array();
@ -300,47 +301,47 @@ $interface_traffic_modules = array(
$data[1] = html_print_select($options, "zoom", $zoom, '', '', 0, true);
$table->data[] = $data;
$table->rowclass[] = '';
$form_table = html_print_table($table, true);
unset($table);
$table->id = 'stat_win_form';
$table->width = '100%';
$table->cellspacing = 2;
$table->cellpadding = 2;
$table->class = 'databox';
$data = array();
$data[0] = html_print_div(array('content' => $form_table, 'style' => 'overflow: auto; height: 220px'), true);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = '<div style="width:100%; text-align:right;">' . html_print_submit_button (__('Reload'), "submit", false, 'class="sub upd"', true) . "</div>";
$table->data[] = $data;
$table->rowclass[] = '';
$side_layer_params['body_text'] .= html_print_table($table, true);
$side_layer_params['body_text'] .= '</form>';
$side_layer_params['body_text'] .= '</div>'; // outer
// ICONS
$side_layer_params['icon_closed'] = '/images/graphmenu_arrow_hide.png';
$side_layer_params['icon_open'] = '/images/graphmenu_arrow.png';
// SIZE
$side_layer_params['width'] = 500;
// POSITION
$side_layer_params['position'] = 'left';
html_print_side_layer($side_layer_params);
// Hidden div to forced title
html_print_div(array('id' => 'forced_title_layer', 'class' => 'forced_title_layer', 'hidden' => true));
?>
</body>
</html>
<?php
@ -351,7 +352,7 @@ ui_require_jquery_file("ui.datepicker-" . $custom_user_language, "include/javasc
ui_include_time_picker(true);
?>
<script>
<?php
//Resize window when show the overview graph.
if ($config['flash_charts']) {
@ -363,7 +364,7 @@ ui_include_time_picker(true);
height_window = $(window).height();
width_window = $(window).width();
});
$("*").filter(function() {
if (typeof(this.id) == "string")
return this.id.match(/menu_overview_graph.*/);
@ -375,12 +376,12 @@ ui_include_time_picker(true);
<?php
}
?>
// Add datepicker and timepicker
$("#text-start_date").datepicker({
dateFormat: "<?php echo DATE_FORMAT_JS; ?>"
});
$("#text-start_time").timepicker({
showSecond: true,
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
@ -392,8 +393,8 @@ ui_include_time_picker(true);
currentText: '<?php echo __('Now');?>',
closeText: '<?php echo __('Close');?>'
});
$.datepicker.setDefaults($.datepicker.regional["<?php echo $custom_user_language; ?>"]);
forced_title_callback();
</script>