Solved problems with availability reports and unknown time (2)

Tickets #3449
This commit is contained in:
fermin831 2016-05-27 14:06:05 +02:00
parent 8cb651079a
commit 1c94eee171
1 changed files with 9 additions and 10 deletions

View File

@ -2292,26 +2292,25 @@ function modules_get_unknown_time ($id_agent_module, $date, $period){
array_unshift ($interval_data, $first_data); array_unshift ($interval_data, $first_data);
} else { } else {
$first_data = array_shift ($interval_data); $first_data = array_shift ($interval_data);
if (($previous_data['utimestamp'] + SECONDS_1DAY) >= $first_data['utimestamp']) { $previous_1day = $previous_data['utimestamp'] + SECONDS_1DAY;
if (($previous_data['utimestamp'] + SECONDS_1DAY) >= $datelimit) { if ($previous_1day <= $datelimit) {
$unknown_seconds += $previous_data['utimestamp'] + SECONDS_1DAY - $first_data['utimestamp']; $unknown_seconds += $first_data['utimestamp'] - $datelimit;
} else { } else if ($previous_1day <= $first_data['utimestamp']) {
$unknown_seconds += $first_data['utimestamp'] - $datetime; $unknown_seconds += $first_data['utimestamp'] - $previous_1day;
}
} }
array_unshift ($interval_data, $first_data); array_unshift ($interval_data, $first_data);
} }
// Put utimestamp like last data // Put utimestamp like last data
$last_data = modules_get_next_data ($id_agent_module, $datelimit);
$last_data['utimestamp'] = $date; $last_data['utimestamp'] = $date;
array_push ($interval_data, $last_data); array_push ($interval_data, $last_data);
$previous_data = array_shift ($previous_data); $previous_data = array_shift ($interval_data);
// Check if all datas have data maximum one day before // Check if all datas have data maximum one day before
foreach ($interval_data as $data) { foreach ($interval_data as $data) {
$previous_1day = $previous_data['utimestamp'] + SECONDS_1DAY; $previous_1day = $previous_data['utimestamp'] + SECONDS_1DAY;
if ($previous_1day >= $data['utimestamp']) { if ($previous_1day <= $data['utimestamp']) {
$unknown_period += $previous_1day - $data['utimestamp']; $unknown_seconds += $data['utimestamp'] - $previous_1day;
} }
$previous_data = $data; $previous_data = $data;
} }