1.0.11 - patched yearly snapshot bug, thanks @stevenolen for the bug report!
This commit is contained in:
parent
c6a5aad2aa
commit
9b5f0fc3d3
|
@ -1,3 +1,5 @@
|
||||||
|
1.0.11 patched bug in yearly snapshots - thank you @stevenolen for the bug report!
|
||||||
|
|
||||||
1.0.10 added --monitor-version to check installed version against current version in trunk on GitHub
|
1.0.10 added --monitor-version to check installed version against current version in trunk on GitHub
|
||||||
|
|
||||||
1.0.9 added CR/LF after --monitor-health message output to make CLI usage cleaner looking
|
1.0.9 added CR/LF after --monitor-health message output to make CLI usage cleaner looking
|
||||||
|
|
31
sanoid
31
sanoid
|
@ -4,14 +4,13 @@
|
||||||
# from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this
|
# from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this
|
||||||
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
|
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
|
||||||
|
|
||||||
my $version = '1.0.10';
|
my $version = '1.0.8';
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use Config::IniFiles; # read samba-style conf file
|
use Config::IniFiles; # read samba-style conf file
|
||||||
use File::Path; # for rmtree command in use_prune
|
use File::Path; # for rmtree command in use_prune
|
||||||
use Data::Dumper; # debugging - print contents of hash
|
use Data::Dumper; # debugging - print contents of hash
|
||||||
use Time::Local; # to parse dates in reverse
|
use Time::Local; # to parse dates in reverse
|
||||||
use LWP::Simple; # to check VERSION against trunk on Github
|
|
||||||
|
|
||||||
my $pscmd = '/bin/ps';
|
my $pscmd = '/bin/ps';
|
||||||
|
|
||||||
|
@ -44,9 +43,6 @@ if ($ARGV[0] eq '--verbose') {
|
||||||
} elsif ($ARGV[0] eq '--version') {
|
} elsif ($ARGV[0] eq '--version') {
|
||||||
print "Sanoid version: $version\n";
|
print "Sanoid version: $version\n";
|
||||||
exit 0;
|
exit 0;
|
||||||
} elsif ($ARGV[0] eq '--monitor-version') {
|
|
||||||
monitor_version();
|
|
||||||
exit 0;
|
|
||||||
} elsif ($ARGV[0] eq '--cron' || 1) {
|
} elsif ($ARGV[0] eq '--cron' || 1) {
|
||||||
take_snapshots (@params);
|
take_snapshots (@params);
|
||||||
prune_snapshots (@params);
|
prune_snapshots (@params);
|
||||||
|
@ -59,18 +55,6 @@ exit 0;
|
||||||
####################################################################################
|
####################################################################################
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
sub monitor_version() {
|
|
||||||
my $trunkversion = get("https://raw.githubusercontent.com/jimsalterjrs/sanoid/master/VERSION");
|
|
||||||
chomp $trunkversion;
|
|
||||||
if ($version eq $trunkversion) {
|
|
||||||
print "OK: local version $version matches trunk version $trunkversion\n";
|
|
||||||
exit 0;
|
|
||||||
} else {
|
|
||||||
print "WARN: local version $version does not match trunk version $trunkversion\n";
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub monitor_health() {
|
sub monitor_health() {
|
||||||
my ($config, $snaps, $snapsbytype, $snapsbypath) = @_;
|
my ($config, $snaps, $snapsbytype, $snapsbypath) = @_;
|
||||||
my %pools;
|
my %pools;
|
||||||
|
@ -91,7 +75,7 @@ sub monitor_health() {
|
||||||
|
|
||||||
my @warninglevels = ('','*** WARNING *** ','*** CRITICAL *** ');
|
my @warninglevels = ('','*** WARNING *** ','*** CRITICAL *** ');
|
||||||
my $message = $warninglevels[$errlevel] . join (', ',@messages);
|
my $message = $warninglevels[$errlevel] . join (', ',@messages);
|
||||||
print "$message\n";
|
print $message;
|
||||||
exit $errlevel;
|
exit $errlevel;
|
||||||
|
|
||||||
} # end monitor_health()
|
} # end monitor_health()
|
||||||
|
@ -310,10 +294,10 @@ sub take_snapshots {
|
||||||
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24*31; } # preferred time is later this month - so look at last month's
|
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24*31; } # preferred time is later this month - so look at last month's
|
||||||
} elsif ($type eq 'yearly') {
|
} elsif ($type eq 'yearly') {
|
||||||
push @preferredtime,0; # try to hit 0 seconds
|
push @preferredtime,0; # try to hit 0 seconds
|
||||||
push @preferredtime,$config{$section}{'monthly_min'};
|
push @preferredtime,$config{$section}{'yearly_min'};
|
||||||
push @preferredtime,$config{$section}{'monthly_hour'};
|
push @preferredtime,$config{$section}{'yearly_hour'};
|
||||||
push @preferredtime,$config{$section}{'monthly_mday'};
|
push @preferredtime,$config{$section}{'yearly_mday'};
|
||||||
push @preferredtime,($config{$section}{'monthly_mon'}-1); # january is month 0
|
push @preferredtime,($config{$section}{'yearly_mon'}-1); # january is month 0
|
||||||
push @preferredtime,$datestamp{'year'};
|
push @preferredtime,$datestamp{'year'};
|
||||||
$lastpreferred = timelocal(@preferredtime);
|
$lastpreferred = timelocal(@preferredtime);
|
||||||
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24*31*365.25; } # preferred time is later this year - so look at last year
|
if ($lastpreferred > time()) { $lastpreferred -= 60*60*24*31*365.25; } # preferred time is later this year - so look at last year
|
||||||
|
@ -565,7 +549,8 @@ sub init {
|
||||||
$config{$section}{'monthly_hour'} = 0;
|
$config{$section}{'monthly_hour'} = 0;
|
||||||
$config{$section}{'monthly_min'} = 0;
|
$config{$section}{'monthly_min'} = 0;
|
||||||
# yearly - immediately at the beginning of the year (ie 00:00 on Jan 1)
|
# yearly - immediately at the beginning of the year (ie 00:00 on Jan 1)
|
||||||
$config{$section}{'yearly_yday'} = 1;
|
$config{$section}{'yearly_mday'} = 1;
|
||||||
|
$config{$section}{'yearly_mon'} = 1;
|
||||||
$config{$section}{'yearly_hour'} = 0;
|
$config{$section}{'yearly_hour'} = 0;
|
||||||
$config{$section}{'yearly_min'} = 0;
|
$config{$section}{'yearly_min'} = 0;
|
||||||
$config{$section}{'monitor_dont_warn'} = 0;
|
$config{$section}{'monitor_dont_warn'} = 0;
|
||||||
|
|
Loading…
Reference in New Issue