Class: CertCheck::Cert
- Inherits:
-
Object
- Object
- CertCheck::Cert
- Defined in:
- lib/openvpn_cert_nagios/certs.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #chk_command ⇒ Object
- #expiration_date ⇒ Object
- #expiration_row ⇒ Object
- #expires_in ⇒ Object
-
#initialize(path) ⇒ Cert
constructor
A new instance of Cert.
- #message ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(path) ⇒ Cert
Returns a new instance of Cert.
3 4 5 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 3 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 6 def path @path end |
Instance Method Details
#chk_command ⇒ Object
28 29 30 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 28 def chk_command Shell.exe("openssl x509 -in #{path} -inform PEM -text -noout -enddate -startdate") end |
#expiration_date ⇒ Object
20 21 22 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 20 def expiration_date Date.parse(expiration_row.split("=", 2)[1]) end |
#expiration_row ⇒ Object
24 25 26 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 24 def expiration_row chk_command.find { |x| x =~ /^notAfter=/ } end |
#expires_in ⇒ Object
8 9 10 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 8 def expires_in expiration_date - Date.today end |
#message ⇒ Object
12 13 14 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 12 def "%4d:%s" % [expires_in, name] end |
#name ⇒ Object
16 17 18 |
# File 'lib/openvpn_cert_nagios/certs.rb', line 16 def name File.basename(path, ".crt") end |