From c24d8f22e7e99650a1a03e44578f8af5e7d71522 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 14 Apr 2015 16:21:44 +0200 Subject: [PATCH] Working in the refactoring the code of reports (monitor_report). --- .../include/functions_reporting.php | 42 ++++++++++ .../include/functions_reporting_html.php | 80 +++++++++---------- 2 files changed, 81 insertions(+), 41 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 46ff78b348..0ae6240968 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -301,12 +301,54 @@ function reporting_make_reporting_data($id_report, $date, $time, $force_width_chart, $force_height_chart); break; + case 'monitor_report': + $report['contents'][] = reporting_monitor_report( + $report, + $content); + break; } } return reporting_check_structure_report($report); } +function reporting_monitor_report($report, $content) { + global $config; + + + $return['type'] = 'monitor_report'; + + if (empty($content['name'])) { + $content['name'] = __('Monitor Report'); + } + + $return['title'] = $content['name']; + $return["description"] = $content["description"]; + $return["date"] = reporting_get_date_text($report, $content); + + $value = reporting_get_agentmodule_sla( + $content['id_agent_module'], + $content['period'], + 1, + false, + $report["datetime"]); + + if ($value === __('Unknown')) { + $return['data']['unknown'] = 1; + } + else { + $return['data']['unknown'] = 0; + + $return["data"]["ok"]["value"] = $value; + $return["data"]["ok"]["formated_value"] = format_numeric($value, 2); + + $return["data"]["fail"]["value"] = 100 - $return["data"]["ok"]["value"]; + $return["data"]["fail"]["formated_value"] = (100 - $return["data"]["ok"]["formated_value"]); + } + + return reporting_check_structure_content($return); +} + function reporting_netflow($report, $content, $type, $force_width_chart, $force_height_chart, $type_netflow = null) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 779dc490b7..368884d3c2 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -197,6 +197,9 @@ function reporting_html_print_report($report, $mini = false) { case 'netflow_summary': reporting_html_graph($table, $item); break; + case 'monitor_report': + reporting_html_monitor_report($table, $item, $mini); + break; } if ($item['type'] == 'agent_module') @@ -209,6 +212,42 @@ function reporting_html_print_report($report, $mini = false) { } } +function reporting_html_monitor_report($table, $item, $mini) { + if ($mini) { + $font_size = '1.5'; + } + else { + $font_size = '3'; + } + + $table->colspan['module']['cell'] = 3; + $table->cellstyle['module']['cell'] = 'text-align: center;'; + + $table1->width = '99%'; + $table1->head = array (); + $table1->data = array (); + if ($item['data']['unknown'] == 1) { + $table1->data['data']['unknown'] = + '

'; + $table1->data['data']['unknown'] .= __('Unknown') . "

"; + } + else { + $table1->data['data']['ok'] = + '

'; + $table1->data['data']['ok'] .= + html_print_image("images/module_ok.png", true) . ' ' . + __('OK') . ': ' . $item['data']["ok"]["formated_value"].' %

'; + + $table1->data['data']['fail'] = + '

'; + $table1->data['data']['fail'] .= + html_print_image("images/module_critical.png", true) . ' ' . + __('Not OK') . ': ' . $item['data']["fail"]["formated_value"] . ' % ' . '

'; + } + + $table->data['module']['cell'] = html_print_table($table1, true); +} + function reporting_html_graph($table, $item) { $table->colspan['chart']['cell'] = 3; $table->cellstyle['chart']['cell'] = 'text-align: center;'; @@ -3921,47 +3960,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f array_push ($table->data, $data); } break; - case 6: - case 'monitor_report': - if (empty($item_title)) { - $item_title = __('Monitor report'); - } - reporting_header_content($mini, $content, $report, $table, $item_title, - ui_print_truncate_text($agent_name, 'agent_medium', false) . - '
'.ui_print_truncate_text($module_name, 'module_medium', false)); - - //RUNNING - $next_row = 1; - - // Put description at the end of the module (if exists) - if ($content["description"] != "") { - $table->colspan[1][0] = 3; - $data_desc = array(); - $data_desc[0] = $content["description"]; - array_push ($table->data, $data_desc); - $next_row++; - } - - $data = array (); - $monitor_value = reporting_get_agentmodule_sla ($content['id_agent_module'], $content['period'], 1, false, $report["datetime"]); - if ($monitor_value === false) { - $monitor_value = __('Unknown'); - } - else { - $monitor_value = format_numeric ($monitor_value); - } - - $table->colspan[$next_row][0] = 2; - $data[0] = '

'; - $data[0] .= html_print_image("images/module_ok.png", true) . ' ' . __('OK') . ': ' . $monitor_value.' %

'; - if ($monitor_value !== __('Unknown')) { - $monitor_value = format_numeric (100 - $monitor_value, 2) ; - } - $data[1] = '

'; - $data[1] .= html_print_image("images/module_critical.png", true) . ' ' .__('Not OK') . ': ' .$monitor_value.' % ' . '

'; - array_push ($table->data, $data); - - break; case 'agent_detailed_event': case 'event_report_agent':