diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index be3dbad1a2..25a6ae18b4 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -5899,6 +5899,8 @@ function reporting_availability_graph($report, $content, $pdf=false) { $dataslice['order'] = $data['sla_value']; $dataslice['checks_total'] = $data['checks_total']; $dataslice['checks_ok'] = $data['checks_ok']; + $dataslice['time_total'] = $data['time_total']; + $dataslice['time_not_init']= $data['time_not_init']; $dataslice['sla_status'] = $data['sla_status']; $dataslice['sla_value'] = $data['sla_value']; @@ -11009,6 +11011,7 @@ function reporting_label_macro ($item, $label) { * @brief Calculates the SLA compliance value given an sla array * * @param Array With keys time_ok, time_error, time_downtime and time_unknown + * @return SLA Return the compliance value. */ function reporting_sla_get_compliance_from_array ($sla_array) { $time_compliance = $sla_array['time_ok'] + $sla_array['time_unknown'] + $sla_array['time_downtime']; @@ -11018,6 +11021,28 @@ function reporting_sla_get_compliance_from_array ($sla_array) { : $time_compliance/$time_total_working; } +/** + * @brief Calculates if an SLA array is not init + * + * @param Array With keys time_ok, time_error, time_downtime and time_unknown + * @return bool True if not init + */ +function reporting_sla_is_not_init_from_array($sla_array) { + if ($sla_array["time_total"] == 0) return false; + return $sla_array["time_not_init"] == $sla_array["time_total"]; +} + +/** + * @brief Calculates if an SLA array is ignored + * + * @param Array With keys time_ok, time_error, time_downtime and time_unknown + * @return bool True if igonred time + */ +function reporting_sla_is_ignored_from_array($sla_array) { + if ($sla_array["time_total"] > 0) return false; + return $sla_array["time_not_init"] == 0; +} + /** * @brief Given a period, get the SLA status of the period. * diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 040a4f625f..52d124421f 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -485,14 +485,19 @@ function reporting_html_SLA($table, $item, $mini) { $row[] = $sla['dinamic_text']; } $row[] = round($sla['sla_limit'], 2) . "%"; - - if ($sla['sla_value_unknown']) { - $row[] = '' . + + if (reporting_sla_is_not_init_from_array($sla)) { + $row[] = '' . __('N/A') . ''; - $row[] = '' . - __('Unknown') . ''; - } - elseif ($sla['sla_status']) { + $row[] = '' . + __('Not init') . ''; + } elseif (reporting_sla_is_ignored_from_array($sla)) { + $row[] = '' . + __('N/A') . ''; + $row[] = '' . + __('No data') . ''; + // Normal calculation + } elseif ($sla['sla_status']) { $row[] = '' . sla_truncate($sla['sla_value'], $config['graph_precision']) . "%" . ''; $row[] = '' . @@ -2564,24 +2569,36 @@ function reporting_html_availability_graph(&$table, $item, $pdf=0) { $table1->width = '99%'; $table1->data = array (); foreach ($item['charts'] as $chart) { - switch ($chart['sla_status']) { - case REPORT_STATUS_ERR: - $color = COL_CRITICAL; - break; - case REPORT_STATUS_OK: - $color = COL_NORMAL; - break; - default: - $color = COL_UNKNOWN; - break; + $checks_resume = ''; + $sla_value = ''; + if (reporting_sla_is_not_init_from_array($chart)) { + $color = COL_NOTINIT; + $sla_value = __('Not init'); + } elseif (reporting_sla_is_ignored_from_array($chart)) { + $color = COL_IGNORED; + $sla_value = __('No data'); + } else { + switch ($chart['sla_status']) { + case REPORT_STATUS_ERR: + $color = COL_CRITICAL; + break; + case REPORT_STATUS_OK: + $color = COL_NORMAL; + break; + default: + $color = COL_UNKNOWN; + break; + } + $sla_value = sla_truncate($chart['sla_value'], $config['graph_precision']) . '%'; + $checks_resume = "(" . $chart['checks_ok'] . "/" . $chart['checks_total'] . ")"; } $table1->data[] = array( $chart['agent'] . "
" . $chart['module'], $chart['chart'], "" . - sla_truncate($chart['sla_value'], $config['graph_precision']) . '%' . + $sla_value . '', - "(" . $chart['checks_ok'] . "/" . $chart['checks_total'] . ")" + $checks_resume ); }