New data precision... (Init)

This commit is contained in:
Arturo Gonzalez 2016-10-18 10:32:10 +02:00
parent 5af34c3a3d
commit d5f82b568c
9 changed files with 91 additions and 47 deletions

View File

@ -392,6 +392,15 @@ $table_chars->data[$row][0] = __('Value to interface graphics');
$table_chars->data[$row][1] = html_print_input_text ('interface_unit', $config["interface_unit"], '', 20, 20, true);
$row++;
$disabled_graph_precision = false;
if (!enterprise_installed()) {
$disabled_graph_precision = true;
}
$table_chars->data[$row][0] = __('Data precision for reports');
$table_chars->data[$row][1] = html_print_input_text ('graph_precision', $config["graph_precision"], '', 5, 5, true, $disabled_graph_precision);
$row++;
$table_chars->data[$row][0] = __('Default line thickness for the Custom Graph.');
$table_chars->data[$row][1] = html_print_input_text ('custom_graph_width',
$config["custom_graph_width"], '', 5, 5, true);

View File

@ -911,12 +911,12 @@ if ($list_modules) {
$salida = $config["render_proc_fail"];
break;
default:
$salida = format_numeric($module["datos"]);
$salida = number_format($module["datos"], $config['graph_precision']);
break;
}
}
else {
$salida = format_numeric($module["datos"]);
$salida = number_format($module["datos"], $config['graph_precision']);
}
// Show units ONLY in numeric data types
if (isset($module["unit"])) {

View File

@ -197,6 +197,8 @@ switch ($action) {
case 'get_module_value':
global $config;
$unit_text = false;
$layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element));
switch ($layoutData['type']) {
@ -338,8 +340,15 @@ switch ($action) {
break;
}
$returnValue_value = explode(' ', $returnValue);
$return = array();
$return['value'] = $returnValue;
if ($returnValue_value[1] != "") {
$return['value'] = number_format($returnValue_value[0], $config['graph_precision']) . " " . $returnValue_value[1];
}
else {
$return['value'] = number_format($returnValue_value[0], $config['graph_precision']);
}
$return['max_percentile'] = $layoutData['height'];
$return['width_percentile'] = $layoutData['width'];
$return['unit_text'] = $unit_text;

View File

@ -444,6 +444,8 @@ function config_update_config () {
$error_update[] = __('Graphic resolution (1-low, 5-high)');
if (!config_update_value ('interface_unit', (string) get_parameter ('interface_unit', __('Bytes') )))
$error_update[] = __('Value to interface graphics');
if (!config_update_value ('graph_precision', (string) get_parameter ('graph_precision', 1)))
$error_update[] = __('Data precision for reports');
$style = (string) get_parameter ('style');
if ($style != $config['style'])
$style = substr ($style, 0, strlen ($style) - 4);
@ -1409,6 +1411,15 @@ function config_process_config () {
config_update_value ('interface_unit', __('Bytes'));
}
if (!isset($config['graph_precision'])) {
config_update_value ('graph_precision', 1);
}
else {
if (!isset($config['enterprise_installed'])) {
config_update_value ('graph_precision', 1);
}
}
if (!isset($config['gis_default_icon'])) {
config_update_value ('gis_default_icon', "marker");
}

View File

@ -498,7 +498,6 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
global $max_value;
global $min_value;
$chart = array();
$color = array();
$legend = array();
@ -734,16 +733,16 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
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 : '');
__('Last') . ': ' . rtrim(number_format($graph_stats['sum']['last'], $config['graph_precision']), '.0') . ($unit ? ' ' . $unit : '') . ' ; '
. __('Avg') . ': ' . rtrim(number_format($graph_stats['sum']['avg'], $config['graph_precision']), '.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['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['max'.$series_suffix] = __('Max').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['max']['last'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['max']['avg'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['max']['max'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['max']['min'], $config['graph_precision']), '.0').' '.$unit.' --> '.__('Selected');
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['sum']['last'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['sum']['avg'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['sum']['max'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['sum']['min'], $config['graph_precision']), '.0').' '.$unit.' --> '.__('Selected');
$legend['min'.$series_suffix] = __('Min').$series_suffix_str.': '.__('Last').': '.rtrim(number_format($graph_stats['min']['last'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['min']['avg'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['min']['max'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['min']['min'], $config['graph_precision']), '.0').' '.$unit.' --> '.__('Selected');
}
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'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Avg').': '.rtrim(number_format($graph_stats['sum']['avg'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Max').': '.rtrim(number_format($graph_stats['sum']['max'], $config['graph_precision']), '.0').' '.$unit.' ; '.__('Min').': '.rtrim(number_format($graph_stats['sum']['min'], $config['graph_precision']), '.0').' '.$unit.' --> '.__('Selected');
}
//Baseline was replaced by compare graph feature
/*if ($baseline) {
@ -804,8 +803,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$compare, $series_suffix, $series_suffix_str,
$show_unknown, $percentil, $dashboard, $vconsole);
switch ($compare) {
case 'separated':
// Store the chart calculated
@ -830,7 +827,6 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
}
}
// Build the data of the current period
$data_returned = grafico_modulo_sparse_data ($agent_module_id,
$period, $show_events,
@ -1351,30 +1347,30 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$last = $graph_stats['last'];
if ($min > 1000000)
$min = sprintf("%sM", number_format($min / 1000000, 2));
$min = sprintf("%sM", number_format($min / 1000000, $config['graph_precision']));
else if ($min > 1000)
$min = sprintf("%sK", number_format($min / 1000, 2));
$min = sprintf("%sK", number_format($min / 1000, $config['graph_precision']));
if ($max > 1000000)
$max = sprintf("%sM", number_format($max / 1000000, 2));
$max = sprintf("%sM", number_format($max / 1000000, $config['graph_precision']));
else if ($max > 1000)
$max = sprintf("%sK", number_format($max / 1000, 2));
$max = sprintf("%sK", number_format($max / 1000, $config['graph_precision']));
if ($avg > 1000000)
$avg = sprintf("%sM", number_format($avg / 1000000, 2));
$avg = sprintf("%sM", number_format($avg / 1000000, $config['graph_precision']));
else if ($avg > 1000)
$avg = sprintf("%sK", number_format($avg / 1000, 2));
$avg = sprintf("%sK", number_format($avg / 1000, $config['graph_precision']));
if ($last > 1000000)
$last = sprintf("%sM", number_format($last / 1000000, 2));
$last = sprintf("%sM", number_format($last / 1000000, $config['graph_precision']));
else if ($last > 1000)
$last = sprintf("%sK", number_format($last / 1000, 2));
$last = sprintf("%sK", number_format($last / 1000, $config['graph_precision']));
}
else {
$min = number_format($graph_stats['min'], 2);
$max = number_format($graph_stats['max'], 2);
$avg = number_format($graph_stats['avg'], 2);
$last = number_format($graph_stats['last'], 2);
$min = number_format($graph_stats['min'], $config['graph_precision']);
$max = number_format($graph_stats['max'], $config['graph_precision']);
$avg = number_format($graph_stats['avg'], $config['graph_precision']);
$last = number_format($graph_stats['last'], $config['graph_precision']);
}
@ -3754,8 +3750,8 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
//Boolean graph doesn't have max!!!
//$legend['max'.$series_suffix] = __('Max').$series_suffix_str .': '.__('Last').': '.$graph_stats['max']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['max']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['max']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['max']['min'].' '.$unit;
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.$graph_stats['sum']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['sum']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['sum']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['sum']['min'].' '.$unit;
//Boolean graph doesn't have min!!!
//$legend['min'.$series_suffix] = __('Min').$series_suffix_str .': '.__('Last').': '.$graph_stats['min']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['min']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['min']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['min']['min'].' '.$unit;
// Boolean graph doesn't have min!!!
// $legend['min'.$series_suffix] = __('Min').$series_suffix_str .': '.__('Last').': '.$graph_stats['min']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['min']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['min']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['min']['min'].' '.$unit;
}
else {
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.$graph_stats['sum']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['sum']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['sum']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['sum']['min'].' '.$unit;

View File

@ -296,6 +296,8 @@ function reporting_html_SLA($table, $item, $mini) {
$hide_notinit_agent = $style['hide_notinit_agents'];
$same_agent_in_resume = "";
global $config;
if ($mini) {
$font_size = '1.5';
}
@ -351,7 +353,7 @@ function reporting_html_SLA($table, $item, $mini) {
$row = array();
$row[] = $sla['agent'];
$row[] = $sla['module'];
$row[] = $sla['max'] . " / " . $sla['min'];
$row[] = number_format($sla['max'], $config['graph_precision']) . " / " . number_format($sla['min'], $config['graph_precision']);
$row[] = round($sla['sla_limit'], 2) . "%";
if ($sla['sla_value_unknown']) {
@ -378,7 +380,7 @@ function reporting_html_SLA($table, $item, $mini) {
$row = array();
$row[] = $sla['agent'];
$row[] = $sla['module'];
$row[] = $sla['max'] . " / " . $sla['min'];
$row[] = number_format($sla['max'], $config['graph_precision']) . " / " . number_format($sla['min'], $config['graph_precision']);
$row[] = round($sla['sla_limit'], 2) . "%";
if ($sla['sla_value_unknown']) {
@ -1472,6 +1474,8 @@ function reporting_html_sql_graph($table, $item) {
}
function reporting_html_monitor_report($table, $item, $mini) {
global $config;
if ($mini) {
$font_size = '1.5';
}
@ -1496,13 +1500,13 @@ function reporting_html_monitor_report($table, $item, $mini) {
'<p style="font: bold ' . $font_size . 'em Arial, Sans-serif; color: ' . COL_NORMAL . ';">';
$table1->data['data']['ok'] .=
html_print_image("images/module_ok.png", true) . ' ' .
__('OK') . ': ' . $item['data']["ok"]["formated_value"].' %</p>';
__('OK') . ': ' . number_format($item['data']["ok"]["formated_value"], $config['graph_precision']).' %</p>';
$table1->data['data']['fail'] =
'<p style="font: bold ' . $font_size . 'em Arial, Sans-serif; color: ' . COL_CRITICAL . ';">';
$table1->data['data']['fail'] .=
html_print_image("images/module_critical.png", true) . ' ' .
__('Not OK') . ': ' . $item['data']["fail"]["formated_value"] . ' % ' . '</p>';
__('Not OK') . ': ' . number_format($item['data']["fail"]["formated_value"], $config['graph_precision']) . ' % ' . '</p>';
}
$table->data['module']['cell'] = html_print_table($table1, true);
@ -1690,6 +1694,8 @@ function reporting_html_availability(&$table, $item) {
$hide_notinit_agent = $style['hide_notinit_agents'];
$same_agent_in_resume = "";
global $config;
if (!empty($item["data"])) {
$table1 = new stdClass();
$table1->width = '99%';
@ -1738,10 +1744,10 @@ function reporting_html_availability(&$table, $item) {
$table_row[] = $row['availability_item'];
$table_row[] = $row['checks'];
$table_row[] = $row['failed'];
$table_row[] = $row['fail'];
$table_row[] = number_format($row['fail'], $config['graph_precision']);
$table_row[] = $row['poling_time'];
$table_row[] = $row['time_unavaliable'];
$table_row[] = $row['ok'];
$table_row[] = number_format($row['ok'], $config['graph_precision']);
}
else {
if ($item['date']['to'] > $the_first_men_time) {
@ -1750,10 +1756,10 @@ function reporting_html_availability(&$table, $item) {
$table_row[] = $row['availability_item'];
$table_row[] = $row['checks'];
$table_row[] = $row['failed'];
$table_row[] = $row['fail'];
$table_row[] = number_format($row['fail'], $config['graph_precision']);
$table_row[] = $row['poling_time'];
$table_row[] = $row['time_unavaliable'];
$table_row[] = $row['ok'];
$table_row[] = number_format($row['ok'], $config['graph_precision']);
}
else {
$same_agent_in_resume = $row['agent'];
@ -1803,10 +1809,10 @@ function reporting_html_availability(&$table, $item) {
$table1->data[] = array(
'max_text' => $item['resume']['min_text'],
'max' => format_numeric($item['resume']['max'], 2) . "%",
'avg' => format_numeric($item['resume']['avg'], 2) . "%",
'max' => number_format($item['resume']['max'], $config['graph_precision']) . "%",
'avg' => number_format($item['resume']['avg'], $config['graph_precision']) . "%",
'min_text' => $item['resume']['max_text'],
'min' => format_numeric($item['resume']['min'], 2) . "%"
'min' => number_format($item['resume']['min'], $config['graph_precision']) . "%"
);
$table->colspan[2][0] = 3;

View File

@ -802,7 +802,6 @@ function visual_map_print_item($mode = "read", $layoutData,
break;
}
$class = "item ";
switch ($type) {
case STATIC_GRAPH:
@ -1009,9 +1008,23 @@ function visual_map_print_item($mode = "read", $layoutData,
$value = visual_map_get_simple_value($type,
$layoutData['id_agente_modulo'], $period);
// If the value is a string, dont format it
if (!is_string($value)) {
$value = format_for_graph($value, 2);
global $config;
if ($type == SIMPLE_VALUE) {
$returnValue_value = explode('&nbsp;', $value);
if ($returnValue_value[1] != "") {
$value = number_format($returnValue_value[0], $config['graph_precision']) . " " . $returnValue_value[1];
}
else {
$value = number_format($returnValue_value[0], $config['graph_precision']);
}
}
else {
// If the value is a string, dont format it
if (!is_string($value)) {
$value = format_for_graph($value, $config['graph_precision']);
}
}
$io_safe_output_text = str_replace(array('_VALUE_','_value_'), $value, $io_safe_output_text);

View File

@ -537,7 +537,7 @@ function flot_custom_pie_chart ($flash_charts, $graph_values,
$no_data,$xaxisname, $yaxisname, $water_mark, $fontpath, $font_size,
$unit, $ttl, $homeurl, $background_color, $legend_position) {
global $config;
///TODO
include_javascript_dependencies_flot_graph();
@ -547,9 +547,9 @@ function flot_custom_pie_chart ($flash_charts, $graph_values,
foreach ($graph_values as $label => $value) {
if ($value['value']) {
if ($value['value'] > 1000000)
$legendvalue = sprintf("%sM", number_format($value['value'] / 1000000, 2));
$legendvalue = sprintf("%sM", number_format($value['value'] / 1000000, $config['graph_precision']));
else if ($value['value'] > 1000)
$legendvalue = sprintf("%sK", number_format($value['value'] / 1000, 2));
$legendvalue = sprintf("%sK", number_format($value['value'] / 1000, $config['graph_precision']));
else
$legendvalue = $value['value'];
}

View File

@ -1242,12 +1242,12 @@ if (!empty($result)) {
$salida = $config['render_proc_fail'];
break;
default:
$salida = format_numeric($row['datos']);
$salida = number_format($row['datos'], $config['graph_precision']);
break;
}
}
else {
$salida = format_numeric($row['datos']);
$salida = number_format($row['datos'], $config['graph_precision']);
}
// Show units ONLY in numeric data types