Skip to content

Instantly share code, notes, and snippets.

@le0pard
Last active December 16, 2015 09:49
Show Gist options
  • Select an option

  • Save le0pard/5416074 to your computer and use it in GitHub Desktop.

Select an option

Save le0pard/5416074 to your computer and use it in GitHub Desktop.
This scout plugin give info about ssl cert, which installed on web server. You can create trigger, which will notify before ssl cert expired.
require 'net/https'
require 'uri'
class SimpleSslCheckPlugin < Scout::Plugin
OPTIONS=<<-EOS
url:
default: https://localhost
EOS
def build_report
uri = URI.parse(option(:url))
http = Net::HTTP.new(uri.host,uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |h|
@cert = h.peer_cert
end
report(
subject: @cert.subject,
issuer: @cert.issuer,
serial: @cert.serial,
issued: @cert.not_before.to_i,
expires: @cert.not_after.to_i,
days_left: ((@cert.not_after - Time.now) / 86400).floor
)
rescue => e
error("Some error: #{e.inspect}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment