New data precision... (Init)

(cherry picked from commit d5f82b568c)
This commit is contained in:
Arturo Gonzalez 2016-10-18 10:32:10 +02:00
parent b4419db311
commit 9a0f12d9b4
10 changed files with 1203 additions and 69 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

@ -177,7 +177,7 @@ if ($get_module_detail) {
"Data" => array(
"data",
"modules_format_data",
"align" => "center",
"align" => "left",
"width" => "230px"),
);
@ -185,14 +185,14 @@ if ($get_module_detail) {
$columns["Time"] = array(
"utimestamp",
"modules_format_time",
"align" => "center",
"align" => "left",
"width" => "50px");
}
else {
$columns["Timestamp"] = array(
"utimestamp",
"modules_format_timestamp",
"align" => "center",
"align" => "left",
"width" => "50px");
}
@ -249,7 +249,7 @@ if ($get_module_detail) {
foreach ($columns as $col => $attr) {
if ($attr[1] != "modules_format_data") {
$data[] = date('d F Y - h:i:s A', $row['utimestamp']);
$data[] = $attr[1] ($row[$attr[0]]);
}
elseif (($config['command_snapshot']) && (preg_match ("/[\n]+/i", $row[$attr[0]]))) {
@ -283,27 +283,15 @@ if ($get_module_detail) {
$data[] = io_safe_input($row[$attr[0]]);
}
else if (is_numeric($row[$attr[0]]) && !modules_is_string_type($row['module_type']) ) {
switch($row['module_type']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id);
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0')
$data[] = human_milliseconds_to_string($row['data']);
else
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
break;
default:
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
break;
}
//~ $data[] = (double) $row[$attr[0]];
$data[] = (double) $row[$attr[0]];
}
else {
if ($row[$attr[0]] == '') {
$data[] = 'No data';
}
else {
$data[] = "<a target='_blank' href='".io_safe_input($row[$attr[0]])."'><img style='width:300px' src='".io_safe_input($row[$attr[0]])."'></a>";
$data[] = io_safe_input($row[$attr[0]]);
}
}
}
@ -866,6 +854,7 @@ if ($list_modules) {
modules_get_status($module['id_agente_modulo'], $module['estado'],
$module_value, $status, $title);
$data[5] = ui_print_status_image($status, $title, true);
if (!$show_context_help_first_time) {
$show_context_help_first_time = true;
@ -875,6 +864,7 @@ if ($list_modules) {
}
}
if ($module["id_tipo_modulo"] == 24) {
// log4x
switch($module["datos"]) {
@ -990,10 +980,8 @@ if ($list_modules) {
base64_encode($module["nombre"]))) . "&amp;" .
"refresh=" . SECONDS_10MINUTES . "&amp;" .
"draw_events=$draw_events', 'day_".$win_handle."')";
if(!is_snapshot_data($module['datos'])){
$data[8] .= '<a href="javascript:'.$link.'">' . html_print_image("images/chart_curve.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
}
$server_name = '';
$data[8] .= "<a href='javascript: " .
"show_module_detail_dialog(" .
@ -1003,7 +991,7 @@ if(!is_snapshot_data($module['datos'])){
0 . ", " .
SECONDS_1DAY . ", \" " . modules_get_agentmodule_name( $module["id_agente_modulo"] ) . "\")'>". html_print_image ("images/binary.png", true, array ("border" => "0", "alt" => "")) . "</a>";
}
if ($module['estado'] == 3) {
$data[9] = '<span class="redb">';
}
@ -1091,4 +1079,4 @@ if ($get_type) {
return;
}
?>
?>

File diff suppressed because it is too large Load Diff

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('&nbsp;', $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

@ -432,6 +432,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);
@ -1429,6 +1431,15 @@ function config_process_config () {
if (!isset($config['interface_unit'])) {
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,
@ -1331,30 +1327,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']);
}
@ -3649,8 +3645,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']) {
@ -1481,6 +1483,8 @@ function reporting_html_sql_graph($table, $item) {
}
function reporting_html_monitor_report($table, $item, $mini) {
global $config;
if ($mini) {
$font_size = '1.5';
}
@ -1505,13 +1509,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);
@ -1699,6 +1703,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%';
@ -1747,10 +1753,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) {
@ -1759,10 +1765,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'];
@ -1812,10 +1818,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

@ -804,7 +804,6 @@ function visual_map_print_item($mode = "read", $layoutData,
break;
}
$class = "item ";
switch ($type) {
case STATIC_GRAPH:
@ -1011,9 +1010,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

@ -535,7 +535,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();
@ -545,9 +545,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

@ -1246,12 +1246,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