sensu-plugins-edgelab 1.0.1 → 1.1.0
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 +4 -4
- data/bin/check-apt-expired-keys.rb +93 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82239604e6dd622edcfb47f6f612dcb825700e41
|
4
|
+
data.tar.gz: 65f687f3ee8a645cb07d767e34f4446f94b02b0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f693e3d1a564698ee290cbec139fdb74e0ca46ecf1994c1fbc6e9720832eb8b9aa73e02bcd8d0c11d0cb24dda03cc9ad7cad34cae18877655e976c075bbecd
|
7
|
+
data.tar.gz: 3c486951f0a28fdc5dcf59abe8f1dd777a21d71b190c49f8098aa32510351a37d26cb2ce632d640ed2e2c50d37aaeed8355f4da8b0a37026cec8a013fcfb164b
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-apt-expired-keys
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin reports expired GPG key used for APT signing.
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Debian
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
# example commands
|
19
|
+
#
|
20
|
+
# NOTES:
|
21
|
+
# Does it behave differently on specific platforms, specific use cases, etc
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright 2015 EdgeLaboratories.
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'rubygems' if RUBY_VERSION < '1.9.0'
|
30
|
+
require 'sensu-plugin/check/cli'
|
31
|
+
|
32
|
+
class APTKey < Sensu::Plugin::Check::CLI
|
33
|
+
def run
|
34
|
+
# Must be executed as root in order to access APT keys list
|
35
|
+
if Process.uid != 0
|
36
|
+
return unknown 'Must be executed as root user'
|
37
|
+
end
|
38
|
+
|
39
|
+
expired = expired_keys
|
40
|
+
|
41
|
+
if expired.count > 0
|
42
|
+
if expired.count == 1
|
43
|
+
verb = 'is'
|
44
|
+
noun = 'key'
|
45
|
+
else
|
46
|
+
verb = 'are'
|
47
|
+
noun = 'keys'
|
48
|
+
end
|
49
|
+
warning "There #{verb} #{expired.count} expired APT #{noun}: #{expired.join('; ')}"
|
50
|
+
else
|
51
|
+
ok 'No APT expired keys'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def expired_keys
|
56
|
+
expired = []
|
57
|
+
IO.popen('apt-key list') do |cmd|
|
58
|
+
current_key_id = nil
|
59
|
+
current_key_name = nil
|
60
|
+
|
61
|
+
# We try to parse output like this:
|
62
|
+
# pub 2048R/B999A372 2010-08-12 [expired: 2015-08-13]
|
63
|
+
# uid Riptano Package Repository <paul@riptano.com>
|
64
|
+
|
65
|
+
cmd.each do |line|
|
66
|
+
# Parse and extract the expired public key ID
|
67
|
+
match = /^pub[ ]+[^\/]+\/(.*) .* \[expired: /.match(line)
|
68
|
+
unless match.nil?
|
69
|
+
current_key_id = match.captures[0]
|
70
|
+
end
|
71
|
+
|
72
|
+
# Try to get the more user-friendly name. Sometimes, it doesn't
|
73
|
+
# contain enough information to be useful, but it still
|
74
|
+
# slightly better than the key ID.
|
75
|
+
match = /^uid[ ]+(.*)$/.match(line)
|
76
|
+
unless match.nil?
|
77
|
+
current_key_name = match.captures[0]
|
78
|
+
end
|
79
|
+
|
80
|
+
# If we reach an empty line and we parsed expired key, save
|
81
|
+
# them and reset everything for the next keys after.
|
82
|
+
if line =~ /^$/
|
83
|
+
if current_key_id
|
84
|
+
expired.push "#{current_key_name || 'unknown key uid'} (#{current_key_id})"
|
85
|
+
end
|
86
|
+
current_key_id = nil
|
87
|
+
current_key_name = nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
expired
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-edgelab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgelab
|
@@ -83,10 +83,12 @@ dependencies:
|
|
83
83
|
description: Sensu plugins developed by Edgelab
|
84
84
|
email:
|
85
85
|
executables:
|
86
|
+
- check-apt-expired-keys.rb
|
86
87
|
- check-nomad-jobs.rb
|
87
88
|
extensions: []
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
91
|
+
- bin/check-apt-expired-keys.rb
|
90
92
|
- bin/check-nomad-jobs.rb
|
91
93
|
homepage:
|
92
94
|
licenses: []
|