sensu-plugins-sslcrt 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +10 -0
- data/LICENSE +23 -0
- data/README.md +18 -0
- data/bin/check-sslcrt.rb +67 -0
- data/lib/sensu-plugins-sslcrt.rb +1 -0
- data/lib/sensu-plugins-sslcrt/version.rb +9 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b8764080400ba0d69c5ef71ba2184e0f169619a6
|
4
|
+
data.tar.gz: 488e9890bbe2661cf3b0b8ba13daa049a70a4f88
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b7c0695f23ed9d800677aed734496911d799eb34e36bbe622de841c637df7ab74ae79e6d4ddf52e8ca663f3f940e225a48be8c30f40ff6aa68da8678e6b67c61
|
7
|
+
data.tar.gz: a8e86e9759e78766c9ae501e1e7fcb0e60a7f39ba785553d2ea10fee91d168a492aea7616924bf696a76cf19f9f081d571d944dc996c3acd34a7d35b79fafa40
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2015 Matteo Cerutti
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Sensu plugin for monitoring SSL certificates
|
2
|
+
|
3
|
+
A sensu plugin to monitor the validity of SSL certificates
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
The plugin accepts the following command line options:
|
8
|
+
|
9
|
+
```
|
10
|
+
Usage: check-sslcrt.rb (options)
|
11
|
+
--connect <HOST>[:<PORT>] This specifies the host and optional port to connect to
|
12
|
+
-c, --crit <DAYS> Critical if expiration date is DAYS away
|
13
|
+
-f, --file <CERT_FILE> This specifies the input filename to read a certificate from
|
14
|
+
-w, --warn <DAYS> Warn if expiration date is DAYS away
|
15
|
+
```
|
16
|
+
|
17
|
+
## Author
|
18
|
+
Matteo Cerutti - <matteo.cerutti@hotmail.co.uk>
|
data/bin/check-sslcrt.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-sslcrt.rb
|
4
|
+
#
|
5
|
+
# Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk>
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'sensu-plugin/check/cli'
|
9
|
+
require 'time'
|
10
|
+
|
11
|
+
class CheckSslCrt < Sensu::Plugin::Check::CLI
|
12
|
+
option :connect,
|
13
|
+
:description => "This specifies the host and optional port to connect to",
|
14
|
+
:long => "--connect <HOST>[:<PORT>]",
|
15
|
+
:default => nil
|
16
|
+
|
17
|
+
option :file,
|
18
|
+
:description => "This specifies the input filename to read a certificate from",
|
19
|
+
:short => "-f <CERT_FILE>",
|
20
|
+
:long => "--file <CERT_FILE>",
|
21
|
+
:default => nil
|
22
|
+
|
23
|
+
option :warn,
|
24
|
+
:description => "Warn if expiration date is DAYS away",
|
25
|
+
:short => "-w <DAYS>",
|
26
|
+
:long => "--warn <DAYS>",
|
27
|
+
:proc => proc(&:to_i),
|
28
|
+
:default => 25
|
29
|
+
|
30
|
+
option :crit,
|
31
|
+
:description => "Critical if expiration date is DAYS away",
|
32
|
+
:short => "-c <DAYS>",
|
33
|
+
:long => "--crit <DAYS>",
|
34
|
+
:proc => proc(&:to_i),
|
35
|
+
:default => 10
|
36
|
+
|
37
|
+
def initialize()
|
38
|
+
super
|
39
|
+
|
40
|
+
raise "Must provide either --connect or --file command line options" if (config[:connect] and config[:file]) or (!config[:connect] and !config[:file])
|
41
|
+
raise "Critical threshold must be lower than the warning threshold" if config[:crit] >= config[:warn]
|
42
|
+
end
|
43
|
+
|
44
|
+
def expiration_date()
|
45
|
+
if config[:connect]
|
46
|
+
date = %x[openssl s_client -connect #{config[:connect]} 2>/dev/null </dev/null | openssl x509 -noout -dates]
|
47
|
+
else
|
48
|
+
date = %x[openssl x509 -enddate -noout -in #{config[:file]}]
|
49
|
+
end
|
50
|
+
|
51
|
+
Time.parse(date[/^notAfter=(.*)/, 1])
|
52
|
+
end
|
53
|
+
|
54
|
+
def run
|
55
|
+
days_left = ((expiration_date() - Time.now) / 86400).to_i
|
56
|
+
|
57
|
+
if config[:connect]
|
58
|
+
msg = "SSL certificate for host #{config[:connect]} will expire in #{days_left} days"
|
59
|
+
else
|
60
|
+
msg = "SSL certificate file '#{config[:file]}' will expire in #{days_left} days"
|
61
|
+
end
|
62
|
+
|
63
|
+
critical(msg + " (<= #{config[:crit]})") if days_left <= config[:crit]
|
64
|
+
warning(msg + " (<= #{config[:warn]})") if days_left <= config[:warn]
|
65
|
+
ok(msg + " (> #{config[:warn]})")
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-sslcrt/version'
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-sslcrt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matteo Cerutti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-plugin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.0
|
27
|
+
description: This plugin provides facilities for monitoring the validity of SSL certificates
|
28
|
+
email: "<matteo.cerutti@hotmail.co.uk>"
|
29
|
+
executables:
|
30
|
+
- check-sslcrt.rb
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- bin/check-sslcrt.rb
|
38
|
+
- lib/sensu-plugins-sslcrt.rb
|
39
|
+
- lib/sensu-plugins-sslcrt/version.rb
|
40
|
+
homepage: https://github.com/m4ce/sensu-plugins-sslcrt
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata:
|
44
|
+
maintainer: "@m4ce"
|
45
|
+
development_status: active
|
46
|
+
production_status: stable
|
47
|
+
release_draft: 'false'
|
48
|
+
release_prerelease: 'false'
|
49
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
50
|
+
in /etc/default/sensu
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.3
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.4.5.1
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Sensu plugins for monitoring the validity of SSL certificates
|
70
|
+
test_files: []
|