Graph and table mode for max, min and avg reports an template reports - #654

This commit is contained in:
enriquecd 2017-10-02 18:23:26 +02:00
parent 0897bbea28
commit f608c686b8
6 changed files with 629 additions and 31 deletions

View File

@ -725,6 +725,9 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`module_free_text` TEXT,
`each_agent` tinyint(1) default 1,
`historical_db` tinyint(1) UNSIGNED NOT NULL default 0,
`lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0',
`lapse` int(11) UNSIGNED NOT NULL default '300',
`visual_format` UNSIGNED NOT NULL tinyint(1) default '0',
PRIMARY KEY(`id_rc`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
@ -1270,6 +1273,9 @@ UPDATE treport_custom_sql SET `sql` = 'select t1.alias as agent_n
-- ---------------------------------------------------------------------
ALTER TABLE treport_content ADD COLUMN `historical_db` tinyint(1) NOT NULL DEFAULT '0';
ALTER TABLE treport_content ADD COLUMN `lapse_calc` tinyint(1) default '0';
ALTER TABLE treport_content ADD COLUMN `lapse` int(11) default '300';
ALTER TABLE treport_content ADD COLUMN `visual_format` tinyint(1) default '0';
-- ---------------------------------------------------------------------
-- Table `tmodule_relationship`

View File

@ -112,6 +112,10 @@ $netflow_filter = 0;
$max_values = 0;
$resolution = 0;
$lapse_calc = 0;
$lapse = 300;
$visual_format = 0;
//Others
$filter_search = "";
@ -195,12 +199,6 @@ switch ($action) {
$name = $item['name'];
switch ($type) {
case 'avg_value':
$period = $item['period'];
$description = $item['description'];
$idAgentModule = $item['id_agent_module'];
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
break;
case 'event_report_log':
$period = $item['period'];
$description = $item['description'];
@ -312,6 +310,9 @@ switch ($action) {
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
$lapse = $item['lapse'];
$lapse_calc = $item['lapse_calc'];
$visual_format = $item['visual_format'];
break;
case 'max_value':
$description = $item['description'];
@ -319,6 +320,9 @@ switch ($action) {
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
$lapse = $item['lapse'];
$lapse_calc = $item['lapse_calc'];
$visual_format = $item['visual_format'];
break;
case 'min_value':
$description = $item['description'];
@ -326,6 +330,9 @@ switch ($action) {
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule));
$idAgentModule = $item['id_agent_module'];
$period = $item['period'];
$lapse = $item['lapse'];
$lapse_calc = $item['lapse_calc'];
$visual_format = $item['visual_format'];
break;
case 'sumatory':
$description = $item['description'];
@ -1580,6 +1587,78 @@ You can of course remove the warnings, that's why we include the source and do n
?>
</td>
</tr>
<!-- advanced elements -->
<!-- <tr id="advanced_expansion">
<td colspan="2" style="cursor:pointer;" onclick="if($('.advanced_elements').css('display') == 'none'){$('.advanced_elements').css('display','table-row');}else{$('.advanced_elements').css('display','none');}">
+ ADVANCED
</td>
</tr> -->
<tr id="row_lapse_calc" style="" class="datos advanced_elements">
<td style="font-weight:bold;">
<?php echo __('Calculate for custom intervals'); ?>
</td>
<td style="">
<?php
html_print_checkbox('lapse_calc',1,$lapse_calc);?>
</td>
</tr>
<tr id="row_lapse" style="" class="datos advanced_elements">
<td style="font-weight:bold;">
<?php
echo __('Time lapse intervals');
ui_print_help_tip(__('Lapses of time in which the period is divided to make more precise calculations
'));
?>
</td>
<td style="">
<?php
html_print_extended_select_for_time('lapse', $lapse,
'', '', '0', 10,'','','','',!$lapse_calc);
?>
</td>
</tr>
<tr id="row_visual_format" style="" class="datos advanced_elements">
<td style="font-weight:bold;" colspan="2">
<?php
if($visual_format == 1){
$visual_format_table = true;
$visual_format_graph = false;
$visual_format_both = false;
}
elseif ($visual_format == 2) {
$visual_format_table = false;
$visual_format_graph = true;
$visual_format_both = false;
}
elseif ($visual_format == 3) {
$visual_format_table = false;
$visual_format_graph = false;
$visual_format_both = true;
}
echo __('Table only').'<span style="margin-left:10px;"></span>';
html_print_radio_button ('visual_format', 1, '', $visual_format_table,'',!$lapse_calc);
echo ('<span style="margin:30px;"></span>');
echo __('Graph only').'<span style="margin-left:10px;"></span>';
html_print_radio_button ('visual_format', 2, '', $visual_format_graph,'',!$lapse_calc);
echo ('<span style="margin:30px;"></span>');
echo __('Graph and table').'<span style="margin-left:10px;"></span>';
html_print_radio_button ('visual_format', 3, '', $visual_format_both,'',!$lapse_calc);
?>
</td>
</tr>
</tbody>
</table>
@ -2211,6 +2290,19 @@ $(document).ready (function () {
}
});
$("#checkbox-lapse_calc").change(function () {
if($(this).is(":checked")){
$( "#lapse_select" ).prop( "disabled", false );
$("[name=visual_format]").prop( "disabled", false );
}
else{
$( "#lapse_select" ).prop( "disabled", true );
$("[name=visual_format]").prop( "disabled", true );
}
});
});
function create_custom_graph() {
@ -2692,6 +2784,9 @@ function chooseType() {
$("#row_show_in_two_columns").hide();
$("#row_show_in_same_row").hide();
$("#row_historical_db_check").hide();
$("#row_lapse_calc").hide();
$("#row_lapse").hide();
$("#row_visual_format").hide();
$("#row_show_in_landscape").hide();
$('#row_hide_notinit_agents').hide();
$("#row_module_group").hide();
@ -2884,6 +2979,9 @@ function chooseType() {
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
$("#row_lapse_calc").show();
$("#row_lapse").show();
$("#row_visual_format").show();
$("#row_historical_db_check").hide();
break;
@ -2893,6 +2991,9 @@ function chooseType() {
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
$("#row_lapse_calc").show();
$("#row_lapse").show();
$("#row_visual_format").show();
$("#row_historical_db_check").hide();
break;
@ -2902,6 +3003,9 @@ function chooseType() {
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_two_columns").show();
$("#row_lapse_calc").show();
$("#row_lapse").show();
$("#row_visual_format").show();
$("#row_historical_db_check").hide();
break;

View File

@ -1069,6 +1069,15 @@ switch ($action) {
$values['period'] = get_parameter('period');
$good_format = true;
break;
case 'min_value':
case 'max_value':
case 'avg_value':
$values['period'] = get_parameter('period');
$values['lapse_calc'] = get_parameter('lapse_calc');
$values['lapse'] = get_parameter('lapse');
$values['visual_format'] = get_parameter('visual_format');
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
@ -1404,6 +1413,15 @@ switch ($action) {
$values['period'] = get_parameter('period');
$good_format = true;
break;
case 'min_value':
case 'max_value':
case 'avg_value':
$values['period'] = get_parameter('period');
$values['lapse_calc'] = get_parameter('lapse_calc');
$values['lapse'] = get_parameter('lapse');
$values['visual_format'] = get_parameter('visual_format');
$good_format = true;
break;
default:
$values['period'] = get_parameter('period');
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);

View File

@ -232,8 +232,8 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
$projection, $avg_only = false, $uncompressed_module = false,
$show_events = false, $show_alerts = false, $show_unknown = false, $baseline = false,
$baseline_data = array(), $events = array(), $series_suffix = '', $start_unknown = false,
$percentil = null, $fullscale = false) {
$percentil = null, $fullscale = false, $force_interval = false,$time_interval = 300,
$max_only = 0, $min_only = 0) {
global $config;
global $chart_extra_data;
global $series_type;
@ -413,10 +413,17 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
}
if ($count > 0) {
if ($avg_only) {
$chart[$timestamp]['sum'.$series_suffix] = $total;
}
else {
else if($max_only){
$chart[$timestamp]['max'.$series_suffix] = $interval_max;
}
else if($min_only){
$chart[$timestamp]['min'.$series_suffix] = $interval_min;
}
else{
$chart[$timestamp]['max'.$series_suffix] = $interval_max;
$chart[$timestamp]['sum'.$series_suffix] = $total;
$chart[$timestamp]['min'.$series_suffix] = $interval_min;
@ -428,7 +435,13 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
if ($avg_only) {
$chart[$timestamp]['sum'.$series_suffix] = 0;
}
else {
else if($max_only){
$chart[$timestamp]['max'.$series_suffix] = 0;
}
else if($min_only){
$chart[$timestamp]['min'.$series_suffix] = 0;
}
else{
$chart[$timestamp]['max'.$series_suffix] = 0;
$chart[$timestamp]['sum'.$series_suffix] = 0;
$chart[$timestamp]['min'.$series_suffix] = 0;
@ -438,6 +451,12 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
if ($avg_only) {
$chart[$timestamp]['sum'.$series_suffix] = $last_known;
}
else if ($max_only) {
$chart[$timestamp]['max'.$series_suffix] = $last_known;
}
else if ($min_only) {
$chart[$timestamp]['min'.$series_suffix] = $last_known;
}
else {
$chart[$timestamp]['max'.$series_suffix] = $last_known;
$chart[$timestamp]['sum'.$series_suffix] = $last_known;
@ -502,7 +521,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$baseline = 0, $return_data = 0, $show_title = true, $projection = false,
$adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '',
$show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false,
$type_graph='area', $fullscale = false, $flash_chart = false) {
$type_graph='area', $fullscale = false, $flash_chart = false, $force_interval = false,$time_interval = 300,
$max_only = 0, $min_only = 0) {
global $config;
global $chart;
@ -529,8 +549,23 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
if ($date == 0) $date = get_system_time();
$datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit);
if($force_interval){
$resolution = $period/$time_interval;
}
else{
$resolution = $config['graph_res'] * 50; //Number of points of the graph
}
if($force_interval){
$interval = $time_interval;
}
else{
$interval = (int) ($period / $resolution);
}
$agent_name = modules_get_agentmodule_agent_name ($agent_module_id);
$agent_id = agents_get_agent_id ($agent_name);
$module_name = modules_get_agentmodule_name ($agent_module_id);
@ -718,7 +753,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$projection, $avg_only, $uncompressed_module,
$show_events, $show_alerts, $show_unknown, $baseline,
$baseline_data, $events, $series_suffix, $start_unknown,
$percentil, $fullscale);
$percentil, $fullscale, $force_interval, $time_interval,
$max_only, $min_only);
}
// Return chart data and don't draw
@ -843,6 +879,19 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$legend['percentil'.$series_suffix] = __('Percentile %dº', $percentil) .$series_suffix_str . " (" . $percentil_value . " " . $unit . ") ";
$chart_extra_data['legend_percentil'] = $legend['percentil'.$series_suffix_str];
}
if($force_interval){
$legend = array();
if($avg_only){
$legend['sum'.$series_suffix] = __('Avg');
}
elseif ($max_only) {
$legend['min'.$series_suffix] = __('Max');
}
elseif ($min_only) {
$legend['max'.$series_suffix] = __('Min');
}
}
}
function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
@ -853,7 +902,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$adapt_key = '', $compare = false, $show_unknown = false,
$menu = true, $backgroundColor = 'white', $percentil = null,
$dashboard = false, $vconsole = false, $type_graph = 'area', $fullscale = false,
$id_widget_dashboard = false) {
$id_widget_dashboard = false,$force_interval = 0,$time_interval = 300,
$max_only = 0, $min_only = 0) {
global $config;
global $graphic_type;
@ -884,7 +935,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$return_data, $show_title, $projection, $adapt_key,
$compare, $series_suffix, $series_suffix_str,
$show_unknown, $percentil, $dashboard, $vconsole,$type_graph,
$fullscale, $flash_chart);
$fullscale, $flash_chart,$force_interval,$time_interval,$max_only,$min_only);
switch ($compare) {
case 'separated':
@ -917,7 +968,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$show_alerts, $avg_only,
$date, $unit, $baseline, $return_data, $show_title,
$projection, $adapt_key, $compare, '', '', $show_unknown,
$percentil, $dashboard, $vconsole, $type_graph, $fullscale, $flash_chart);
$percentil, $dashboard, $vconsole, $type_graph, $fullscale,$flash_chart,
$force_interval,$time_interval,$max_only,$min_only);
if ($return_data) {
return $data_returned;
}

View File

@ -190,6 +190,9 @@ function reporting_make_reporting_data($report = null, $id_report,
$items_label['id_agent_module'] = $content['id_agent_module'];
$items_label['modules'] = $modules_to_macro;
$items_label['agents'] = $agents_to_macro;
$items_label['visual_format'] = $visual_format;
$metaconsole_on = is_metaconsole();
$server_name = $content['server_name'];
//Metaconsole connection
if ($metaconsole_on && $server_name != '') {
@ -290,19 +293,19 @@ function reporting_make_reporting_data($report = null, $id_report,
$report['contents'][] = reporting_value(
$report,
$content,
'max');
'max',$pdf);
break;
case 'avg_value':
$report['contents'][] = reporting_value(
$report,
$content,
'avg');
'avg',$pdf);
break;
case 'min_value':
$report['contents'][] = reporting_value(
$report,
$content,
'min');
'min',$pdf);
break;
case 'sumatory':
$report['contents'][] = reporting_value(
@ -3752,7 +3755,7 @@ function reporting_agent_configuration($report, $content) {
return reporting_check_structure_content($return);
}
function reporting_value($report, $content, $type) {
function reporting_value($report, $content, $type,$pdf) {
global $config;
$return = array();
@ -3837,8 +3840,17 @@ function reporting_value($report, $content, $type) {
$return['agent_name'] = $agent_name;
$return['module_name'] = $module_name;
html_debug($pdf,true);
html_debug($only_image,true);
if($pdf){
$only_image = 1;
}
switch ($type) {
case 'max':
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
@ -3847,18 +3859,286 @@ function reporting_value($report, $content, $type) {
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Maximum").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_max(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
}
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .=
grafico_modulo_sparse(
$content['id_agent_module'],
$content['period'],
false,
600,
300,
'',
'',
false,
0,
true,
$report["datetime"],
'',
0,
0,
true,
$only_image,
ui_get_full_url(false, false, false, false),
2,
false,
'',
$time_compare_overlapped,
true,
true,
'white',
($content['style']['percentil'] == 1) ? $config['percentil'] : null,
false,
false,
$config['type_module_charts'],
false,
false,
$content['lapse_calc'],
$content['lapse'],
1);
}
$value .= '
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Maximum").'
</th>
</tr>
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if($i>$time_begin['utimestamp']){
$value .= format_for_graph(reporting_get_agentmodule_data_min(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
}
else{
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
</tr>
</table>';
$formated_value = $value;
}
break;
case 'min':
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_min(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
$formated_value = $value;
}
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Minimum").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_min(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
}
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .=
grafico_modulo_sparse(
$content['id_agent_module'],
$content['period'],
false,
600,
300,
'',
'',
false,
0,
true,
$report["datetime"],
'',
0,
0,
true,
$only_image,
ui_get_full_url(false, false, false, false),
2,
false,
'',
$time_compare_overlapped,
true,
true,
'white',
($content['style']['percentil'] == 1) ? $config['percentil'] : null,
false,
false,
$config['type_module_charts'],
false,
false,
$content['lapse_calc'],
$content['lapse'],
0,
1);
}
$value .= '
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Minimum").'
</th>
</tr>
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if($i>$time_begin['utimestamp']){
$value .= format_for_graph(reporting_get_agentmodule_data_min(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
}
else{
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
</tr>
</table>';
$formated_value = $value;
}
break;
case 'avg':
if($content['lapse_calc'] == 0){
$value = reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content['period'], $report["datetime"]);
if (!$config['simple_module_value']) {
@ -3867,7 +4147,138 @@ function reporting_value($report, $content, $type) {
else {
$formated_value = format_for_graph($value, $config['graph_precision']) . " " . $unit;
}
}
else{
$value = '
<table border="0" style="margin:0 auto;text-align:center;">
<tr>
<td width="400px;" height="20%;">';
if($content['visual_format'] == 1 || $content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Agent").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Module").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Average").'
</th>
<tr>
<td style="padding:5px;">
'.$agent_name.'
</td>
<td style="padding:5px;">
'.$module_name.'
</td>
<td style="padding:5px;">
'.format_for_graph(reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content['period'], $report["datetime"]), $config['graph_precision']) . ' ' . $unit.'
</td>
</tr>
</table>';
}
$value .= '
</td>
<td rowspan="2" width="150px">
</td>
<td rowspan="2">';
if($content['visual_format'] == 2 || $content['visual_format'] == 3){
$value .=
grafico_modulo_sparse(
$content['id_agent_module'],
$content['period'],
false,
600,
300,
'',
'',
false,
1,
true,
$report["datetime"],
'',
0,
0,
true,
$only_image,
ui_get_full_url(false, false, false, false),
2,
false,
'',
$time_compare_overlapped,
true,
true,
'white',
($content['style']['percentil'] == 1) ? $config['percentil'] : null,
false,
false,
$config['type_module_charts'],
false,
false,
$content['lapse_calc'],
$content['lapse']
);
}
$value .= '
</td>
</tr>
<tr>
<td>';
if($content['visual_format'] == 1 || $content['visual_format'] == 3){
$value .= '
<table style="width:90%;margin:0 auto;margin-top:30px;background-color:#eee;border: solid lightgray 1px;">
<tr>
<th style="padding:5px;background-color:#82b92e;">
'.__("Lapse").'
</th>
<th style="padding:5px;background-color:#82b92e;">
'.__("Average").'
</th>
</tr>
<tr>';
$time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module']);
$date_reference = getdate();
for ($i=$date_reference[0]; $i > ($date_reference[0]-$content["period"]); $i -= $content["lapse"]) {
$value .= '<tr><td style="padding:5px;">'. date("Y-m-d H:i:s", ($i-$content["lapse"]+1)).' to '.date("Y-m-d H:i:s",$i).'</td><td>';
if($i>$time_begin['utimestamp']){
$value .= format_for_graph(reporting_get_agentmodule_data_average(
$content['id_agent_module'], $content["lapse"], $i), $config['graph_precision']) . ' ' . $unit.'</td></tr>';
}
else{
$value .= 'N/A</td></tr>';
}
}
$value .='</table>';
}
$value .= '
</td>
</tr>
</table>';
$formated_value = $value;
}
break;
case 'sum':
$value = reporting_get_agentmodule_data_sum(
$content['id_agent_module'], $content['period'], $report["datetime"]);

View File

@ -1270,6 +1270,9 @@ CREATE TABLE IF NOT EXISTS `treport_content` (
`id_module_group` INT (10) unsigned NOT NULL DEFAULT 0,
`server_name` text,
`historical_db` tinyint(1) UNSIGNED NOT NULL default 0,
`lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0',
`lapse` int(11) UNSIGNED NOT NULL default '300',
`visual_format` UNSIGNED NOT NULL tinyint(1) default '0',
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_report`) REFERENCES treport(`id_report`)
ON UPDATE CASCADE ON DELETE CASCADE
@ -2727,6 +2730,9 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` (
`module_free_text` TEXT,
`each_agent` tinyint(1) default 1,
`historical_db` tinyint(1) UNSIGNED NOT NULL default 0,
`lapse_calc` tinyint(1) UNSIGNED NOT NULL default '0',
`lapse` int(11) UNSIGNED NOT NULL default '300',
`visual_format` UNSIGNED NOT NULL tinyint(1) default '0',
PRIMARY KEY(`id_rc`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;