check_cert.pl
branchModule::Build
changeset 17 bd500305861e
parent 16 9501cc7d9177
equal deleted inserted replaced
16:9501cc7d9177 17:bd500305861e
       
     1 #!/usr/bin/perl
       
     2 
       
     3 #    Copyright (C) 2015  Matthias Förste
       
     4 #
       
     5 #    This program is free software: you can redistribute it and/or modify
       
     6 #    it under the terms of the GNU General Public License as published by
       
     7 #    the Free Software Foundation, either version 3 of the License, or
       
     8 #    (at your option) any later version.
       
     9 #
       
    10 #    This program is distributed in the hope that it will be useful,
       
    11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13 #    GNU General Public License for more details.
       
    14 #
       
    15 #    You should have received a copy of the GNU General Public License
       
    16 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    17 #
       
    18 #    Matthias Förste <foerste@schlittermann.de>
       
    19 
       
    20 =encoding utf8
       
    21 =cut
       
    22 
       
    23 use strict;
       
    24 use warnings;
       
    25 
       
    26 #use Getopt::Long;
       
    27 use Pod::Usage;
       
    28 
       
    29 use Nagios::Plugin;
       
    30 
       
    31 package Nagios::Plugin::IUS::Cert;
       
    32 $VERSION = 2.0;
       
    33 
       
    34 my $np = Nagios::Plugin->new(  
       
    35     usage => pod2usage ( -verbose => 0, -exitval => 0)
       
    36 );
       
    37 
       
    38 GetOptions(
       
    39     "h|help" => sub { pod2usage( -verbose => 0, -exitval => 0 ) },
       
    40     "m|man"  => sub {
       
    41         pod2usage(
       
    42             -verbose   => 2,
       
    43             -exitval   => 0,
       
    44             -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1]
       
    45         );
       
    46     },
       
    47 ) or pod2usage();
       
    48 
       
    49 
       
    50 __END__
       
    51 
       
    52 =pod
       
    53 
       
    54 =head1 NAME
       
    55 
       
    56 check_cert - check ssl certificate expiry
       
    57 
       
    58 =head1 SYNOPSIS
       
    59 
       
    60 check_cert [options] [directories]
       
    61 
       
    62 check_cert -m|--man
       
    63            -h|--help
       
    64 
       
    65 =head1 DESCRIPTION
       
    66 
       
    67 This script checks the expiry of openssl certificates.
       
    68 
       
    69 =head1 OPTIONS
       
    70 
       
    71 =over
       
    72 
       
    73 =item B<-b|--binary> I<path>
       
    74 
       
    75 Path to the openssl binary (default: /usr/bin/openssl)
       
    76 
       
    77 =item B<-w|--warning> I<time>
       
    78 
       
    79 Return status I<warning> if certificate expires in less than <time>.
       
    80 
       
    81 =item B<-w|--critical> I<time>
       
    82 
       
    83 Return status I<critical> if certificate expires in less than <time>.
       
    84 
       
    85 =back
       
    86 
       
    87 =head1 NOTES
       
    88 
       
    89 Time Ranges may be given as <number><suffix>, where <suffix> can be one of s, m, h or d for seconds, minutes, hours or days (default).
       
    90 
       
    91 =head1 FILES
       
    92 
       
    93 Any files which may be used by 'check_cert' will be listed here.
       
    94 
       
    95 =head1 AUTHOR
       
    96 
       
    97 Matthias Förste <foerste@schlittermann.de>
       
    98 
       
    99 =cut