check_cert.pl
branchModule::Build
changeset 17 bd500305861e
parent 16 9501cc7d9177
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/check_cert.pl	Wed Apr 01 11:19:29 2015 +0200
@@ -0,0 +1,99 @@
+#!/usr/bin/perl
+
+#    Copyright (C) 2015  Matthias Förste
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    Matthias Förste <foerste@schlittermann.de>
+
+=encoding utf8
+=cut
+
+use strict;
+use warnings;
+
+#use Getopt::Long;
+use Pod::Usage;
+
+use Nagios::Plugin;
+
+package Nagios::Plugin::IUS::Cert;
+$VERSION = 2.0;
+
+my $np = Nagios::Plugin->new(  
+    usage => pod2usage ( -verbose => 0, -exitval => 0)
+);
+
+GetOptions(
+    "h|help" => sub { pod2usage( -verbose => 0, -exitval => 0 ) },
+    "m|man"  => sub {
+        pod2usage(
+            -verbose   => 2,
+            -exitval   => 0,
+            -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1]
+        );
+    },
+) or pod2usage();
+
+
+__END__
+
+=pod
+
+=head1 NAME
+
+check_cert - check ssl certificate expiry
+
+=head1 SYNOPSIS
+
+check_cert [options] [directories]
+
+check_cert -m|--man
+           -h|--help
+
+=head1 DESCRIPTION
+
+This script checks the expiry of openssl certificates.
+
+=head1 OPTIONS
+
+=over
+
+=item B<-b|--binary> I<path>
+
+Path to the openssl binary (default: /usr/bin/openssl)
+
+=item B<-w|--warning> I<time>
+
+Return status I<warning> if certificate expires in less than <time>.
+
+=item B<-w|--critical> I<time>
+
+Return status I<critical> if certificate expires in less than <time>.
+
+=back
+
+=head1 NOTES
+
+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).
+
+=head1 FILES
+
+Any files which may be used by 'check_cert' will be listed here.
+
+=head1 AUTHOR
+
+Matthias Förste <foerste@schlittermann.de>
+
+=cut