Last active
December 16, 2015 09:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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