Working in the refactoring the code of reports (fixed max_value, added min_value and avg_value).
This commit is contained in:
parent
13e78e44eb
commit
4924556a21
|
@ -180,9 +180,22 @@ function reporting_make_reporting_data($id_report, $date, $time,
|
|||
$type);
|
||||
break;
|
||||
case 'max_value':
|
||||
$report['contents'][] = reporting_max_value(
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content);
|
||||
$content,
|
||||
'max');
|
||||
break;
|
||||
case 'avg_value':
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content,
|
||||
'avg');
|
||||
break;
|
||||
case 'min_value':
|
||||
$report['contents'][] = reporting_value(
|
||||
$report,
|
||||
$content,
|
||||
'min');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -190,21 +203,61 @@ function reporting_make_reporting_data($id_report, $date, $time,
|
|||
return reporting_check_structure_report($report);
|
||||
}
|
||||
|
||||
function reporting_max_value($report, $content) {
|
||||
function reporting_value($report, $content, $type) {
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['type'] = 'max_value';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Max. Value');
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
$return['type'] = 'max_value';
|
||||
break;
|
||||
case 'min':
|
||||
$return['type'] = 'min_value';
|
||||
break;
|
||||
case 'avg':
|
||||
$return['type'] = 'avg_value';
|
||||
break;
|
||||
}
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text();
|
||||
|
||||
$value = reporting_get_agentmodule_data_max ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
if (empty($content['name'])) {
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
$content['name'] = __('Max. Value');
|
||||
break;
|
||||
case 'min':
|
||||
$content['name'] = __('Min. Value');
|
||||
break;
|
||||
case 'avg':
|
||||
$content['name'] = __('AVG. Value');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$module_name = io_safe_output(
|
||||
modules_get_agentmodule_name($content['id_agent_module']));
|
||||
$agent_name = io_safe_output(
|
||||
modules_get_agentmodule_agent_name ($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);
|
||||
|
||||
switch ($type) {
|
||||
case 'max':
|
||||
$value = reporting_get_agentmodule_data_max(
|
||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
break;
|
||||
case 'min':
|
||||
$value = reporting_get_agentmodule_data_min(
|
||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
break;
|
||||
case 'avg':
|
||||
$value = reporting_get_agentmodule_data_average(
|
||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
break;
|
||||
}
|
||||
|
||||
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $content ['id_agent_module']);
|
||||
|
||||
|
|
|
@ -146,6 +146,12 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
case 'max_value':
|
||||
reporting_html_max_value($table, $item, $mini);
|
||||
break;
|
||||
case 'avg_value':
|
||||
reporting_html_avg_value($table, $item, $mini);
|
||||
break;
|
||||
case 'min_value':
|
||||
reporting_html_min_value($table, $item, $mini);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($item['type'] == 'agent_module')
|
||||
|
@ -158,7 +164,19 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
}
|
||||
}
|
||||
|
||||
function reporting_html_max_value($table, $item, $mini) {
|
||||
function reporting_html_avg_value(&$table, $item, $mini) {
|
||||
reporting_html_value($table, $item, $mini);
|
||||
}
|
||||
|
||||
function reporting_html_max_value(&$table, $item, $mini) {
|
||||
reporting_html_value($table, $item, $mini);
|
||||
}
|
||||
|
||||
function reporting_html_min_value(&$table, $item, $mini) {
|
||||
reporting_html_value($table, $item, $mini);
|
||||
}
|
||||
|
||||
function reporting_html_value(&$table, $item, $mini) {
|
||||
if ($mini) {
|
||||
$font_size = '1.5';
|
||||
}
|
||||
|
@ -3836,75 +3854,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
$data[1] .= html_print_image("images/module_critical.png", true) . ' ' .__('Not OK') . ': ' .$monitor_value.' % ' . '</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
break;
|
||||
case 7:
|
||||
case 'avg_value':
|
||||
if (empty($item_title)) {
|
||||
$item_title = __('Avg. Value');
|
||||
}
|
||||
reporting_header_content($mini, $content, $report, $table, $item_title,
|
||||
ui_print_truncate_text($agent_name, 'agent_medium', false) .
|
||||
' <br> '.ui_print_truncate_text($module_name, 'module_medium', false));
|
||||
|
||||
//RUNNING
|
||||
|
||||
// Put description at the end of the module (if exists)
|
||||
$table->colspan[1][0] = 3;
|
||||
if ($content["description"] != "") {
|
||||
$data_desc = array();
|
||||
$data_desc[0] = $content["description"];
|
||||
array_push ($table->data, $data_desc);
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
$table->colspan[2][0] = 3;
|
||||
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module']);
|
||||
$value = reporting_get_agentmodule_data_average ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
if ($value === false) {
|
||||
$value = __('Unknown');
|
||||
}
|
||||
else {
|
||||
$value = format_for_graph($value, 2) . " " . $unit;
|
||||
}
|
||||
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
break;
|
||||
|
||||
case 9:
|
||||
case 'min_value':
|
||||
if (empty($item_title)) {
|
||||
$item_title = __('Min. Value');
|
||||
}
|
||||
reporting_header_content($mini, $content, $report, $table, $item_title,
|
||||
ui_print_truncate_text($agent_name, 'agent_medium', false) .
|
||||
' <br> '.ui_print_truncate_text($module_name, 'module_medium', false));
|
||||
|
||||
//RUNNING
|
||||
|
||||
// Put description at the end of the module (if exists)
|
||||
$table->colspan[1][0] = 3;
|
||||
if ($content["description"] != "") {
|
||||
$data_desc = array();
|
||||
$data_desc[0] = $content["description"];
|
||||
array_push ($table->data, $data_desc);
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
$table->colspan[2][0] = 3;
|
||||
|
||||
$value = reporting_get_agentmodule_data_min ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $content ['id_agent_module']);
|
||||
if ($value === false) {
|
||||
$value = __('Unknown');
|
||||
}
|
||||
else {
|
||||
$value = format_for_graph($value, 2) . " " . $unit;
|
||||
}
|
||||
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
|
||||
array_push ($table->data, $data);
|
||||
|
||||
break;
|
||||
case 10:
|
||||
case 'sumatory':
|
||||
if (empty($item_title)) {
|
||||
|
|
Loading…
Reference in New Issue