sensu-plugins-dns 1.0.0 → 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 +5 -13
- data/CHANGELOG.md +9 -1
- data/bin/check-dns.rb +61 -11
- data/bin/metrics-dns.rb +17 -2
- data/lib/sensu-plugins-dns/version.rb +1 -1
- metadata +32 -31
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YWM3N2UxNDFhNmIxNzYwOWYxMDcxZDEyMDYxNDU5MGFjYjU1NWFlOA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 664c93fc6c8a257e432477013bb4c30ca3e65dcc
|
4
|
+
data.tar.gz: 62dd7664dfedde6cabc6aa218347f35bf93997a5
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NmQ2MTU0YmNhNzhmNDliMDAwMzM2ZGJiYWNmZDk0NjcxYjgwNTNmNWZlNWQ3
|
11
|
-
YjgzYTI5MTgzY2MxYWFiNDc4Y2JkNmIzNGI0OTU5MzMzMTE0MjY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZjQ2NTdmMDQ3NGJiOTNiOTlhZjRiMDkxMmNjMjhhNGM0NmU2NjMwNWMxMDNk
|
14
|
-
NGZlNDg5YzI5YWIxMGFhZmE4YWFjNmE1OWNkYWJjODgxMzU5NjM1MDRhMjVh
|
15
|
-
MzA3Y2I4MzE2OTIzM2Q3MWU2YTMyMjlkZWNjZTY0Yjg2NTJjZGM=
|
6
|
+
metadata.gz: ffa2592d77b836dd07b2a8ebdbd9cea08f6b4f84700a64a4867908303b083a571df07c8d2766f1d15122ccfcaa73be8e8691e46a379ad8b68f43e3e35387501f
|
7
|
+
data.tar.gz: f9834ffedaf0c1fee9d0eaa287896eb547625d4c38ee2532c4d2a9d4fc2e9e9fd39379fb9bb957c27f12f7aaa2e59061513a53404b13b13c8a17eb9f7334d125
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
|
+
## [1.1.0]
|
8
|
+
### Added
|
9
|
+
- Added option for DNS server port (@apriljo)
|
10
|
+
- Added option for use TCP instead of UDP (@liqw33d)
|
11
|
+
- Added `--class` argument to both metric and check scripts (@nickjacques)
|
12
|
+
- Added DNS lookup timeout option (@winks)
|
13
|
+
- check-dns.rb will now ignore case and expand shorthand when comparing ipv4 and pev6 records by turning them into ipaddr objects for comparison (@majormoses)
|
7
14
|
|
8
15
|
## [1.0.0] - 2016-05-11
|
9
16
|
### Added
|
@@ -42,7 +49,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
42
49
|
### Changed
|
43
50
|
- removed cruft from /lib
|
44
51
|
|
45
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-dns/compare/1.
|
52
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-dns/compare/1.1.0...HEAD
|
53
|
+
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-dns/compare/1.0.0...1/1.0
|
46
54
|
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-dns/compare/0.0.6...1.0.0
|
47
55
|
[0.0.6]: https://github.com/sensu-plugins/sensu-plugins-dns/compare/0.0.5...0.0.6
|
48
56
|
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-dns/compare/0.0.4...0.0.5
|
data/bin/check-dns.rb
CHANGED
@@ -31,6 +31,7 @@
|
|
31
31
|
|
32
32
|
require 'sensu-plugin/check/cli'
|
33
33
|
require 'dnsruby'
|
34
|
+
require 'ipaddr'
|
34
35
|
#
|
35
36
|
# DNS
|
36
37
|
#
|
@@ -46,11 +47,23 @@ class DNS < Sensu::Plugin::Check::CLI
|
|
46
47
|
long: '--type RECORD',
|
47
48
|
default: 'A'
|
48
49
|
|
50
|
+
option :class,
|
51
|
+
description: 'Record class to resolve (IN, CH, HS, ANY)',
|
52
|
+
short: '-c CLASS',
|
53
|
+
long: '--class CLASS',
|
54
|
+
default: 'IN'
|
55
|
+
|
49
56
|
option :server,
|
50
57
|
description: 'Server to use for resolution',
|
51
58
|
short: '-s SERVER',
|
52
59
|
long: '--server SERVER'
|
53
60
|
|
61
|
+
option :port,
|
62
|
+
description: 'Port to use for resolution',
|
63
|
+
short: '-p PORT',
|
64
|
+
long: '--port PORT',
|
65
|
+
proc: proc(&:to_i)
|
66
|
+
|
54
67
|
option :result,
|
55
68
|
description: 'A positive result entry',
|
56
69
|
short: '-r RESULT',
|
@@ -78,10 +91,28 @@ class DNS < Sensu::Plugin::Check::CLI
|
|
78
91
|
long: '--validate',
|
79
92
|
boolean: true
|
80
93
|
|
94
|
+
option :use_tcp,
|
95
|
+
description: 'Use tcp for resolution',
|
96
|
+
short: '-T',
|
97
|
+
long: '--use-tcp',
|
98
|
+
boolean: true
|
99
|
+
|
100
|
+
option :timeout,
|
101
|
+
description: 'Set timeout for query',
|
102
|
+
short: '-T TIMEOUT',
|
103
|
+
long: '--timeout TIMEOUT',
|
104
|
+
proc: proc(&:to_i),
|
105
|
+
default: 5
|
106
|
+
|
81
107
|
def resolve_domain
|
82
|
-
|
108
|
+
dnsruby_config = {}
|
109
|
+
dnsruby_config[:nameserver] = [config[:server]] unless config[:server].nil?
|
110
|
+
dnsruby_config[:port] = config[:port] unless config[:port].nil?
|
111
|
+
dnsruby_config[:use_tcp] = config[:use_tcp] unless config[:use_tcp].nil?
|
112
|
+
resolv = Dnsruby::Resolver.new(dnsruby_config)
|
83
113
|
resolv.do_validation = true if config[:validate]
|
84
|
-
entries = resolv.query(config[:domain], config[:type])
|
114
|
+
entries = resolv.query(config[:domain], config[:type], config[:class])
|
115
|
+
resolv.query_timeout = config[:timeout]
|
85
116
|
puts "Entries: #{entries}" if config[:debug]
|
86
117
|
|
87
118
|
entries
|
@@ -102,6 +133,16 @@ class DNS < Sensu::Plugin::Check::CLI
|
|
102
133
|
critical "Resolved #{config[:domain]} #{config[:type]} did not match #{regex}"
|
103
134
|
end
|
104
135
|
|
136
|
+
def check_ips(entries)
|
137
|
+
ips = entries.answer.rrsets(config[:type]).flat_map(&:rrs).map(&:address).map(&:to_s)
|
138
|
+
result = IPAddr.new config[:result]
|
139
|
+
if ips.any? { |ip| (IPAddr.new ip) == result }
|
140
|
+
ok "Resolved #{entries.security_level} #{config[:domain]} #{config[:type]} included #{config[:result]}"
|
141
|
+
else
|
142
|
+
critical "Resolved #{config[:domain]} #{config[:type]} did not include #{config[:result]}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
105
146
|
def run
|
106
147
|
unknown 'No domain specified' if config[:domain].nil?
|
107
148
|
|
@@ -112,7 +153,7 @@ class DNS < Sensu::Plugin::Check::CLI
|
|
112
153
|
critical(output)
|
113
154
|
return
|
114
155
|
rescue => e
|
115
|
-
output = "
|
156
|
+
output = "Could not resolve #{config[:domain]}: #{e}"
|
116
157
|
config[:warn_only] ? warning(output) : critical(output)
|
117
158
|
return
|
118
159
|
end
|
@@ -121,16 +162,25 @@ class DNS < Sensu::Plugin::Check::CLI
|
|
121
162
|
output = "Could not resolve #{config[:domain]} #{config[:type]} record"
|
122
163
|
config[:warn_only] ? warning(output) : critical(output)
|
123
164
|
elsif config[:result]
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
ok "Resolved #{entries.security_level} #{config[:domain]} #{config[:type]} included #{config[:result]}"
|
165
|
+
# special logic for checking ipaddresses with result
|
166
|
+
# mostly for ipv6 but decided to use the same logic for
|
167
|
+
# consistency reasons
|
168
|
+
if config[:type] == 'A' || config[:type] == 'AAAA'
|
169
|
+
check_ips(entries)
|
170
|
+
# non ip type
|
131
171
|
else
|
132
|
-
|
172
|
+
b = if entries.answer.count > 1
|
173
|
+
entries.answer.rrsets(config[:type].to_s).to_s
|
174
|
+
else
|
175
|
+
entries.answer.first.to_s
|
176
|
+
end
|
177
|
+
if b.include?(config[:result])
|
178
|
+
ok "Resolved #{entries.security_level} #{config[:domain]} #{config[:type]} included #{config[:result]}"
|
179
|
+
else
|
180
|
+
critical "Resolved #{config[:domain]} #{config[:type]} did not include #{config[:result]}"
|
181
|
+
end
|
133
182
|
end
|
183
|
+
|
134
184
|
elsif config[:regex]
|
135
185
|
check_against_regex(entries, Regexp.new(config[:regex]))
|
136
186
|
|
data/bin/metrics-dns.rb
CHANGED
@@ -39,11 +39,23 @@ class DNSGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
39
39
|
long: '--type RECORD',
|
40
40
|
default: 'A'
|
41
41
|
|
42
|
+
option :class,
|
43
|
+
description: 'Record class to resolve (IN, CH, HS, ANY)',
|
44
|
+
short: '-c CLASS',
|
45
|
+
long: '--class CLASS',
|
46
|
+
default: 'IN'
|
47
|
+
|
42
48
|
option :server,
|
43
49
|
description: 'Server to use for resolution',
|
44
50
|
short: '-s SERVER',
|
45
51
|
long: '--server SERVER'
|
46
52
|
|
53
|
+
option :port,
|
54
|
+
description: 'Port to use for resolution',
|
55
|
+
short: '-p PORT',
|
56
|
+
long: '--port PORT',
|
57
|
+
proc: proc(&:to_i)
|
58
|
+
|
47
59
|
option :scheme,
|
48
60
|
description: 'Metric naming scheme, text to prepend to metric',
|
49
61
|
short: '-S SCHEME',
|
@@ -54,8 +66,11 @@ class DNSGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
54
66
|
unknown 'No domain specified' if config[:domain].nil?
|
55
67
|
|
56
68
|
begin
|
57
|
-
|
58
|
-
|
69
|
+
dnsruby_config = {}
|
70
|
+
dnsruby_config[:nameserver] = [config[:server]] unless config[:server].nil?
|
71
|
+
dnsruby_config[:port] = config[:port] unless config[:port].nil?
|
72
|
+
resolver = Dnsruby::Resolver.new(dnsruby_config)
|
73
|
+
result = Benchmark.realtime { resolver.query(config[:domain], config[:type], config[:class]) }
|
59
74
|
|
60
75
|
key_name = config[:domain].to_s.tr('.', '_')
|
61
76
|
|
metadata
CHANGED
@@ -1,178 +1,179 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-dns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dnsruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.59'
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 1.59.2
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - ~>
|
41
|
+
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '1.59'
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 1.59.2
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - ~>
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '1.7'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - ~>
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1.7'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: codeclimate-test-reporter
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - ~>
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0.4'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - ~>
|
72
|
+
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0.4'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: github-markup
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - ~>
|
79
|
+
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '1.3'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- - ~>
|
86
|
+
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '1.3'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: pry
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - ~>
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0.10'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - ~>
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0.10'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rake
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - ~>
|
107
|
+
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '10.0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - ~>
|
114
|
+
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '10.0'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: redcarpet
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- - ~>
|
121
|
+
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '3.2'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - ~>
|
128
|
+
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '3.2'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rspec
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- - ~>
|
135
|
+
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '3.1'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
|
-
- - ~>
|
142
|
+
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '3.1'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: rubocop
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- - ~>
|
149
|
+
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: 0.40.0
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
|
-
- - ~>
|
156
|
+
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: 0.40.0
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: yard
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- - ~>
|
163
|
+
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '0.8'
|
166
166
|
type: :development
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
|
-
- - ~>
|
170
|
+
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0.8'
|
173
|
-
description:
|
174
|
-
|
175
|
-
|
173
|
+
description: |-
|
174
|
+
This plugin provides native DNS instrumentation
|
175
|
+
for monitoring, including: record resolution
|
176
|
+
email: "<sensu-users@googlegroups.com>"
|
176
177
|
executables:
|
177
178
|
- check-dns.rb
|
178
179
|
- metrics-dns.rb
|
@@ -202,12 +203,12 @@ require_paths:
|
|
202
203
|
- lib
|
203
204
|
required_ruby_version: !ruby/object:Gem::Requirement
|
204
205
|
requirements:
|
205
|
-
- -
|
206
|
+
- - ">="
|
206
207
|
- !ruby/object:Gem::Version
|
207
208
|
version: 2.0.0
|
208
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
210
|
requirements:
|
210
|
-
- -
|
211
|
+
- - ">="
|
211
212
|
- !ruby/object:Gem::Version
|
212
213
|
version: '0'
|
213
214
|
requirements: []
|