Working in the refactoring the code of reports (netflow_area, netflow_pie, netflow_data, netflow_statistics, netflow_summary).

This commit is contained in:
mdtrooper 2015-04-14 12:58:26 +02:00
parent ab09716cd4
commit 6ee2ea02d4
2 changed files with 144 additions and 61 deletions

View File

@ -261,12 +261,135 @@ function reporting_make_reporting_data($id_report, $date, $time,
$force_width_chart,
$force_height_chart);
break;
case 'netflow_area':
$report['contents'][] = reporting_simple_baseline_graph(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
case 'netflow_pie':
$report['contents'][] = reporting_netflow_pie(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
case 'netflow_data':
$report['contents'][] = reporting_netflow_data(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
case 'netflow_statistics':
$report['contents'][] = reporting_netflow_statistics(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
case 'netflow_summary':
$report['contents'][] = reporting_netflow_summary(
$report,
$content,
$type,
$force_width_chart,
$force_height_chart);
break;
}
}
return reporting_check_structure_report($report);
}
function reporting_netflow($report, $content, $type,
$force_width_chart, $force_height_chart, $type_netflow = null) {
global $config;
switch ($type_netflow) {
case 'netflow_area':
$return['type'] = 'netflow_area';
break;
case 'netflow_pie':
$return['type'] = 'netflow_pie';
break;
case 'netflow_data':
$return['type'] = 'netflow_data';
break;
case 'netflow_statistics':
$return['type'] = 'netflow_statistics';
break;
case 'netflow_summary':
$return['type'] = 'netflow_summary';
break;
}
if (empty($content['name'])) {
switch ($type_netflow) {
case 'netflow_area':
$return['name'] = __('Netflow Area');
break;
case 'netflow_pie':
$return['name'] = __('Netflow Pie');
break;
case 'netflow_data':
$return['name'] = __('Netflow Data');
break;
case 'netflow_statistics':
$return['name'] = __('Netflow Statistics');
break;
case 'netflow_summary':
$return['name'] = __('Netflow Summary');
break;
}
}
$return['title'] = $content['name'];
$return["description"] = $content["description"];
$return["date"] = reporting_get_date_text($report, $content);
// Get chart
reporting_set_conf_charts($width, $height, $only_image, $type, $content);
if (!empty($force_width_chart)) {
$width = $force_width_chart;
}
if (!empty($force_height_chart)) {
$height = $force_height_chart;
}
// Get item filters
$filter = db_get_row_sql("SELECT *
FROM tnetflow_filter
WHERE id_sg = '" . (int)$content['text'] . "'", false, true);
switch ($type) {
case 'dinamic':
case 'static':
$return['chart'] = netflow_draw_item (
$report['datetime'] - $content['period'],
$report['datetime'],
$content['top_n'],
$type_netflow,
$filter,
$content['top_n_value'],
$content ['server_name'],
'HTML');
break;
case 'data':
break;
}
return reporting_check_structure_content($return);
}
function reporting_simple_baseline_graph($report, $content,
$type = 'dinamic', $force_width_chart = null,
$force_height_chart = null) {

View File

@ -135,10 +135,10 @@ function reporting_html_print_report($report, $mini = false) {
reporting_html_sql($table, $item);
break;
case 'simple_graph':
reporting_html_simple_graph($table, $item);
reporting_html_graph($table, $item);
break;
case 'custom_graph':
reporting_html_custom_graph($table, $item);
reporting_html_graph($table, $item);
break;
case 'text':
reporting_html_text($table, $item);
@ -174,13 +174,28 @@ function reporting_html_print_report($report, $mini = false) {
reporting_html_agent_configuration($table, $item);
break;
case 'projection_graph':
reporting_html_projection_graph($table, $item);
reporting_html_graph($table, $item);
break;
case 'prediction_date':
reporting_html_prediction_date($table, $item, $mini);
break;
case 'simple_baseline_graph':
reporting_html_simple_baseline_graph($table, $item);
reporting_html_graph($table, $item);
break;
case 'netflow_area':
reporting_html_graph($table, $item);
break;
case 'netflow_pie':
reporting_html_graph($table, $item);
break;
case 'netflow_data':
reporting_html_graph($table, $item);
break;
case 'netflow_statistics':
reporting_html_graph($table, $item);
break;
case 'netflow_summary':
reporting_html_graph($table, $item);
break;
}
@ -194,7 +209,7 @@ function reporting_html_print_report($report, $mini = false) {
}
}
function reporting_html_simple_baseline_graph($table, $item) {
function reporting_html_graph($table, $item) {
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = $item['chart'];
@ -204,12 +219,6 @@ function reporting_html_prediction_date($table, $item, $mini) {
reporting_html_value($table, $item, $mini, true);
}
function reporting_html_projection_graph(&$table, $item) {
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = $item['chart'];
}
function reporting_html_agent_configuration(&$table, $item) {
$table->colspan['agent']['cell'] = 3;
$table->cellstyle['agent']['cell'] = 'text-align: left;';
@ -588,18 +597,6 @@ function reporting_html_sql(&$table, $item) {
}
}
function reporting_html_custom_graph(&$table, $item) {
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = $item['chart'];
}
function reporting_html_simple_graph(&$table, $item) {
$table->colspan['chart']['cell'] = 3;
$table->cellstyle['chart']['cell'] = 'text-align: center;';
$table->data['chart']['cell'] = $item['chart'];
}
/**
* Get the maximum value of an agent module in a period of time.
@ -5493,7 +5490,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$table_data .= "</table>";
$table_data .= "<div class='legend_basic' style='width: 96%'>";
$table_data .= "<table>";
$table_data .= "<tr><td colspan='2' style='padding-bottom: 10px;'><b>" . __('Legend') . "</b></td></tr>";
$table_data .= "<tr><td class='legend_square_simple'><div style='background-color: " . COL_ALERTFIRED . ";'></div></td><td>" . __("Orange cell when the module has fired alerts") . "</td></tr>";
@ -5739,43 +5736,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
}
break;
case 'netflow_area':
case 'netflow_pie':
case 'netflow_data':
case 'netflow_statistics':
case 'netflow_summary':
// Read the report item
$report_id = $report['id_report'];
$content_id = $content['id_rc'];
$max_aggregates= $content['top_n_value'];
$type = $content['show_graph'];
$description = $content['description'];
$resolution = $content['top_n'];
$type = $content['type'];
$period = $content['period'];
// Calculate the start and end dates
$end_date = $report['datetime'];
$start_date = $end_date - $period;
// Get item filters
$filter = db_get_row_sql("SELECT *
FROM tnetflow_filter
WHERE id_sg = '" . (int)$content['text'] . "'", false, true);
if ($description == '') {
$description = $filter['id_name'];
}
if (empty($item_title)) {
$item_title = $description;
}
$table->colspan[0][0] = 4;
$table->data[0][0] = '<h4>' . $item_title . '</h4>';
$table->colspan[1][0] = 4;
$table->data[1][0] = netflow_draw_item ($start_date, $end_date, $resolution, $type, $filter, $max_aggregates, $server_name, 'HTML');
break;
}
//Restore dbconnection
if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE') && $remote_connection == 1) {