function get_current_delay($delay, $flex_intervals, $now)
{
    if (zbx_empty($flex_intervals)) {
        return $delay;
    }
    $current_delay = SEC_PER_YEAR;
    $arr_of_flex_intervals = explode(';', $flex_intervals);
    foreach ($arr_of_flex_intervals as $fnum => $flex_interval) {
        if (2 != sscanf($flex_interval, "%d/%29s", $flex_delay, $flex_period)) {
            continue;
        }
        if ($flex_delay < $current_delay && check_time_period($flex_period, $now)) {
            $current_delay = $flex_delay;
        }
    }
    if ($current_delay == SEC_PER_YEAR) {
        return $delay;
    }
    return $current_delay == 0 ? SEC_PER_YEAR : $current_delay;
}
Exemple #2
0
function get_flexible_interval($delay_flex, $delay, $now)
{
    if (is_null($delay_flex) || $delay_flex == '') {
        return $delay;
    }
    $arr_of_delay = explode(';', $delay_flex);
    foreach ($arr_of_delay as $one_delay_flex) {
        $arr = explode('/', $one_delay_flex);
        if (check_time_period($arr[1], $now)) {
            return $arr[0];
        }
    }
    return $delay;
}