check_rsnapshot.pl
changeset 31 072b9adfb2ac
parent 24 2516a761473b
child 35 539577720214
equal deleted inserted replaced
30:2c350ec405a1 31:072b9adfb2ac
     1 #! /usr/bin/perl -w
     1 #! /usr/bin/perl -w
     2 
     2 
     3 #    Copyright (C) 2011-2013  Christian Arnold
     3 #    Copyright (C) 2011-2013  Christian Arnold
     4 #    Copyright (C) 2013       Matthias Förste
     4 #    Copyright (C) 2013-2018  Matthias Förste
     5 #
     5 #
     6 #    This program is free software: you can redistribute it and/or modify
     6 #    This program is free software: you can redistribute it and/or modify
     7 #    it under the terms of the GNU General Public License as published by
     7 #    it under the terms of the GNU General Public License as published by
     8 #    the Free Software Foundation, either version 3 of the License, or
     8 #    the Free Software Foundation, either version 3 of the License, or
     9 #    (at your option) any later version.
     9 #    (at your option) any later version.
    40 sub get_status($$$);
    40 sub get_status($$$);
    41 sub report($);
    41 sub report($);
    42 sub version($$);
    42 sub version($$);
    43 
    43 
    44 my $ME      = basename $0;
    44 my $ME      = basename $0;
    45 my $VERSION = "2.9";
    45 my $VERSION = "2.10";
    46 
    46 
    47 my %opt = (
    47 my %opt = (
    48     binary => "/usr/bin/rsnapshot",
    48     binary => "/usr/bin/rsnapshot",
    49     maxage => undef,
    49     maxage => undef,
    50     date   => "today"
    50     date   => "today"
    61         "V|version" => sub { version($ME, $VERSION); exit $ERRORS{OK}; }
    61         "V|version" => sub { version($ME, $VERSION); exit $ERRORS{OK}; }
    62     ) or pod2usage(-verbose => 1, -exitval => $ERRORS{CRITICAL});
    62     ) or pod2usage(-verbose => 1, -exitval => $ERRORS{CRITICAL});
    63 
    63 
    64     my @logfiles = @ARGV ? @ARGV : glob '/var/log/rsnapshot.log{,.1.gz}';
    64     my @logfiles = @ARGV ? @ARGV : glob '/var/log/rsnapshot.log{,.1.gz}';
    65 
    65 
    66     my $date = UnixDate(ParseDate($opt{date}), "%d/%b/%Y");
    66     # older versions log the date as %d/%b/%Y
       
    67     my $date = UnixDate(ParseDate($opt{date}), "%d/%b/%Y|%Y-%m-%d");
    67     unless ($date) {
    68     unless ($date) {
    68         print "RSNAPSHOT CRITICAL: can't parse date [$opt{date}]\n";
    69         print "RSNAPSHOT CRITICAL: can't parse date [$opt{date}]\n";
    69         exit $ERRORS{CRITICAL};
    70         exit $ERRORS{CRITICAL};
    70     }
    71     }
    71 
    72 
   157     print <<_VERSION;
   158     print <<_VERSION;
   158 $progname version $version
   159 $progname version $version
   159 Copyright (C) 2011-2013 by Christian Arnold and Schlittermann internet & unix
   160 Copyright (C) 2011-2013 by Christian Arnold and Schlittermann internet & unix
   160 support.
   161 support.
   161 
   162 
   162 Copyright (C) 2013 by Matthias Förste and Schlittermann internet & unix support.
   163 Copyright (C) 2013-2018 by Matthias Förste and Schlittermann internet & unix support.
   163 
   164 
   164 $ME comes with ABSOLUTELY NO WARRANTY. This is free software,
   165 $ME comes with ABSOLUTELY NO WARRANTY. This is free software,
   165 and you are welcome to redistribute it under certain conditions.
   166 and you are welcome to redistribute it under certain conditions.
   166 See the GNU General Public Licence for details.
   167 See the GNU General Public Licence for details.
   167 _VERSION
   168 _VERSION
   232 
   233 
   233 =head1 AUTHORS
   234 =head1 AUTHORS
   234 
   235 
   235 2011-2013 Originally written by Christian Arnold L<arnold@schlittermann.de>.
   236 2011-2013 Originally written by Christian Arnold L<arnold@schlittermann.de>.
   236 
   237 
   237 2013      Maintained by Matthias Förste L<foerste@schlittermann.de>.
   238 2013-2018 Maintained by Matthias Förste L<foerste@schlittermann.de>.
   238 
   239 
   239 =head1 COPYRIGHT
   240 =head1 COPYRIGHT
   240 
   241 
   241 Copyright (C) 2011-2013 by Christian Arnold and Schlittermann internet & unix
   242 Copyright (C) 2011-2013 by Christian Arnold and Schlittermann internet & unix
   242 support. Copyright (C) 2013 by Matthias Förste and Schlittermann internet &
   243 support. Copyright (C) 2013-2018 by Matthias Förste and Schlittermann internet
   243 unix support. This is free software, and you are welcome to redistribute it
   244 & unix support. This is free software, and you are welcome to redistribute it
   244 under certain conditions. See the GNU General Public Licence for details.
   245 under certain conditions. See the GNU General Public Licence for details.
   245 
   246 
   246 =cut
   247 =cut