changes in module data formatting when printed across the application and new setup options
This commit is contained in:
parent
b386da7da6
commit
5880bec88a
|
@ -0,0 +1,5 @@
|
|||
START TRANSACTION;
|
||||
|
||||
INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_module_units', '{"bytes":"bytes","entries":"entries","files":"files","hits":"hits","sessions":"sessions","users":"users","ºC":"ºC","ºF":"ºF"}');
|
||||
|
||||
COMMIT;
|
|
@ -1003,6 +1003,10 @@ $row++;
|
|||
$table_other->class = 'databox filters';
|
||||
$table_other->style[0] = 'font-weight: bold;';
|
||||
$table_other->size[0] = '50%';
|
||||
$table_other->size[1] = '26%';
|
||||
$table_other->size[2] = '12%';
|
||||
$table_other->size[3] = '12%';
|
||||
|
||||
$table_other->data = [];
|
||||
|
||||
// Enrique (27/01/2017) New feature: Show report info on top of reports
|
||||
|
@ -1134,7 +1138,7 @@ $row++;
|
|||
'graphviz_bin_dir',
|
||||
$config['graphviz_bin_dir'],
|
||||
'',
|
||||
50,
|
||||
25,
|
||||
255,
|
||||
true
|
||||
);
|
||||
|
@ -1192,16 +1196,15 @@ $row++;
|
|||
// CUSTOM VALUES POST PROCESS
|
||||
// ----------------------------------------------------------------------
|
||||
$table_other->data[$row][0] = __('Custom values post process');
|
||||
$table_other->data[$row][1] = '<table>';
|
||||
$table_other->data[$row][1] .= __('Value').': '.html_print_input_text('custom_value', '', '', 25, 50, true);
|
||||
$table_other->data[$row][1] .= ' '.__('Text').': '.html_print_input_text('custom_text', '', '', 25, 50, true);
|
||||
$table_other->data[$row][1] .= ' ';
|
||||
$table_other->data[$row][1] .= html_print_input_hidden(
|
||||
$table_other->data[$row][1] = __('Value').': '.html_print_input_text('custom_value', '', '', 25, 50, true);
|
||||
$table_other->data[$row][2] = __('Text').': '.html_print_input_text('custom_text', '', '', 15, 50, true);
|
||||
$table_other->data[$row][2] .= ' ';
|
||||
$table_other->data[$row][2] .= html_print_input_hidden(
|
||||
'custom_value_add',
|
||||
'',
|
||||
true
|
||||
);
|
||||
$table_other->data[$row][1] .= html_print_button(
|
||||
$table_other->data[$row][3] = html_print_button(
|
||||
__('Add'),
|
||||
'custom_value_add_btn',
|
||||
false,
|
||||
|
@ -1210,10 +1213,11 @@ $row++;
|
|||
true
|
||||
);
|
||||
|
||||
$table_other->data[$row][1] .= '<br /><br />';
|
||||
$row++;
|
||||
|
||||
$table_other->data[$row][1] .= __('Delete custom values').': ';
|
||||
$table_other->data[$row][1] .= html_print_select(
|
||||
$table_other->data[$row][0] = '';
|
||||
$table_other->data[$row][1] = __('Delete custom values').': ';
|
||||
$table_other->data[$row][2] = html_print_select(
|
||||
post_process_get_custom_values(),
|
||||
'custom_values',
|
||||
'',
|
||||
|
@ -1223,7 +1227,7 @@ $row++;
|
|||
true
|
||||
);
|
||||
$count_custom_postprocess = post_process_get_custom_values();
|
||||
$table_other->data[$row][1] .= html_print_button(
|
||||
$table_other->data[$row][3] = html_print_button(
|
||||
__('Delete'),
|
||||
'custom_values_del_btn',
|
||||
empty($count_custom_postprocess),
|
||||
|
@ -1237,7 +1241,8 @@ $row++;
|
|||
'',
|
||||
true
|
||||
);
|
||||
$table_other->data[$row][1] .= '</table>';
|
||||
$table_other->data[$row][3] .= '<br><br>';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------
|
||||
// CUSTOM INTERVAL VALUES
|
||||
|
@ -1252,22 +1257,51 @@ $row++;
|
|||
SECONDS_1MONTH => __('months'),
|
||||
SECONDS_1YEAR => __('years'),
|
||||
];
|
||||
$table_other->data[$row][1] = __('Add new custom value to intervals').': ';
|
||||
$table_other->data[$row][1] = __('Value').': ';
|
||||
$table_other->data[$row][1] .= html_print_input_text('interval_value', '', '', 5, 5, true);
|
||||
$table_other->data[$row][1] .= html_print_select($units, 'interval_unit', 1, '', '', '', true, false, false);
|
||||
$table_other->data[$row][1] .= html_print_button(__('Add'), 'interval_add_btn', false, '', 'class="sub next"', true);
|
||||
$table_other->data[$row][1] .= '<br><br>';
|
||||
$table_other->data[$row][2] = html_print_select($units, 'interval_unit', 1, '', '', '', true, false, false);
|
||||
$table_other->data[$row][3] = html_print_button(__('Add'), 'interval_add_btn', false, '', 'class="sub next"', true);
|
||||
|
||||
$table_other->data[$row][1] .= __('Delete interval').': ';
|
||||
$table_other->data[$row][1] .= html_print_select(get_periods(false, false), 'intervals', '', '', '', '', true);
|
||||
$table_other->data[$row][1] .= html_print_button(__('Delete'), 'interval_del_btn', empty($config['interval_values']), '', 'class="sub cancel"', true);
|
||||
$row++;
|
||||
|
||||
$table_other->data[$row][0] = '';
|
||||
$table_other->data[$row][1] = __('Delete interval').': ';
|
||||
$table_other->data[$row][2] = html_print_select(get_periods(false, false), 'intervals', '', '', '', '', true);
|
||||
$table_other->data[$row][3] = html_print_button(__('Delete'), 'interval_del_btn', empty($config['interval_values']), '', 'class="sub cancel"', true);
|
||||
|
||||
$table_other->data[$row][1] .= html_print_input_hidden('interval_values', $config['interval_values'], true);
|
||||
// This hidden field will be filled from jQuery before submit
|
||||
$table_other->data[$row][1] .= html_print_input_hidden('interval_to_delete', '', true);
|
||||
$table_other->data[$row][3] .= '<br><br>';
|
||||
// ----------------------------------------------------------------------
|
||||
$row++;
|
||||
|
||||
$table_other->data[$row][0] = __('Module units');
|
||||
$table_other->data[$row][1] = __('Value').': ';
|
||||
$table_other->data[$row][1] .= html_print_input_text('custom_module_unit', '', '', 15, 50, true);
|
||||
$table_other->data[$row][2] = '';
|
||||
$table_other->data[$row][3] = html_print_button(__('Add'), 'module_unit_add_btn', false, '', 'class="sub next"', true);
|
||||
|
||||
$row++;
|
||||
$table_other->data[$row][0] = '';
|
||||
$table_other->data[$row][1] = __('Delete custom values').': ';
|
||||
$table_other->data[$row][2] = html_print_select(get_custom_module_units(), 'module_units', '', '', '', '', true, false, true, 'w100p');
|
||||
$table_other->data[$row][3] = html_print_button(
|
||||
__('Delete'),
|
||||
'custom_module_unit_del_btn',
|
||||
empty($count_custom_postprocess),
|
||||
'',
|
||||
'class="sub cancel"',
|
||||
true
|
||||
);
|
||||
$table_other->data[$row][3] .= html_print_input_hidden(
|
||||
'custom_module_unit_to_delete',
|
||||
'',
|
||||
true
|
||||
);
|
||||
|
||||
$row++;
|
||||
|
||||
$common_dividers = [
|
||||
';' => ';',
|
||||
',' => ',',
|
||||
|
@ -1284,6 +1318,14 @@ $row++;
|
|||
|
||||
$row++;
|
||||
|
||||
$table_other->data[$row][0] = __('Data multiplier to use in graphs/data');
|
||||
$options_data_multiplier = [];
|
||||
$options_data_multiplier[0] = __('Use 1024 when module unit are bytes');
|
||||
$options_data_multiplier[1] = __('Use always 1000');
|
||||
$options_data_multiplier[2] = __('Use always 1024');
|
||||
|
||||
$table_other->data[$row][1] = html_print_select($options_data_multiplier, 'use_data_multiplier', $config['use_data_multiplier'], '', '', 0, true, false, false);
|
||||
|
||||
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.__('Other configuration').' '.ui_print_help_icon('other_conf_tab', true).'</legend>';
|
||||
|
@ -1500,7 +1542,20 @@ $(document).ready (function () {
|
|||
});
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// CUSTOM MODULE UNITS
|
||||
//------------------------------------------------------------------
|
||||
$("#button-custom_module_unit_del_btn").click( function() {
|
||||
var unit_selected = $('#module_units option:selected').val();
|
||||
$('#hidden-custom_module_unit_to_delete').val(unit_selected);
|
||||
$('#submit-update_button').trigger('click');
|
||||
});
|
||||
|
||||
$("#button-module_unit_add_btn").click( function() {
|
||||
$('#submit-update_button').trigger('click');
|
||||
});
|
||||
//------------------------------------------------------------------
|
||||
|
||||
// Juanma (06/05/2014) New feature: Custom front page for reports
|
||||
var custom_report = $('#checkbox-custom_report_front')
|
||||
.prop('checked');
|
||||
|
|
|
@ -438,20 +438,16 @@ switch ($action) {
|
|||
|| ($layoutData['type'] == PERCENTILE_BUBBLE)
|
||||
) {
|
||||
if ($value_show == 'value') {
|
||||
$returnValue = format_for_graph($returnValue, 2);
|
||||
|
||||
$unit_text_db = db_get_sql(
|
||||
'SELECT unit
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']
|
||||
);
|
||||
$unit_text_db = trim(io_safe_output($unit_text_db));
|
||||
|
||||
if ($value_show == 'value') {
|
||||
// Set empty string unit at the moment
|
||||
// and change for old false value
|
||||
$unit_text = '';
|
||||
}
|
||||
$divisor = get_data_multiplier($unit_text_db);
|
||||
|
||||
$returnValue = format_for_graph($returnValue, 2, '.', ',', $divisor);
|
||||
|
||||
if (!empty($unit_text_db)) {
|
||||
$unit_text = $unit_text_db;
|
||||
|
|
|
@ -616,7 +616,8 @@ class Tree
|
|||
&& $statusType !== STATUS_MODULE_NO_DATA_BALL
|
||||
) {
|
||||
if (is_numeric($module['value'])) {
|
||||
$statusTitle .= ' : '.format_for_graph($module['value']);
|
||||
$divisor = get_data_multiplier($module['unit']);
|
||||
$statusTitle .= ' : '.format_for_graph($module['value'], 1, '.', ',', $divisor);
|
||||
} else {
|
||||
$statusTitle .= ' : '.substr(io_safe_output($module['value']), 0, 42);
|
||||
}
|
||||
|
@ -1062,7 +1063,7 @@ class Tree
|
|||
|
||||
$columns = 'DISTINCT(tam.id_agente_modulo) AS id, tam.nombre AS name,
|
||||
tam.id_tipo_modulo, tam.id_modulo, tae.estado, tae.datos,
|
||||
tam.parent_module_id AS parent, tatm.id AS alerts';
|
||||
tam.parent_module_id AS parent, tatm.id AS alerts, tam.unit';
|
||||
|
||||
$sql = "SELECT $columns
|
||||
FROM tagente_modulo tam
|
||||
|
|
|
@ -262,6 +262,11 @@ function format_for_graph(
|
|||
$divider=1000,
|
||||
$sufix=''
|
||||
) {
|
||||
// Exception to exclude modules whose unit is already formatted as KB (satellite modules)
|
||||
if (!empty($sufix) && $sufix == 'KB') {
|
||||
return;
|
||||
}
|
||||
|
||||
$shorts = [
|
||||
'',
|
||||
'K',
|
||||
|
@ -5483,3 +5488,108 @@ if (!function_exists('getallheaders')) {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update config token that contains custom module units.
|
||||
*
|
||||
* @param string Name of new module unit.
|
||||
* @return boolean Success or failure.
|
||||
*/
|
||||
function add_custom_module_unit($value)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$custom_module_units = get_custom_module_units();
|
||||
|
||||
$custom_module_units[$value] = $value;
|
||||
|
||||
$new_conf = json_encode($custom_module_units);
|
||||
|
||||
$return = config_update_value(
|
||||
'custom_module_units',
|
||||
$new_conf
|
||||
);
|
||||
|
||||
if ($return) {
|
||||
$config['custom_module_units'] = $new_conf;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_custom_module_units()
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (!isset($config['custom_module_units'])) {
|
||||
$custom_module_units = [];
|
||||
} else {
|
||||
$custom_module_units = json_decode(
|
||||
io_safe_output($config['custom_module_units']),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return $custom_module_units;
|
||||
}
|
||||
|
||||
|
||||
function delete_custom_module_unit($value)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$custom_units = get_custom_module_units();
|
||||
|
||||
unset($custom_units[$value]);
|
||||
|
||||
$new_conf = json_encode($custom_units);
|
||||
$return = config_update_value(
|
||||
'custom_module_units',
|
||||
$new_conf
|
||||
);
|
||||
|
||||
if ($return) {
|
||||
$config['custom_module_units'] = $new_conf;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get multiplier to be applied on module data in order to represent it properly. Based on setup configuration and module's unit, either 1000 or 1024 will be returned.
|
||||
*
|
||||
* @param string Module's unit.
|
||||
*
|
||||
* @return integer Multiplier.
|
||||
*/
|
||||
function get_data_multiplier($unit)
|
||||
{
|
||||
global $config;
|
||||
|
||||
switch ($config['use_data_multiplier']) {
|
||||
case 0:
|
||||
if (strpos($unit, 'yte') !== false) {
|
||||
$multiplier = 1024;
|
||||
} else {
|
||||
$multiplier = 1000;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$multiplier = 1024;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
default:
|
||||
$multiplier = 1000;
|
||||
break;
|
||||
}
|
||||
|
||||
return $multiplier;
|
||||
}
|
||||
|
|
|
@ -1279,6 +1279,28 @@ function config_update_config()
|
|||
$error_update[] = __('Delete interval');
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
// --------------------------------------------------
|
||||
// MODULE CUSTOM UNITS
|
||||
// --------------------------------------------------
|
||||
$custom_unit = get_parameter('custom_module_unit');
|
||||
$custom_unit_to_delete = get_parameter('custom_module_unit_to_delete', '');
|
||||
|
||||
if (!empty($custom_unit)) {
|
||||
if (!add_custom_module_unit(
|
||||
$custom_unit
|
||||
)
|
||||
) {
|
||||
$error_update[] = __('Add custom module unit');
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($custom_unit_to_delete)) {
|
||||
if (!delete_custom_module_unit($custom_unit_to_delete)) {
|
||||
$error_update[] = __('Delete custom module unit');
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------
|
||||
if (!config_update_value('custom_report_info', get_parameter('custom_report_info'))) {
|
||||
$error_update[] = __('Custom report info');
|
||||
|
@ -1316,6 +1338,10 @@ function config_update_config()
|
|||
if (!config_update_value('csv_divider', (string) get_parameter('csv_divider', ';'))) {
|
||||
$error_update[] = __('CSV divider');
|
||||
}
|
||||
|
||||
if (!config_update_value('use_data_multiplier', get_parameter('use_data_multiplier', ';'))) {
|
||||
$error_update[] = __('Use data multiplier');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'net':
|
||||
|
@ -2804,6 +2830,10 @@ function config_process_config()
|
|||
config_update_value('csv_divider', ';');
|
||||
}
|
||||
|
||||
if (!isset($config['use_data_multiplier'])) {
|
||||
config_update_value('use_data_multiplier', ';');
|
||||
}
|
||||
|
||||
if (!isset($config['command_snapshot'])) {
|
||||
config_update_value('command_snapshot', 1);
|
||||
}
|
||||
|
|
|
@ -572,7 +572,7 @@ function grafico_modulo_sparse_data(
|
|||
|
||||
|
||||
/**
|
||||
* Functions tu create graphs.
|
||||
* Functions to create graphs.
|
||||
*
|
||||
* @param array $params Details builds graphs. For example:
|
||||
* 'agent_module_id' => $agent_module_id,
|
||||
|
@ -856,6 +856,10 @@ function grafico_modulo_sparse($params)
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($params['divisor'])) {
|
||||
$params['divisor'] = get_data_multiplier($params['unit']);
|
||||
}
|
||||
|
||||
if (!$params['array_data_create']) {
|
||||
if ($params['baseline']) {
|
||||
$array_data = get_baseline_data(
|
||||
|
@ -1467,6 +1471,10 @@ function graphic_combined_module(
|
|||
$data_module_graph['module_id'] = $agent_module_id;
|
||||
$data_module_graph['unit'] = $module_data['unit'];
|
||||
|
||||
$params['unit'] = $module_data['unit'];
|
||||
|
||||
$params['divisor'] = get_data_multiplier($params['unit']);
|
||||
|
||||
// Stract data.
|
||||
$array_data_module = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
|
|
|
@ -798,6 +798,10 @@ function html_print_extended_select_for_unit(
|
|||
$fields['_timeticks_'] = 'Timeticks';
|
||||
$fields['none'] = __('none');
|
||||
|
||||
$default_module_custom_units = get_custom_module_units();
|
||||
|
||||
$fields = array_merge($fields, $default_module_custom_units);
|
||||
|
||||
if ($no_change != 0) {
|
||||
$fields[-1] = __('No change');
|
||||
}
|
||||
|
|
|
@ -1557,7 +1557,10 @@ function reporting_event_top_n(
|
|||
$data['module'] = $module_name[$i];
|
||||
|
||||
$data['value'] = $dt;
|
||||
$data['formated_value'] = format_for_graph($dt, 2).' '.$units[$i];
|
||||
|
||||
$divisor = get_data_multiplier($units[$i]);
|
||||
|
||||
$data['formated_value'] = format_for_graph($dt, 2, '.', ',', $divisor, $units[$i]);
|
||||
$data_return[] = $data;
|
||||
}
|
||||
|
||||
|
@ -1610,12 +1613,15 @@ function reporting_event_top_n(
|
|||
|
||||
$data_pie_graph[$item_name] = $data_top[$i];
|
||||
$data_hbar[$item_name]['g'] = $data_top[$i];
|
||||
|
||||
$divisor = get_data_multiplier($units[$i]);
|
||||
|
||||
if ($show_graph == 0 || $show_graph == 1) {
|
||||
$data = [];
|
||||
$data['agent'] = $an;
|
||||
$data['module'] = $module_name[$i];
|
||||
$data['value'] = $data_top[$i];
|
||||
$data['formated_value'] = format_for_graph($data_top[$i], 2).' '.$units[$i];
|
||||
$data['formated_value'] = format_for_graph($data_top[$i], 2, '.', ',', $divisor, $units[$i]);
|
||||
$data_return[] = $data;
|
||||
}
|
||||
|
||||
|
@ -1691,14 +1697,15 @@ function reporting_event_top_n(
|
|||
$i++;
|
||||
}
|
||||
|
||||
$unit = $data_top_values['units'][0];
|
||||
$avg = ($avg / $i);
|
||||
|
||||
$return['resume']['min']['value'] = $min;
|
||||
$return['resume']['min']['formated_value'] = format_for_graph($min, 2);
|
||||
$return['resume']['min']['formated_value'] = format_for_graph($min, 2, '.', ',', $divisor, $unit);
|
||||
$return['resume']['avg']['value'] = $avg;
|
||||
$return['resume']['avg']['formated_value'] = format_for_graph($avg, 2);
|
||||
$return['resume']['avg']['formated_value'] = format_for_graph($avg, 2, '.', ',', $divisor, $unit);
|
||||
$return['resume']['max']['value'] = $max;
|
||||
$return['resume']['max']['formated_value'] = format_for_graph($max, 2);
|
||||
$return['resume']['max']['formated_value'] = format_for_graph($max, 2, '.', ',', $divisor, $unit);
|
||||
}
|
||||
|
||||
$return['data'] = $data_return;
|
||||
|
@ -4787,6 +4794,8 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
case 'max':
|
||||
case 'min':
|
||||
case 'avg':
|
||||
$divisor = get_data_multiplier($unit);
|
||||
|
||||
if ($content['lapse_calc'] == 0) {
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
|
@ -4817,7 +4826,7 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
if (!$config['simple_module_value']) {
|
||||
$formated_value = $value;
|
||||
} else {
|
||||
$formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit;
|
||||
$formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
}
|
||||
} else {
|
||||
$return['visual_format'] = $content['visual_format'];
|
||||
|
@ -4825,17 +4834,17 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
switch ($type) {
|
||||
case 'max':
|
||||
$params['force_interval'] = 'max_only';
|
||||
$value = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit;
|
||||
$value = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
break;
|
||||
|
||||
case 'min':
|
||||
$params['force_interval'] = 'min_only';
|
||||
$value = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit;
|
||||
$value = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
break;
|
||||
|
||||
case 'avg':
|
||||
$params['force_interval'] = 'avg_only';
|
||||
$value = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision']).' '.$unit;
|
||||
$value = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['period'], $report['datetime']), $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4860,15 +4869,15 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
if ($i > $time_begin['utimestamp']) {
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit;
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
break;
|
||||
|
||||
case 'min':
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit;
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
break;
|
||||
|
||||
case 'avg':
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit;
|
||||
$row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -4897,7 +4906,9 @@ function reporting_value($report, $content, $type, $pdf=false)
|
|||
if (!$config['simple_module_value']) {
|
||||
$formated_value = $value;
|
||||
} else {
|
||||
$formated_value = format_for_graph($value, $config['graph_precision']).' '.$unit;
|
||||
$divisor = get_data_multiplier($unit);
|
||||
|
||||
$formated_value = format_for_graph($value, $config['graph_precision'], '.', ',', $divisor, $unit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -7211,6 +7222,8 @@ function reporting_general($report, $content)
|
|||
}
|
||||
}
|
||||
|
||||
$divisor = get_data_multiplier($unit);
|
||||
|
||||
switch ($content['group_by_agent']) {
|
||||
case REPORT_GENERAL_NOT_GROUP_BY_AGENT:
|
||||
$id_agent_module[$index] = $row['id_agent_module'];
|
||||
|
@ -7241,7 +7254,7 @@ function reporting_general($report, $content)
|
|||
if (!is_numeric($data_res[$index])) {
|
||||
$return['data'][$name_agent][$mod_name] = $data_res[$index];
|
||||
} else {
|
||||
$return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$index], 2).' '.$unit;
|
||||
$return['data'][$name_agent][$mod_name] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -7260,7 +7273,7 @@ function reporting_general($report, $content)
|
|||
|
||||
if ($change_min) {
|
||||
$return['min']['value'] = $data_res[$index];
|
||||
$return['min']['formated_value'] = format_for_graph($data_res[$index], 2).' '.$unit;
|
||||
$return['min']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
|
||||
$return['min']['agent'] = $ag_name;
|
||||
$return['min']['module'] = $mod_name;
|
||||
}
|
||||
|
@ -7276,7 +7289,7 @@ function reporting_general($report, $content)
|
|||
|
||||
if ($change_max) {
|
||||
$return['max']['value'] = $data_res[$index];
|
||||
$return['max']['formated_value'] = format_for_graph($data_res[$index], 2).' '.$unit;
|
||||
$return['max']['formated_value'] = format_for_graph($data_res[$index], 2, '.', ',', $divisor, $unit);
|
||||
$return['max']['agent'] = $ag_name;
|
||||
$return['max']['module'] = $mod_name;
|
||||
}
|
||||
|
@ -7394,13 +7407,15 @@ function reporting_general($report, $content)
|
|||
break;
|
||||
}
|
||||
|
||||
$divisor = get_data_multiplier($units[$i]);
|
||||
|
||||
if (!is_numeric($d) || $is_string[$i]) {
|
||||
$data['value'] = $d;
|
||||
// to see the chains on the table
|
||||
$data['formated_value'] = $d;
|
||||
} else {
|
||||
$data['value'] = $d;
|
||||
$data['formated_value'] = format_for_graph($d, 2).' '.$units[$i];
|
||||
$data['formated_value'] = format_for_graph($d, 2, '.', ',', $divisor, $units[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1052,6 +1052,11 @@ function pandoraFlotArea(
|
|||
var update_legend = {};
|
||||
var force_integer = 0;
|
||||
var title = params.title;
|
||||
var divisor = params.divisor;
|
||||
|
||||
if (typeof divisor === "undefined") {
|
||||
divisor = 1000;
|
||||
}
|
||||
|
||||
if (typeof type === "undefined" || type == "") {
|
||||
type = params.type_graph;
|
||||
|
@ -2458,11 +2463,6 @@ function pandoraFlotArea(
|
|||
}
|
||||
}
|
||||
|
||||
var y_array = format_unit_yaxes(y);
|
||||
|
||||
y = y_array["y"];
|
||||
var how_bigger = y_array["unit"];
|
||||
|
||||
var data_legend = [];
|
||||
|
||||
// The graphs of points type and unknown graphs will dont be updated
|
||||
|
@ -2480,10 +2480,7 @@ function pandoraFlotArea(
|
|||
.html(
|
||||
label_aux +
|
||||
" value = " +
|
||||
(short_data
|
||||
? number_format(y, 0, "", short_data)
|
||||
: parseFloat(y)) +
|
||||
how_bigger +
|
||||
number_format(y, 0, "", short_data, divisor) +
|
||||
" " +
|
||||
unit
|
||||
);
|
||||
|
@ -2531,20 +2528,11 @@ function pandoraFlotArea(
|
|||
|
||||
data_legend[index] =
|
||||
" Min: " +
|
||||
(short_data
|
||||
? number_format(min_y, 0, "", short_data)
|
||||
: parseFloat(min_y)) +
|
||||
min_bigger +
|
||||
number_format(value[x].min, 0, unit, short_data, divisor) +
|
||||
" Max: " +
|
||||
(short_data
|
||||
? number_format(max_y, 0, "", short_data)
|
||||
: parseFloat(max_y)) +
|
||||
max_bigger +
|
||||
number_format(value[x].max, 0, unit, short_data, divisor) +
|
||||
" Avg: " +
|
||||
(short_data
|
||||
? number_format(avg_y, 0, "", short_data)
|
||||
: parseFloat(avg_y)) +
|
||||
avg_bigger;
|
||||
number_format(value[x].avg, 0, unit, short_data, divisor);
|
||||
});
|
||||
|
||||
label_aux =
|
||||
|
@ -2749,12 +2737,13 @@ function pandoraFlotArea(
|
|||
|
||||
function yFormatter(v) {
|
||||
var formatted = v;
|
||||
|
||||
if (short_data) {
|
||||
formatted = number_format(v, force_integer, "", short_data);
|
||||
formatted = number_format(v, force_integer, unit, short_data, divisor);
|
||||
} else {
|
||||
// It is an integer.
|
||||
if (v - Math.floor(v) == 0) {
|
||||
formatted = number_format(v, force_integer, "", 2);
|
||||
formatted = number_format(v, force_integer, unit, 2, divisor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3082,7 +3071,18 @@ function check_adaptions(graph_id) {
|
|||
});
|
||||
}
|
||||
|
||||
function number_format(number, force_integer, unit, short_data) {
|
||||
function number_format(number, force_integer, unit, short_data, divisor) {
|
||||
divisor = typeof divisor !== "undefined" ? divisor : 1000;
|
||||
|
||||
if (unit == "KB") {
|
||||
return number + unit;
|
||||
}
|
||||
|
||||
// Set maximum decimal precision to 99 in case short_data is not set.
|
||||
if (!short_data) {
|
||||
short_data = 99;
|
||||
}
|
||||
|
||||
if (force_integer) {
|
||||
if (Math.round(number) != number) {
|
||||
return "";
|
||||
|
@ -3095,17 +3095,15 @@ function number_format(number, force_integer, unit, short_data) {
|
|||
|
||||
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||
var pos = 0;
|
||||
while (1) {
|
||||
if (number >= 1000) {
|
||||
//as long as the number can be divided by 1000
|
||||
pos++; //Position in array starting with 0
|
||||
number = number / 1000;
|
||||
} else if (number <= -1000) {
|
||||
pos++;
|
||||
number = number / 1000;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
while (number >= divisor) {
|
||||
// As long as the number can be divided by 1000 or 1024.
|
||||
pos++;
|
||||
number = number / divisor;
|
||||
}
|
||||
|
||||
if (divisor) {
|
||||
number = Math.round(number * decimals) / decimals;
|
||||
}
|
||||
|
||||
return number + " " + shorts[pos] + unit;
|
||||
|
|
|
@ -140,7 +140,8 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
|
|||
('cr_incident_title', ''),
|
||||
('cr_incident_content', ''),
|
||||
('sample_agent', '0'),
|
||||
('gotty', '/usr/bin/gotty');
|
||||
('gotty', '/usr/bin/gotty'),
|
||||
('custom_module_units', '{"bytes":"bytes","entries":"entries","files":"files","hits":"hits","sessions":"sessions","users":"users","ºC":"ºC","ºF":"ºF"}');
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
|
|
Loading…
Reference in New Issue