implemented weekly period
This commit is contained in:
parent
09a879664a
commit
00b9206829
26
sanoid
26
sanoid
|
@ -121,15 +121,16 @@ sub monitor_snapshots {
|
|||
my $path = $config{$section}{'path'};
|
||||
push @paths, $path;
|
||||
|
||||
my @types = ('yearly','monthly','daily','hourly');
|
||||
my @types = ('yearly','monthly', 'weekly', 'daily','hourly');
|
||||
foreach my $type (@types) {
|
||||
|
||||
my $smallerperiod = 0;
|
||||
# we need to set the period length in seconds first
|
||||
if ($type eq 'hourly') { $smallerperiod = 60; }
|
||||
elsif ($type eq 'daily') { $smallerperiod = 60*60; }
|
||||
elsif ($type eq 'monthly') { $smallerperiod = 60*60*24; }
|
||||
elsif ($type eq 'yearly') { $smallerperiod = 60*60*24; }
|
||||
elsif ($type eq 'weekly') { $smallerperiod = 60*60*24; }
|
||||
elsif ($type eq 'monthly') { $smallerperiod = 60*60*24*7; }
|
||||
elsif ($type eq 'yearly') { $smallerperiod = 60*60*24*31; }
|
||||
|
||||
my $typewarn = $type . '_warn';
|
||||
my $typecrit = $type . '_crit';
|
||||
|
@ -202,6 +203,7 @@ sub prune_snapshots {
|
|||
# we need to set the period length in seconds first
|
||||
if ($type eq 'hourly') { $period = 60*60; }
|
||||
elsif ($type eq 'daily') { $period = 60*60*24; }
|
||||
elsif ($type eq 'weekly') { $period = 60*60*24*7; }
|
||||
elsif ($type eq 'monthly') { $period = 60*60*24*31; }
|
||||
elsif ($type eq 'yearly') { $period = 60*60*24*365.25; }
|
||||
|
||||
|
@ -309,6 +311,24 @@ sub take_snapshots {
|
|||
push @preferredtime,$datestamp{'year'};
|
||||
$lastpreferred = timelocal(@preferredtime);
|
||||
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24; } # preferred time is later today - so look at yesterday's
|
||||
} elsif ($type eq 'weekly') {
|
||||
# calculate offset in seconds for the desired weekday
|
||||
my $offset;
|
||||
if ($config{$section}{'weekly_wday'} < $datestamp{'wday'}) {
|
||||
$offset += 6;
|
||||
}
|
||||
$offset += $config{$section}{'weekly_wday'} - $datestamp{'wday'};
|
||||
$offset *= 60*60*24; # full day
|
||||
|
||||
push @preferredtime,0; # try to hit 0 seconds
|
||||
push @preferredtime,$config{$section}{'weekly_min'};
|
||||
push @preferredtime,$config{$section}{'weekly_hour'};
|
||||
push @preferredtime,$datestamp{'mday'};
|
||||
push @preferredtime,($datestamp{'mon'}-1); # january is month 0
|
||||
push @preferredtime,$datestamp{'year'};
|
||||
$lastpreferred = timelocal(@preferredtime);
|
||||
$lastpreferred -= $offset;
|
||||
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24*7; } # preferred time is later today - so look at yesterday's
|
||||
} elsif ($type eq 'monthly') {
|
||||
push @preferredtime,0; # try to hit 0 seconds
|
||||
push @preferredtime,$config{$section}{'monthly_min'};
|
||||
|
|
|
@ -24,6 +24,7 @@ process_children_only =
|
|||
autoprune = yes
|
||||
hourly = 48
|
||||
daily = 90
|
||||
weekly = 0
|
||||
monthly = 6
|
||||
yearly = 0
|
||||
min_percent_free = 10
|
||||
|
@ -40,6 +41,10 @@ hourly_min = 0
|
|||
# daily - at 23:59 (most people expect a daily to contain everything done DURING that day)
|
||||
daily_hour = 23
|
||||
daily_min = 59
|
||||
# weekly -at 23:30 each Monday
|
||||
weekly_wday = 1
|
||||
weekly_hour = 23
|
||||
weekly_min = 30
|
||||
# monthly - immediately at the beginning of the month (ie 00:00 of day 1)
|
||||
monthly_mday = 1
|
||||
monthly_hour = 0
|
||||
|
@ -66,7 +71,9 @@ hourly_warn = 90
|
|||
hourly_crit = 360
|
||||
daily_warn = 28
|
||||
daily_crit = 32
|
||||
monthly_warn = 32
|
||||
monthly_crit = 35
|
||||
weekly_warn = 7
|
||||
weekly_crit = 10
|
||||
monthly_warn = 5
|
||||
monthly_crit = 6
|
||||
yearly_warn = 0
|
||||
yearly_crit = 0
|
||||
|
|
Loading…
Reference in New Issue