fixed baseline report
This commit is contained in:
parent
266cd6d394
commit
ed0d89ec73
|
@ -265,7 +265,7 @@ function grafico_modulo_sparse_data_chart (
|
|||
$data_module_graph['id_module_type'] == 9 ||
|
||||
$data_module_graph['id_module_type'] == 31 ||
|
||||
$data_module_graph['id_module_type'] == 100 ||
|
||||
$params['baseline'] || $params['projection']
|
||||
$params['projection']
|
||||
){
|
||||
|
||||
$data = db_get_all_rows_filter (
|
||||
|
@ -966,53 +966,58 @@ function grafico_modulo_sparse ($params) {
|
|||
}
|
||||
|
||||
if(!$params['array_data_create']){
|
||||
if ($params['compare'] !== false) {
|
||||
$series_suffix = 2;
|
||||
if($params['baseline']){
|
||||
$array_data = get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params);
|
||||
}
|
||||
else{
|
||||
if ($params['compare'] !== false) {
|
||||
$series_suffix = 2;
|
||||
|
||||
$date_array_prev['final_date'] = $date_array['start_date'];
|
||||
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
|
||||
$date_array_prev['period'] = $date_array['period'];
|
||||
$date_array_prev['final_date'] = $date_array['start_date'];
|
||||
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
|
||||
$date_array_prev['period'] = $date_array['period'];
|
||||
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$params['flag_overlapped'] = 1;
|
||||
}
|
||||
else{
|
||||
$params['flag_overlapped'] = 0;
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$params['flag_overlapped'] = 1;
|
||||
}
|
||||
else{
|
||||
$params['flag_overlapped'] = 0;
|
||||
}
|
||||
|
||||
$array_data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array_prev,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$series_suffix
|
||||
);
|
||||
|
||||
switch ($params['compare']) {
|
||||
case 'separated':
|
||||
case 'overlapped':
|
||||
// Store the chart calculated
|
||||
$array_data_prev = $array_data;
|
||||
$legend_prev = $legend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$series_suffix = 1;
|
||||
$params['flag_overlapped'] = 0;
|
||||
|
||||
$array_data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array_prev,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$series_suffix
|
||||
);
|
||||
|
||||
switch ($params['compare']) {
|
||||
case 'separated':
|
||||
case 'overlapped':
|
||||
// Store the chart calculated
|
||||
$array_data_prev = $array_data;
|
||||
$legend_prev = $legend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$series_suffix = 1;
|
||||
$params['flag_overlapped'] = 0;
|
||||
|
||||
$array_data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$series_suffix
|
||||
);
|
||||
|
||||
if($params['compare']){
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$array_data = array_merge($array_data, $array_data_prev);
|
||||
$legend = array_merge($legend, $legend_prev);
|
||||
if($params['compare']){
|
||||
if ($params['compare'] === 'overlapped') {
|
||||
$array_data = array_merge($array_data, $array_data_prev);
|
||||
$legend = array_merge($legend, $legend_prev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5098,4 +5103,53 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
|
|||
return d3_sunburst_graph ($graph_data, $width, $height, true);
|
||||
}
|
||||
|
||||
function get_baseline_data($agent_module_id, $date_array, $data_module_graph, $params){
|
||||
$period = $date_array["period"];
|
||||
$date = $date_array["final_date"];
|
||||
$array_data = array();
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$date_array = array();
|
||||
$date_array["period"] = $period;
|
||||
$date_array["final_date"] = $date - $period * $i;
|
||||
$date_array["start_date"] = $date - $period * ($i + 1);
|
||||
|
||||
$data = grafico_modulo_sparse_data(
|
||||
$agent_module_id,
|
||||
$date_array,
|
||||
$data_module_graph,
|
||||
$params,
|
||||
$i
|
||||
);
|
||||
|
||||
$array_data[] = $data;
|
||||
|
||||
}
|
||||
$result = array();
|
||||
$array_data[1] = array_reverse($array_data[1]['sum1']['slice_data']);
|
||||
$array_data[2] = array_reverse($array_data[2]['sum2']['slice_data']);
|
||||
$array_data[3] = array_reverse($array_data[3]['sum3']['slice_data']);
|
||||
foreach ($array_data[0]['sum0']['slice_data'] as $key => $value) {
|
||||
$data1 = array_pop($array_data[1]);
|
||||
$data2 = array_pop($array_data[2]);
|
||||
$data3 = array_pop($array_data[3]);
|
||||
|
||||
$result['slice_data'][$key]['min'] = ($data1['min'] + $data2['min'] + $data3['min'] + $value['min']) / 4;
|
||||
$result['slice_data'][$key]['avg'] = ($data1['avg'] + $data2['avg'] + $data3['avg'] + $value['avg']) / 4;
|
||||
$result['slice_data'][$key]['max'] = ($data1['max'] + $data2['max'] + $data3['max'] + $value['max']) / 4;
|
||||
|
||||
$result['data'][] = array($key, $result['slice_data'][$key]['avg']);
|
||||
}
|
||||
|
||||
$result['avg'] = ($array_data[0]['sum0']['avg'] + $array_data[1]['sum1']['avg'] + $array_data[2]['sum2']['avg'] +$array_data[3]['sum3']['avg'])/4;
|
||||
$result['max'] = max($array_data[0]['sum0']['max'], $array_data[1]['sum1']['max'], $array_data[2]['sum2']['max'], $array_data[3]['sum3']['max']);
|
||||
$result['min'] = min($array_data[0]['sum0']['min'], $array_data[1]['sum1']['min'], $array_data[2]['sum2']['min'], $array_data[3]['sum3']['min']);
|
||||
|
||||
$result['agent_module_id'] = $array_data[0]['sum0']['agent_module_id'];
|
||||
$result['id_module_type'] = $array_data[0]['sum0']['id_module_type'];
|
||||
$result['agent_name'] = $array_data[0]['sum0']['agent_name'];
|
||||
$result['module_name'] = $array_data[0]['sum0']['module_name'];
|
||||
$result['agent_alias'] = $array_data[0]['sum0']['agent_alias'];
|
||||
return array('sum0' => $result);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -395,7 +395,8 @@ function reporting_make_reporting_data($report = null, $id_report,
|
|||
$content,
|
||||
$type,
|
||||
$force_width_chart,
|
||||
$force_height_chart);
|
||||
$force_height_chart
|
||||
);
|
||||
break;
|
||||
case 'netflow_area':
|
||||
$report['contents'][] = reporting_netflow(
|
||||
|
@ -3481,80 +3482,6 @@ function reporting_netflow($report, $content, $type,
|
|||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_simple_baseline_graph($report, $content,
|
||||
$type = 'dinamic', $force_width_chart = null,
|
||||
$force_height_chart = null) {
|
||||
|
||||
global $config;
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content["server_name"]);
|
||||
$server = metaconsole_get_connection_by_id ($id_meta);
|
||||
metaconsole_connect($server);
|
||||
}
|
||||
|
||||
$return['type'] = 'simple_baseline_graph';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Simple baseline graph');
|
||||
}
|
||||
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name($content['id_agent_module']));
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_alias ($content['id_agent_module']));
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = $agent_name . " - " . $module_name;
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text($report, $content);
|
||||
$return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : '';
|
||||
|
||||
// Get chart
|
||||
reporting_set_conf_charts($width, $height, $only_image, $type,
|
||||
$content, $ttl);
|
||||
|
||||
$baseline_data = enterprise_hook(
|
||||
'reporting_enterprise_get_baseline',
|
||||
array (
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
$report["datetime"]
|
||||
)
|
||||
);
|
||||
|
||||
if ($baseline_data === ENTERPRISE_NOT_HOOK) {
|
||||
$baseline_data = array ();
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
$params =array(
|
||||
'agent_module_id' => $content['id_agent_module'],
|
||||
'period' => $content['period'],
|
||||
'date' => $report["datetime"],
|
||||
'only_image' => $only_image,
|
||||
'homeurl' => ui_get_full_url(false, false, false, false),
|
||||
'ttl' => $ttl,
|
||||
'array_data_create' => $baseline_data,
|
||||
'server_id' => $id_meta,
|
||||
'height' => $config['graph_image_height']
|
||||
);
|
||||
|
||||
$return['chart'] = grafico_modulo_sparse ($params);
|
||||
break;
|
||||
case 'data':
|
||||
break;
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_prediction_date($report, $content) {
|
||||
|
||||
global $config;
|
||||
|
|
Loading…
Reference in New Issue