sensu-plugins-dns 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a4f70c957d58fd9f463eac67941440890085d1d
4
- data.tar.gz: 90e0d993d521ea0d095071d576c3c99396e61f2e
3
+ metadata.gz: 430dc3ea38b7b3450e2bcebebfc4e5b3c557d465
4
+ data.tar.gz: 96ce94335d5d153dd4a2a193a8d94b34bb1bbdbd
5
5
  SHA512:
6
- metadata.gz: 3e17fe0db5ceb9b57ae1371762061b1c1f225f7940bafb82e1534257707a80ad2221d9e166297c6bd600e942e4f325d7008376f5f65c8aab6501006f11f93b0d
7
- data.tar.gz: 081ad7275643bfbefa648703f475360f6daf4740e878dd599116c08e6a218272cb6ebbc3b43096802f2b52fb9b859ad4eb8994491daae1d38d2348f5135f7d2e
6
+ metadata.gz: d367eebc55c005193950dfdd129f7243685a9fd7ba18ec4bec7bff4b69189141f8cfdf808acf16460ba3572b074cb9eacf0425ec3a41e027a96a6c7c796cbbb3
7
+ data.tar.gz: 5ea3a911ae92b0a05acaed16568e985baba94da30e9cbcc9e52a328d2b8dc0873eb4660275d07cefc3e834fc7205fe9f708e9949d7542ab2893f7abb8e3198f0
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -4,7 +4,11 @@ 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][unreleased]
7
- - nothing
7
+ * nothing
8
+
9
+ ## [0.0.6] - 2015-09-28
10
+ ### Changed
11
+ - Migrated from ruby library resolv to dnsruby to support more dns related checks
8
12
 
9
13
  ## [0.0.5] - 2015-08-05
10
14
  ### Removed
data/bin/check-dns.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # check-dns
4
4
  #
5
5
  # DESCRIPTION:
6
- # This plugin checks DNS resolution using ruby `resolv`.
6
+ # This plugin checks DNS resolution using dnsruby .
7
7
  # Note: if testing reverse DNS with -t PTR option,
8
8
  # results will not end with trailing '.' (dot)
9
9
  #
@@ -15,6 +15,7 @@
15
15
  #
16
16
  # DEPENDENCIES:
17
17
  # gem: sensu-plugin
18
+ # gem: dnsruby
18
19
  #
19
20
  # USAGE:
20
21
  # example commands
@@ -29,8 +30,7 @@
29
30
  #
30
31
 
31
32
  require 'sensu-plugin/check/cli'
32
- require 'resolv'
33
-
33
+ require 'dnsruby'
34
34
  #
35
35
  # DNS
36
36
  #
@@ -68,12 +68,10 @@ class DNS < Sensu::Plugin::Check::CLI
68
68
  boolean: true
69
69
 
70
70
  def resolve_domain
71
- resolv = config[:server].nil? ? Resolv::DNS.new : Resolv::DNS.new(nameserver: [config[:server]])
72
- if config[:type] == 'PTR'
73
- entries = resolv.getnames(config[:domain]).map(&:to_s)
74
- else
75
- entries = resolv.getaddresses(config[:domain]).map(&:to_s)
76
- end
71
+ resolv = config[:server].nil? ? Dnsruby::Resolver.new : Dnsruby::Resolver.new(nameserver: [config[:server]])
72
+
73
+ entries = resolv.query(config[:domain], config[:type])
74
+
77
75
  puts "Entries: #{entries}" if config[:debug]
78
76
 
79
77
  entries
@@ -82,18 +80,34 @@ class DNS < Sensu::Plugin::Check::CLI
82
80
  def run
83
81
  unknown 'No domain specified' if config[:domain].nil?
84
82
 
85
- entries = resolve_domain
86
- if entries.length.zero?
87
- output = "Could not resolve #{config[:domain]}"
83
+ begin
84
+ entries = resolve_domain
85
+ rescue Dnsruby::NXDomain
86
+ output = "Could not resolve #{config[:domain]} #{config[:type]} record"
87
+ critical(output)
88
+ return
89
+ rescue => e
90
+ output = "Couldn not resolve #{config[:domain]}: #{e}"
91
+ config[:warn_only] ? warning(output) : critical(output)
92
+ return
93
+ end
94
+ puts entries.answer if config[:debug]
95
+ if entries.answer.length.zero?
96
+ output = "Could not resolve #{config[:domain]} #{config[:type]} record"
88
97
  config[:warn_only] ? warning(output) : critical(output)
89
98
  elsif config[:result]
90
- if entries.include?(config[:result])
91
- ok "Resolved #{config[:domain]} including #{config[:result]}"
99
+ if entries.answer.count > 1
100
+ b = entries.answer.rrsets("#{config[:type]}").to_s
101
+ else
102
+ b = entries.answer.first.to_s
103
+ end
104
+ if b.include?(config[:result])
105
+ ok "Resolved #{config[:domain]} #{config[:type]} included #{config[:result]}"
92
106
  else
93
- critical "Resolved #{config[:domain]} did not include #{config[:result]}"
107
+ critical "Resolved #{config[:domain]} #{config[:type]} did not include #{config[:result]}"
94
108
  end
95
109
  else
96
- ok "Resolved #{config[:domain]} #{config[:type]} records"
110
+ ok "Resolved #{config[:domain]} #{config[:type]}"
97
111
  end
98
112
  end
99
113
  end
@@ -2,7 +2,7 @@ module SensuPluginsDNS
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 5
5
+ PATCH = 6
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu Plugins and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-08-05 00:00:00.000000000 Z
33
+ date: 2015-10-01 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -46,6 +46,20 @@ dependencies:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
48
  version: 1.2.0
49
+ - !ruby/object:Gem::Dependency
50
+ name: dnsruby
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 1.58.0
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.58.0
49
63
  - !ruby/object:Gem::Dependency
50
64
  name: bundler
51
65
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file