Page 1 of 1

Re: [Nagios-devel] Bug in exclude timeperiods code?

Posted: Thu Aug 05, 2010 11:44 am
by Guest
--001636833df27d94b9048d12e702
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

I can't code, but I can propose an algorithm that works (optimal I
don't know). It just need functions to get the start and end see from
a time we want for all daterange types (maybe there are already theses
functions).

Then it' a recursive algo between valid/invalid (will always go
thurser and stop at begining+1 year so it will stop). The "next
invalid" function is like valid, for each daterange we search the next
invalid, check is this time is globally invalid (can be invalid for a
daterange but valid for another one) and take the min. Then check for
it's own exclude of course (so next valid for them).

I hope someone will code it.


Jean

On Thu, Aug 5, 2010 at 1:50 AM, Ethan Galstad wrote:
> nap wrote:
>> Hi,
>>
>> If I'm not wrong the exclude timeperiod feature now working in the
>> HEAD since the last stable version. I try to add a test case with it
>> in test_timeperiods.c but I don't think I've got the good result :
>>
>> I add in t-tap/smallconfig/minimal.cfg theses timeperiods :
>> define timeperiod{
>> =A0 =A0 =A0 =A0 timeperiod_name Test_exclude
>> =A0 =A0 =A0 =A0 alias =A0 =A0 =A0 =A0 =A0 Test for exclude timeperiod
>> =A0 =A0 =A0 =A0 tuesday -1 - monday 1 =A016:30-24:00
>> =A0 =A0 =A0 =A0 exclude =A0 =A0 =A0 =A0 myexclude
>> =A0 =A0 =A0 =A0 }
>>
>>
>> define timeperiod{
>> =A0 =A0 =A0 =A0 timeperiod_name myexclude
>> =A0 =A0 =A0 =A0 alias myexclude
>> =A0 =A0 =A0 =A0 april 1 - august 16 00:00-24:00
>> =A0 =A0 =A0 =A0 saturday -1 - monday 1 =A016:00-24:00
>> =A0 =A0 =A0 =A0 }
>>
>>
>> And in the file t-tap/test_timeperiods.c line 404:
>>
>> =A0 =A0 =A0 =A0 /* Tests around clock change going back for TZ=3DEurope/=
London.
>> 1256511661 =3D Sun Oct
>> 25 23:01:01 2009 */
>> =A0 =A0 =A0 =A0 /* A little trip to Paris*/
>> =A0 =A0 =A0 =A0 putenv("TZ=3DEurope/Paris");
>> =A0 =A0 =A0 =A0 tzset();
>> =A0 =A0 =A0 =A0 temp_timeperiod =3D find_timeperiod("Test_exclude");
>> =A0 =A0 =A0 =A0 ok(temp_timeperiod!=3DNULL, "ME: Testing Exclude timeper=
iod");
>> =A0 =A0 =A0 =A0 test_time=3D1278939600;
>> =A0 =A0 =A0 =A0 /* printf("Testing at time %s", ctime(&test_time)); */
>> =A0 =A0 =A0 =A0 is_valid_time =3D check_time_against_period(test_time, t=
emp_timeperiod);
>> =A0 =A0 =A0 =A0 ok( is_valid_time=3D=3DERROR, "ME: 12 Jul 2010 15:00:00 =
- false" );
>> =A0 =A0 =A0 =A0 _get_next_valid_time(test_time, test_time, &chosen_valid=
_time,
>> temp_timeperiod);
>> =A0 =A0 =A0 =A0 /* printf("ME: Got chosent time at %s", ctime(&chosen_va=
lid_time)); */
>> =A0 =A0 =A0 =A0 ok( chosen_valid_time=3D=3D1288103400, "ME: Next valid t=
ime=3DTue
>> Oct 26 16:30:00 2010 -> Bug in exclude?");
>>
>> =A0 =A0 =A0 =A0 /* printf("ME Got ask %lu and get %lu\n", test_time,
>> chosen_valid_time); */
>>
>> =A0 =A0 =A0 =A0 /* Back to New york */
>> =A0 =A0 =A0 =A0 putenv("TZ=3DAmerica/New_York");
>> =A0 =A0 =A0 =A0 tzset();
>>
>>
>> The good result should be Tue Oct 26 16:30:00 2010.
>>
>> We are checking the next valid time for Monday 12 Jul 2010 15:00:00.
>> It's not valid (it's july tuesday -1 is Tue Jul 27 16:30:00 2010 the
>> first time available without exclude).
>> So by months:
>> *july 27 is not possible because we got nothing until 16 august.
>> *august : =A0 it's =A0the Tues Aug 31, but it's inside "saturday -1 -
>> monday 1" because saturday -1 is the 28 august, so no.
>> *september : can be the 28, but saturday -1 is the 25, so still no
>> *october : now tuesday -1 is 26 and saturday -1 is 30. So ok, it's this =
one :)
>>
>> Is is my test false or a bug in the get next valid time with exclude?
>>
>> Maybe we can try with a less hard case (but I need to run take baby
>> from the babysitter, so it will be the next week ;) )
>>
>> Thanks,
>>
>>
>> Jean
>>
>
> The "exclude" functionality was discovered to have some bugs that
> returned an incorrect result as is currently a known issue. =A0A fix look=
s
> to be difficult. =A0If you figure out a patch, let us know. =A0Thanks!
>
> - Ethan
>
> -----

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]