source: trunk/locker/sbin/check-ldap-certs.pl @ 1571

Last change on this file since 1571 was 1571, checked in by adehnert, 12 years ago
Print the local hostname from check-ldap-certs.pl
  • Property svn:executable set to *
File size: 850 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use File::Basename;
5use Date::Parse;
6use Sys::Hostname;
7
8my @servers = qw(cats-whiskers.mit.edu pancake-bunny.mit.edu real-mccoy.mit.edu busy-beaver.mit.edu bees-knees.mit.edu);
9
10my $hostname = hostname();
11
12my $now = time();
13
14my $dir = dirname($0);
15
16our $verbose = 0;
17$verbose = 1 if ($ARGV[0] eq "-v");
18
19use constant WARNING => 60*60*24*14; # Warn if a cert is expiring within 14 days
20
21foreach my $server (@servers) {
22  open(X509, "-|", "$dir/ssl-get-endtime", "$server:636") or die "Couldn't invoke ssl-get-endtime: $!";
23  chomp(my $exp = <X509>);
24  close(X509);
25  $exp =~ s/^notAfter=// or warn "Cert appears broken: $server";
26
27  my $time = str2time($exp);
28
29  if ($verbose || ($time - $now) <= WARNING) {
30    printf "$hostname: Certificate expiring in %.2f days: %s\n", (($time - $now) / (60.0*60*24)), $server;
31  }
32}
Note: See TracBrowser for help on using the repository browser.