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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

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

Post by Guest »

Hi,

I see in the Changelog that the correction was for hour change, not
for exclude (http://nagios.org/development/history/core-3x "Don't use
these for now - we'll get this fixed for 3.4"). So it's ok, I'll find
another way.


Jean


On Fri, Jul 23, 2010 at 4:56 PM, 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 =A0timeperiod_name Test_exclude
> =A0 =A0 =A0 =A0alias =A0 =A0 =A0 =A0 =A0 Test for exclude timeperiod
> =A0 =A0 =A0 =A0tuesday -1 - monday 1 =A016:30-24:00
> =A0 =A0 =A0 =A0exclude =A0 =A0 =A0 =A0 myexclude
> =A0 =A0 =A0 =A0}
>
>
> define timeperiod{
> =A0 =A0 =A0 =A0timeperiod_name myexclude
> =A0 =A0 =A0 =A0alias myexclude
> =A0 =A0 =A0 =A0april 1 - august 16 00:00-24:00
> =A0 =A0 =A0 =A0saturday -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/Lo=
ndon.
> 1256511661 =3D Sun Oct
> 25 23:01:01 2009 */
> =A0 =A0 =A0 =A0/* A little trip to Paris*/
> =A0 =A0 =A0 =A0putenv("TZ=3DEurope/Paris");
> =A0 =A0 =A0 =A0tzset();
> =A0 =A0 =A0 =A0temp_timeperiod =3D find_timeperiod("Test_exclude");
> =A0 =A0 =A0 =A0ok(temp_timeperiod!=3DNULL, "ME: Testing Exclude timeperio=
d");
> =A0 =A0 =A0 =A0test_time=3D1278939600;
> =A0 =A0 =A0 =A0/* printf("Testing at time %s", ctime(&test_time)); */
> =A0 =A0 =A0 =A0is_valid_time =3D check_time_against_period(test_time, tem=
p_timeperiod);
> =A0 =A0 =A0 =A0ok( 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_t=
ime,
> temp_timeperiod);
> =A0 =A0 =A0 =A0/* printf("ME: Got chosent time at %s", ctime(&chosen_vali=
d_time)); */
> =A0 =A0 =A0 =A0ok( chosen_valid_time=3D=3D1288103400, "ME: Next valid tim=
e=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 =A0putenv("TZ=3DAmerica/New_York");
> =A0 =A0 =A0 =A0tzset();
>
>
> 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 o=
ne :)
>
> 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
>





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