Fixed the report item SLA with some configurations.
This commit is contained in:
parent
68b6120609
commit
39b667a879
|
@ -598,6 +598,8 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
|
||||
global $config;
|
||||
|
||||
|
||||
|
||||
if (empty($id_agent_module))
|
||||
return false;
|
||||
|
||||
|
@ -616,8 +618,11 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Calculate the SLA for large time without hours
|
||||
if ($timeFrom == $timeTo) {
|
||||
|
||||
// Get interval data
|
||||
$sql = sprintf ('SELECT *
|
||||
FROM tagente_datos
|
||||
|
@ -669,7 +674,8 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
}
|
||||
|
||||
// Calculate planned downtime dates
|
||||
$downtime_dates = reporting_get_planned_downtimes_intervals($id_agent_module, $datelimit, $date);
|
||||
$downtime_dates = reporting_get_planned_downtimes_intervals(
|
||||
$id_agent_module, $datelimit, $date);
|
||||
|
||||
// Get previous data
|
||||
$previous_data = modules_get_previous_data ($id_agent_module, $datelimit);
|
||||
|
@ -707,12 +713,27 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
}
|
||||
|
||||
$previous_utimestamp = $first_data['utimestamp'];
|
||||
if ((($max_value > $min_value AND ($first_data['datos'] > $max_value OR $first_data['datos'] < $min_value))) OR
|
||||
($max_value <= $min_value AND $first_data['datos'] < $min_value)) {
|
||||
if (
|
||||
(
|
||||
(
|
||||
$max_value > $min_value AND (
|
||||
$first_data['datos'] > $max_value OR
|
||||
$first_data['datos'] < $min_value
|
||||
)
|
||||
)
|
||||
) OR
|
||||
(
|
||||
$max_value <= $min_value AND
|
||||
$first_data['datos'] < $min_value
|
||||
)
|
||||
) {
|
||||
|
||||
$previous_status = 1;
|
||||
foreach ($downtime_dates as $date_dt) {
|
||||
if (($date_dt['date_from'] <= $previous_utimestamp) AND ($date_dt['date_to'] >= $previous_utimestamp)) {
|
||||
|
||||
if (($date_dt['date_from'] <= $previous_utimestamp) AND
|
||||
($date_dt['date_to'] >= $previous_utimestamp)) {
|
||||
|
||||
$previous_status = 0;
|
||||
}
|
||||
}
|
||||
|
@ -768,13 +789,14 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
$timeTo);
|
||||
}
|
||||
else {
|
||||
|
||||
// Extract the data each day
|
||||
|
||||
$sla = 0;
|
||||
|
||||
$i = 0;
|
||||
for ($interval = 0; $interval <= $period; $interval = $interval + SECONDS_1DAY) {
|
||||
$datelimit = $date - $interval;
|
||||
for ($interval = SECONDS_1DAY; $interval <= $period; $interval = $interval + SECONDS_1DAY) {
|
||||
|
||||
|
||||
$sla_day = reporting_get_agentmodule_sla(
|
||||
$id_agent_module,
|
||||
|
@ -786,8 +808,12 @@ function reporting_get_agentmodule_sla ($id_agent_module, $period = 0,
|
|||
$timeFrom, $timeTo);
|
||||
|
||||
|
||||
$sla += $sla_day;
|
||||
$i++;
|
||||
|
||||
// Avoid to add the period of module not init
|
||||
if ($sla_day !== false) {
|
||||
$sla += $sla_day;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$sla = $sla / $i;
|
||||
|
|
Loading…
Reference in New Issue