Cheshire Cat Computing

Software support and information
It is currently Mon May 20, 2013 9:36 am

All times are UTC + 12 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Mar 09, 2012 1:01 am 
Offline
User

Joined: Fri Mar 09, 2012 12:53 am
Posts: 3
Hi Steve,

I'm using your very useful recurring downtime tool for about a year right now, but recently i found that some of the recurring schedules seem to be wrong:

Attachment:
recurr1.png


I have some computers in a hostgroup called nhs-capax, an we need a recurring downtime for each Monday from 09:00 to 09:15, but when I look at the resulting scheduled downtime, all hosts in this hostgroup are scheduled for Thursday from 09:00 to 09:15. I never noticed this before, maybe it is caused by the leap year, since we just had feb 29th?

Attachment:
recurr2.png



Or is there anything that I'm doing wrong?

Best regards,
Michael


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
PostPosted: Fri Mar 09, 2012 10:38 am 
Offline
Site Admin

Joined: Tue Jul 29, 2003 11:42 am
Posts: 2921
Location: Auckland, New Zealand
Just checked the code, and you're right. The leap year fixes in v3.2 did fix part of it, but not all of it; theres still a case where 29th Feb is not though of as valid in a leap year in downtime_sched.pl.

I've done the fix in v3.3.

Here's the bit of downtime_sched.pl to fix,where it tries to jump forwar done day:
Code:
        # if in the past, advance one day
        if(($h>$nh) or ($h==$nh and $min>$nmin) ) {
            $nd+=1; $dow += 1; $dow = 0 if($dow == 7);
            if(($nd>29)and($nm==1)and(int($ny/4)==($ny/4)))
                {$nm+=1;$nd-=29;} #  Leap yrs?
            if(($nd>28)and($nm==1)and(int($ny/4)!=($ny/4)))
                {$nm+=1;$nd-=28;}
            if(($nd>30)and($nm==8 or $nm==3 or $nm==5 or $nm==10))
                    {$nm+=1;$nd-=30;}
            if($nd>31) {$nm+=1;$nd-=31;}
            if($nm>11) {$ny+=1;$nm-=12;}
        }

Also this bit, where it tries to go forward one week:
Code:
                # if we advanced the day, then make sure the month is right
                if(($nd>29)and($nm==1)and(int($ny/4)==($ny/4)))
                    {$nm+=1;$nd-=29;} #  Leap yrs?
                if(($nd>28)and($nm==1)and(int($ny/4)!=($ny/4)))
                    {$nm+=1;$nd-=28;}
                if(($nd>30)and($nm==8 or $nm==3 or $nm==5 or $nm==10))
                     {$nm+=1;$nd-=30;}
                if($nd>31) {$nm+=1;$nd-=31;}
                if($nm>11){$nm-=12;$ny+=1; }

_________________
Steve Shipway
UNIX Systems, ITSS, University of Auckland, NZ
Woe unto them that rise up early in the morning... -- Isaiah 5:11


Top
 Profile  
 
PostPosted: Fri Mar 09, 2012 11:42 pm 
Offline
User

Joined: Fri Mar 09, 2012 12:53 am
Posts: 3
Hi Steve,

thank you for the quick reply, but when I change the code according to your recommendations, then all the hosts in this special hostgroup get scheduled downtime at 09:00 on 16/3/2012, which is next Friday.

When looking into the output of the perl script, it says:

Code:
...
Montags Neustart zwischen 0900 und 0915:
Current candidate: 09:00 on 9/3/2012
Current candidate: 09:00 on 10/3/2012
Checking days of week: days (1) are valid
Advancing a week to day 1
Current candidate: 09:00 on 16/3/2012
Scheduling hostgroup nhs-capax
Checking hostgroup representative WS-NHS-CAPAX02:1331884800
Sending command 'SCHEDULE_HOSTGROUP_HOST_DOWNTIME;nhs-capax;1331884800;1331885700;1;0;0;michael.van-der-kamp;AUTO: Montags Neustart zwischen 0900 und 0915
'
SCHEDULE_HOSTGROUP_HOST_DOWNTIME;nhs-capax;1331884800;1331885700;1;0;0;michael.van-der-kamp;AUTO: Montags Neustart zwischen 0900 und 0915


Maybe I did something wrong while pasting your code snippets into the v3.2 script, so would you mind giving me a download link for the already corrected v3.3? I can't find it anywhere on the web, all links seem to be broken...

Best regards,
Michael


Top
 Profile  
 
PostPosted: Wed Mar 14, 2012 10:41 am 
Offline
Site Admin

Joined: Tue Jul 29, 2003 11:42 am
Posts: 2921
Location: Auckland, New Zealand
Here is a copy of the v3.3 trunk beta that we are currently using. Please let me know if there are any issues...

Steve


You do not have the required permissions to view the files attached to this post.

_________________
Steve Shipway
UNIX Systems, ITSS, University of Auckland, NZ
Woe unto them that rise up early in the morning... -- Isaiah 5:11


Top
 Profile  
 
PostPosted: Wed Mar 14, 2012 9:48 pm 
Offline
User

Joined: Fri Mar 09, 2012 12:53 am
Posts: 3
Hi Steve,

thanks a lot for the great help, now everything works as usual!

Best regards,
Michael


Top
 Profile  
 
PostPosted: Thu Mar 22, 2012 12:39 am 
Offline
User

Joined: Thu Mar 22, 2012 12:31 am
Posts: 1
Hi,
Thanks, it works fine.
I modified it to make flexible downtime instead of fixed one.


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 12 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group