class CertCheck

Constants

VERSION

Public Instance Methods

certs() click to toggle source
# File lib/openvpn_cert_nagios/check.rb, line 24
def certs
  @certs ||= Dir.new(options.path)
    .entries
    .find_all{ |f| f =~ /.*\.crt$/ }
    .map { |f| "#{ options.path }/#{ f }" }
end
check() click to toggle source
# File lib/openvpn_cert_nagios/check.rb, line 11
def check

  result = certs.reduce({days: 9999, message: []}) do |memo, file|
    cert = Cert.new(file)
    memo[:message] << cert.message
    memo[:days] = [cert.expires_in, memo[:days]].min
    memo
  end

  store_value :expires, result[:days]
  store_message result[:message].sort.join(",").delete(' ')
end