if (($opts{'host'}) && ($opts{'port'})) {
push @{$hosts{$opts{'host'}}}, $opts{'port'};
if (($opts{'host'}) && ($opts{'port'})) {
push @{$hosts{$opts{'host'}}}, $opts{'port'};
- } elsif (/^mail[ ]*=/) {
- ($tmp,$mail) = split /=/, $_;
- # Use hosts from config file if noone are given by command line
+ } elsif (/^mail[ \t]*=/) {
+ ($tmp,$mail) = split /=/, $_;
+ # Use hosts from config file if none are given by command line
- ($tmp,$portlist) = split /:/, $_;
- chomp ($tmp);
- chomp ($portlist);
- # There is multiple ports
- if (/,/) {
- @ports = split /,/, $portlist;
- foreach (@ports) {
- push @{$hosts{$tmp}}, $_;
- }
- # There is only one port
- } else {
- push @{$hosts{$tmp}},$portlist;
- }
+ ($tmp,$portlist) = split /:/, $_;
+ chomp ($tmp);
+ chomp ($portlist);
+ # There is multiple ports
+ if (/,/) {
+ @ports = split /,/, $portlist;
+ foreach (@ports) {
+ push @{$hosts{$tmp}}, $_;
+ }
+ # There is only one port
+ } else {
+ push @{$hosts{$tmp}},$portlist;
+ }
if ($l_x509) {
my $l_string = Net::SSLeay::PEM_get_string_X509($l_x509);
# Get the expiration date, using openssl
if ($l_x509) {
my $l_string = Net::SSLeay::PEM_get_string_X509($l_x509);
# Get the expiration date, using openssl
- ($l_expdate,$l_comment) = split(/\n/, `echo "$l_string" | $opensslpath x509 -enddate -subject -noout 2>&1`);
+ ($l_expdate,$l_comment) = split(/\n/, `echo "$l_string" | $opensslpath x509 -enddate -subject -noout 2>&1`);
my ($l_expdate,$l_comment,$l_host,$l_port) = @_;
my $l_subject = "";
if ($l_expdate ne "1") {
# The current date
my $l_today = time;
my ($l_expdate,$l_comment,$l_host,$l_port) = @_;
my $l_subject = "";
if ($l_expdate ne "1") {
# The current date
my $l_today = time;
# Report if needed
if ($l_diff < $alert) {
$l_subject = "Warning ssl certificate on $l_host:$l_port expires in $l_diff days:" if ($l_diff > 1);
$l_subject = "Warning ssl certificate on $l_host:$l_port expires today:" if (($l_diff > 0) && ($l_diff < 1));
$l_subject = "Warning ssl certificate on $l_host:$l_port expired:" if ($l_diff <= 0);
# Report if needed
if ($l_diff < $alert) {
$l_subject = "Warning ssl certificate on $l_host:$l_port expires in $l_diff days:" if ($l_diff > 1);
$l_subject = "Warning ssl certificate on $l_host:$l_port expires today:" if (($l_diff > 0) && ($l_diff < 1));
$l_subject = "Warning ssl certificate on $l_host:$l_port expired:" if ($l_diff <= 0);
# Report
&report("$expdate","$comment","$host","$port");
}
# Report
&report("$expdate","$comment","$host","$port");
}