From b323d524d6194c9db825ca7dc121a6c7701a1f92 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 21 May 2018 17:25:09 +0200 Subject: [PATCH] fixed errors in graph update version --- pandora_console/include/functions.php | 169 ++++++------ pandora_console/include/functions_graph.php | 261 +++++------------- pandora_console/include/graphs/fgraph.php | 3 +- .../flot/jquery.flot.exportdata.pandora.js | 38 ++- .../include/graphs/flot/pandora.flot.js | 13 +- .../include/graphs/functions_flot.php | 49 +++- .../agentes/interface_traffic_graph_win.php | 101 +++---- 7 files changed, 270 insertions(+), 364 deletions(-) diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 479d15f132..1b19be2b5f 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -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; } ?> diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 5333a1801f..c64f8ce20d 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -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 .= '
'; 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; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 425dda50c1..e2a4d310fc 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -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, diff --git a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js index 8cd548285c..8b72dbced9 100644 --- a/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js +++ b/pandora_console/include/graphs/flot/jquery.flot.exportdata.pandora.js @@ -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'); diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index af44d4907a..a51e3a0760 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -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 '
'+formatted+'
'; } diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index cf2892d6c5..ca5e6b375c 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -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 = "
"; // Set some containers to legend, graph, timestamp tooltip, etc. $return .= "

"; - - $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']) { diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index 84f6087663..12884870f6 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -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 ''; } ?> @@ -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( 1) { $height = $height * ($zoom / 2.1); $width = $width * ($zoom / 1.4); - echo ""; } - + /*$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 '
'; else echo '
'; - - 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 '
'; - + /////////////////////////// // SIDE MENU /////////////////////////// @@ -231,13 +233,12 @@ $interface_traffic_modules = array( $side_layer_params['top_text'] = "
" . html_print_image('/images/config.disabled.png', true, array('width' => '16px'),false,false,false,true) . ' ' . __('Pandora FMS Graph configuration menu') . "
"; $side_layer_params['body_text'] = "'; // 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)); ?> - +