mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-25 19:09:08 +02:00
Working in the refactoring the code of reports (MTTR, MTBF, TTO).
This commit is contained in:
parent
56f4f3dc52
commit
54916a8002
@ -203,6 +203,24 @@ function reporting_make_reporting_data($id_report, $date, $time,
|
|||||||
$content,
|
$content,
|
||||||
'sum');
|
'sum');
|
||||||
break;
|
break;
|
||||||
|
case 'MTTR':
|
||||||
|
$report['contents'][] = reporting_value(
|
||||||
|
$report,
|
||||||
|
$content,
|
||||||
|
'MTTR');
|
||||||
|
break;
|
||||||
|
case 'MTBF':
|
||||||
|
$report['contents'][] = reporting_value(
|
||||||
|
$report,
|
||||||
|
$content,
|
||||||
|
'MTBF');
|
||||||
|
break;
|
||||||
|
case 'TTO':
|
||||||
|
$report['contents'][] = reporting_value(
|
||||||
|
$report,
|
||||||
|
$content,
|
||||||
|
'TTO');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +244,15 @@ function reporting_value($report, $content, $type) {
|
|||||||
case 'sum':
|
case 'sum':
|
||||||
$return['type'] = 'sumatory';
|
$return['type'] = 'sumatory';
|
||||||
break;
|
break;
|
||||||
|
case 'MTTR':
|
||||||
|
$return['type'] = 'MTTR';
|
||||||
|
break;
|
||||||
|
case 'MTBF':
|
||||||
|
$return['type'] = 'MTBF';
|
||||||
|
break;
|
||||||
|
case 'TTO':
|
||||||
|
$return['type'] = 'TTO';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -243,6 +270,15 @@ function reporting_value($report, $content, $type) {
|
|||||||
case 'sum':
|
case 'sum':
|
||||||
$content['name'] = __('Summatory');
|
$content['name'] = __('Summatory');
|
||||||
break;
|
break;
|
||||||
|
case 'MTTR':
|
||||||
|
$content['name'] = __('MTTR');
|
||||||
|
break;
|
||||||
|
case 'MTBF':
|
||||||
|
$content['name'] = __('MTBF');
|
||||||
|
break;
|
||||||
|
case 'TTO':
|
||||||
|
$content['name'] = __('TTO');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,6 +286,8 @@ function reporting_value($report, $content, $type) {
|
|||||||
modules_get_agentmodule_name($content['id_agent_module']));
|
modules_get_agentmodule_name($content['id_agent_module']));
|
||||||
$agent_name = io_safe_output(
|
$agent_name = io_safe_output(
|
||||||
modules_get_agentmodule_agent_name ($content['id_agent_module']));
|
modules_get_agentmodule_agent_name ($content['id_agent_module']));
|
||||||
|
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo',
|
||||||
|
$content ['id_agent_module']);
|
||||||
|
|
||||||
$return['title'] = $content['name'];
|
$return['title'] = $content['name'];
|
||||||
$return['subtitle'] = $agent_name . " - " . $module_name;
|
$return['subtitle'] = $agent_name . " - " . $module_name;
|
||||||
@ -260,26 +298,48 @@ function reporting_value($report, $content, $type) {
|
|||||||
case 'max':
|
case 'max':
|
||||||
$value = reporting_get_agentmodule_data_max(
|
$value = reporting_get_agentmodule_data_max(
|
||||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
$formated_value = format_for_graph($value, 2) . " " . $unit;
|
||||||
break;
|
break;
|
||||||
case 'min':
|
case 'min':
|
||||||
$value = reporting_get_agentmodule_data_min(
|
$value = reporting_get_agentmodule_data_min(
|
||||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
$formated_value = format_for_graph($value, 2) . " " . $unit;
|
||||||
break;
|
break;
|
||||||
case 'avg':
|
case 'avg':
|
||||||
$value = reporting_get_agentmodule_data_average(
|
$value = reporting_get_agentmodule_data_average(
|
||||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
$formated_value = format_for_graph($value, 2) . " " . $unit;
|
||||||
break;
|
break;
|
||||||
case 'sum':
|
case 'sum':
|
||||||
$value = reporting_get_agentmodule_data_sum(
|
$value = reporting_get_agentmodule_data_sum(
|
||||||
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
$formated_value = format_for_graph($value, 2) . " " . $unit;
|
||||||
|
break;
|
||||||
|
case 'MTTR':
|
||||||
|
$value = reporting_get_agentmodule_mttr(
|
||||||
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
$formated_value = null;
|
||||||
|
break;
|
||||||
|
case 'MTBF':
|
||||||
|
$value = reporting_get_agentmodule_mtbf(
|
||||||
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
$formated_value = null;
|
||||||
|
break;
|
||||||
|
case 'TTO':
|
||||||
|
$value = reporting_get_agentmodule_tto(
|
||||||
|
$content['id_agent_module'], $content['period'], $report["datetime"]);
|
||||||
|
if ($value == 0) {
|
||||||
|
$formated_value = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$formated_value = human_time_description_raw ($value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $content ['id_agent_module']);
|
|
||||||
|
|
||||||
$return['data'] = array(
|
$return['data'] = array(
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
'formated_value' => format_for_graph($value, 2) . " " . $unit);
|
'formated_value' => $formated_value);
|
||||||
|
|
||||||
return reporting_check_structure_content($return);
|
return reporting_check_structure_content($return);
|
||||||
}
|
}
|
||||||
|
@ -155,6 +155,15 @@ function reporting_html_print_report($report, $mini = false) {
|
|||||||
case 'sumatory':
|
case 'sumatory':
|
||||||
reporting_html_sum_value($table, $item, $mini);
|
reporting_html_sum_value($table, $item, $mini);
|
||||||
break;
|
break;
|
||||||
|
case 'MTTR':
|
||||||
|
reporting_html_MTTR_value($table, $item, $mini, true, true);
|
||||||
|
break;
|
||||||
|
case 'MTBF':
|
||||||
|
reporting_html_MTBF_value($table, $item, $mini, true, true);
|
||||||
|
break;
|
||||||
|
case 'TTO':
|
||||||
|
reporting_html_TTO_value($table, $item, $mini, false, true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['type'] == 'agent_module')
|
if ($item['type'] == 'agent_module')
|
||||||
@ -167,6 +176,18 @@ function reporting_html_print_report($report, $mini = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reporting_html_TTO_value(&$table, $item, $mini, $only_value = false, $check_empty = false) {
|
||||||
|
reporting_html_value($table, $item, $mini);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reporting_html_MTBF_value(&$table, $item, $mini, $only_value = false, $check_empty = false) {
|
||||||
|
reporting_html_value($table, $item, $mini);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reporting_html_MTTR_value(&$table, $item, $mini, $only_value = false, $check_empty = false) {
|
||||||
|
reporting_html_value($table, $item, $mini);
|
||||||
|
}
|
||||||
|
|
||||||
function reporting_html_sum_value(&$table, $item, $mini) {
|
function reporting_html_sum_value(&$table, $item, $mini) {
|
||||||
reporting_html_value($table, $item, $mini);
|
reporting_html_value($table, $item, $mini);
|
||||||
}
|
}
|
||||||
@ -180,10 +201,10 @@ function reporting_html_max_value(&$table, $item, $mini) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reporting_html_min_value(&$table, $item, $mini) {
|
function reporting_html_min_value(&$table, $item, $mini) {
|
||||||
reporting_html_value($table, $item, $mini);
|
reporting_html_value($table, $item, $mini, $only_value, $check_empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reporting_html_value(&$table, $item, $mini) {
|
function reporting_html_value(&$table, $item, $mini, $only_value = false, $check_empty = false) {
|
||||||
if ($mini) {
|
if ($mini) {
|
||||||
$font_size = '1.5';
|
$font_size = '1.5';
|
||||||
}
|
}
|
||||||
@ -193,10 +214,21 @@ function reporting_html_value(&$table, $item, $mini) {
|
|||||||
|
|
||||||
$table->colspan['data']['cell'] = 3;
|
$table->colspan['data']['cell'] = 3;
|
||||||
$table->cellstyle['data']['cell'] = 'text-align: left;';
|
$table->cellstyle['data']['cell'] = 'text-align: left;';
|
||||||
$table->data['data']['cell'] =
|
|
||||||
'<p style="font: bold ' . $font_size . 'em Arial, Sans-serif; color: #000000;">' .
|
|
||||||
$item['data']['formated_value'] .
|
$table->data['data']['cell'] = '<p style="font: bold ' . $font_size . 'em Arial, Sans-serif; color: #000000;">';
|
||||||
'</p>';
|
|
||||||
|
if ($check_empty && empty($item['data']['value'])) {
|
||||||
|
$table->data['data']['cell'] .= __('Unknown');
|
||||||
|
}
|
||||||
|
elseif ($only_value) {
|
||||||
|
$table->data['data']['cell'] .= $item['data']['value'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$table->data['data']['cell'] .= $item['data']['formated_value'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$table->data['data']['cell'] .= '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function reporting_html_url(&$table, $item, $key) {
|
function reporting_html_url(&$table, $item, $key) {
|
||||||
@ -4397,100 +4429,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||||||
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$ttr.'</p>';
|
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$ttr.'</p>';
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
break;
|
break;
|
||||||
case 'TTO':
|
|
||||||
if (empty($item_title)) {
|
|
||||||
$item_title = __('TTO');
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
$tto = reporting_get_agentmodule_tto ($content['id_agent_module'],
|
|
||||||
$content['period'], $report["datetime"]);
|
|
||||||
if ($tto === false) {
|
|
||||||
$tto = __('Unknown');
|
|
||||||
}
|
|
||||||
else if ($tto != 0) {
|
|
||||||
$tto = human_time_description_raw ($tto);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array ();
|
|
||||||
$table->colspan[2][0] = 3;
|
|
||||||
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$tto.'</p>';
|
|
||||||
array_push ($table->data, $data);
|
|
||||||
break;
|
|
||||||
case 'MTBF':
|
|
||||||
if (empty($item_title)) {
|
|
||||||
$item_title = __('MTBF');
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
$mtbf = reporting_get_agentmodule_mtbf ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
|
||||||
if ($mtbf === false) {
|
|
||||||
$mtbf = __('Unknown');
|
|
||||||
}
|
|
||||||
else if ($mtbf != 0) {
|
|
||||||
$mtbf = human_time_description_raw ($mtbf);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array ();
|
|
||||||
$table->colspan[2][0] = 3;
|
|
||||||
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$mtbf.'</p>';
|
|
||||||
array_push ($table->data, $data);
|
|
||||||
break;
|
|
||||||
case 'MTTR':
|
|
||||||
if (empty($item_title)) {
|
|
||||||
$item_title = __('MTTR');
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
$mttr = reporting_get_agentmodule_mttr ($content['id_agent_module'], $content['period'], $report["datetime"]);
|
|
||||||
if ($mttr === false) {
|
|
||||||
$mttr = __('Unknown');
|
|
||||||
}
|
|
||||||
else if ($mttr != 0) {
|
|
||||||
$mttr = human_time_description_raw ($mttr);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array ();
|
|
||||||
$table->colspan[2][0] = 3;
|
|
||||||
$data[0] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$mttr.'</p>';
|
|
||||||
array_push ($table->data, $data);
|
|
||||||
break;
|
|
||||||
case 'group_report':
|
case 'group_report':
|
||||||
$group_name = groups_get_name($content['id_group'], true);
|
$group_name = groups_get_name($content['id_group'], true);
|
||||||
$group_stats = reporting_get_group_stats($content['id_group']);
|
$group_stats = reporting_get_group_stats($content['id_group']);
|
||||||
@ -7179,7 +7118,7 @@ function reporting_get_event_histogram ($events) {
|
|||||||
|
|
||||||
if (!empty($graph_data)) {
|
if (!empty($graph_data)) {
|
||||||
if (defined("METACONSOLE"))
|
if (defined("METACONSOLE"))
|
||||||
$slicebar = flot_slicesbar_graph($graph_data, $max_value, "100%", 35, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $urlI
|
$slicebar = flot_slicesbar_graph($graph_data, $max_value, "100%", 35, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $url);
|
||||||
else
|
else
|
||||||
$slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl);
|
$slicebar = slicesbar_graph($graph_data, $max_value, 700, 25, $colors, $config['fontpath'], $config['round_corner'], $urlImage, $ttl);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user