Skip to content

Commit

Permalink
added condition if we're already expired
Browse files Browse the repository at this point in the history
  • Loading branch information
failshell committed Apr 21, 2014
1 parent b88583c commit caec6ce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/ssl/check-ssl-cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class CheckSSLCert < Sensu::Plugin::Check::CLI
def check_ssl_cert_expiration
expire = `openssl s_client -connect #{config[:host]}:#{config[:port]} < /dev/null 2>&1 | openssl x509 -enddate -noout`.split('=').last
days_until = (Date.parse(expire) - Date.today).to_i
if days_until < config[:critical].to_i
if days_until < 0
critical "Expired #{days_until.abs} days ago - #{config[:host]}:#{config[:port]}"
elsif days_until < config[:critical].to_i
critical "#{days_until} days left - #{config[:host]}:#{config[:port]}"
elsif days_until < config[:warning].to_i
warning "#{days_until} days left - #{config[:host]}:#{config[:port]}"
Expand Down

0 comments on commit caec6ce

Please sign in to comment.