Now the dashboard and visual console area graphs show the last and avg value in their legend

(cherry picked from commit 554e592275cda6c4adffc5bdb5b5779b86a1d192)
This commit is contained in:
Alejandro Gallardo Escobar 2016-05-31 11:23:14 +02:00
parent a4da4bbc8d
commit ebf11e0473
3 changed files with 12 additions and 11 deletions

View File

@ -168,11 +168,6 @@ function custom_graphs_print($id_graph, $height, $width, $period,
global $config; global $config;
// Only avg on dashboard and visual console
if ($dashboard || $vconsole) {
$show_last = $show_min = $show_max = false;
}
if ($id_graph == 0) { if ($id_graph == 0) {
$graph_conf['stacked'] = CUSTOM_GRAPH_LINE; $graph_conf['stacked'] = CUSTOM_GRAPH_LINE;
} }

View File

@ -484,7 +484,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$show_alerts = false, $avg_only = 0, $date = 0, $unit = '', $show_alerts = false, $avg_only = 0, $date = 0, $unit = '',
$baseline = 0, $return_data = 0, $show_title = true, $projection = false, $baseline = 0, $return_data = 0, $show_title = true, $projection = false,
$adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '', $adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '',
$show_unknown = false, $percentil = null) { $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false) {
global $config; global $config;
global $chart; global $chart;
@ -733,13 +733,19 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix_str]; $chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix_str];
} }
if (!$avg_only) { if ($dashboard || $vconsole) {
$legend['sum'.$series_suffix] =
__('Last') . ': ' . rtrim(number_format($graph_stats['sum']['last'], 2), '.0') . ($unit ? ' ' . $unit : '') . ' ; '
. __('Avg') . ': ' . rtrim(number_format($graph_stats['sum']['avg'], 2), '.0') . ($unit ? ' ' . $unit : '');
}
else if (!$avg_only) {
$legend['max'.$series_suffix] = __('Max').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['max']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['max']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['max']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['max']['min'], 2), '.0').' '.$unit.'--> '.__('Selected'); $legend['max'.$series_suffix] = __('Max').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['max']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['max']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['max']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['max']['min'], 2), '.0').' '.$unit.'--> '.__('Selected');
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['sum']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['sum']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['sum']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['sum']['min'], 2), '.0').' '.$unit.'--> '.__('Selected'); $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['sum']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['sum']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['sum']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['sum']['min'], 2), '.0').' '.$unit.'--> '.__('Selected');
$legend['min'.$series_suffix] = __('Min').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['min']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['min']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['min']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['min']['min'], 2), '.0').' '.$unit.'--> '.__('Selected'); $legend['min'.$series_suffix] = __('Min').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['min']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['min']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['min']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['min']['min'], 2), '.0').' '.$unit.'--> '.__('Selected');
} }
else else {
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['sum']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['sum']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['sum']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['sum']['min'], 2), '.0').' '.$unit.'--> '.__('Selected'); $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['sum']['last'], 2), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['sum']['avg'], 2), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['sum']['max'], 2), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['sum']['min'], 2), '.0').' '.$unit.'--> '.__('Selected');
}
//Baseline was replaced by compare graph feature //Baseline was replaced by compare graph feature
/*if ($baseline) { /*if ($baseline) {
$legend['baseline'.$series_suffix] = __('Baseline'); $legend['baseline'.$series_suffix] = __('Baseline');
@ -797,7 +803,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$show_alerts, $avg_only, $date-$period, $unit, $baseline, $show_alerts, $avg_only, $date-$period, $unit, $baseline,
$return_data, $show_title, $projection, $adapt_key, $return_data, $show_title, $projection, $adapt_key,
$compare, $series_suffix, $series_suffix_str, $compare, $series_suffix, $series_suffix_str,
$show_unknown, $percentil); $show_unknown, $percentil, $dashboard, $vconsole);
@ -833,7 +839,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$show_alerts, $avg_only, $show_alerts, $avg_only,
$date, $unit, $baseline, $return_data, $show_title, $date, $unit, $baseline, $return_data, $show_title,
$projection, $adapt_key, $compare, '', '', $show_unknown, $projection, $adapt_key, $compare, '', '', $show_unknown,
$percentil); $percentil, $dashboard, $vconsole);
if ($return_data) { if ($return_data) {

View File

@ -774,7 +774,7 @@ function visual_map_print_item($mode = "read", $layoutData,
$img = custom_graphs_print( $img = custom_graphs_print(
$layoutData['id_custom_graph'], $height, $width, $layoutData['id_custom_graph'], $height, $width,
$period, null, true, 0, $only_image, $layoutData['image'], $period, null, true, 0, $only_image, $layoutData['image'],
array(), '', array(), array(), false, array(), '', array(), array(), true,
false, false, true, 1, false, true); false, false, true, 1, false, true);
} }
else { else {