Fix #2213
This commit is contained in:
parent
0272cd2425
commit
97457e60ff
|
@ -31,22 +31,22 @@ use centreon::plugins::misc;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'hostname:s' => { name => 'hostname' },
|
||||||
"hostname:s" => { name => 'hostname' },
|
'port:s' => { name => 'port' },
|
||||||
"port:s" => { name => 'port' },
|
'servername:s' => { name => 'servername' },
|
||||||
"servername:s" => { name => 'servername' },
|
'validity-mode:s' => { name => 'validity_mode' },
|
||||||
"validity-mode:s" => { name => 'validity_mode' },
|
'warning-date:s' => { name => 'warning' },
|
||||||
"warning-date:s" => { name => 'warning' },
|
'critical-date:s' => { name => 'critical' },
|
||||||
"critical-date:s" => { name => 'critical' },
|
'subjectname:s' => { name => 'subjectname', default => '' },
|
||||||
"subjectname:s" => { name => 'subjectname', default => '' },
|
'issuername:s' => { name => 'issuername', default => '' },
|
||||||
"issuername:s" => { name => 'issuername', default => '' },
|
'timeout:s' => { name => 'timeout', default => 5 },
|
||||||
"timeout:s" => { name => 'timeout', default => 5 },
|
'ssl-opt:s%' => { name => 'ssl_opt' }
|
||||||
'ssl-opt:s%' => { name => 'ssl_opt' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ sub run {
|
||||||
$self->{output}->exit()
|
$self->{output}->exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
#Retrieve Certificat
|
#Retrieve Certificate
|
||||||
my $cert;
|
my $cert;
|
||||||
eval { $cert = $client->peer_certificate() };
|
eval { $cert = $client->peer_certificate() };
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
@ -124,6 +124,12 @@ sub run {
|
||||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(severity => $exit,
|
||||||
short_msg => sprintf("Certificate expiration for '%s' in days: %s - Validity Date: %s", $subject, $daysbefore, $notafterdate));
|
short_msg => sprintf("Certificate expiration for '%s' in days: %s - Validity Date: %s", $subject, $daysbefore, $notafterdate));
|
||||||
|
$self->{output}->perfdata_add(
|
||||||
|
nlabel => 'certificate.expiration.days.count',
|
||||||
|
value => $daysbefore,
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||||
|
);
|
||||||
#Subject Name
|
#Subject Name
|
||||||
} elsif ($self->{option_results}->{validity_mode} eq 'subject') {
|
} elsif ($self->{option_results}->{validity_mode} eq 'subject') {
|
||||||
my @subject_matched = ();
|
my @subject_matched = ();
|
||||||
|
|
|
@ -30,10 +30,10 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'certificate' => 'apps::protocols::x509::mode::certificate',
|
'certificate' => 'apps::protocols::x509::mode::certificate',
|
||||||
'validity' => 'apps::protocols::x509::mode::validity', #legacy mode
|
'validity' => 'apps::protocols::x509::mode::validity' #legacy mode
|
||||||
);
|
};
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue