sensu-plugins-sensu 2.1.0 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db61d659c304cbb69bab103dc96810acc18b303e
4
- data.tar.gz: 65d88dbf81a056122cf421e2eef2a354e0cb7971
3
+ metadata.gz: a41669c0e26a07efba58456daa34b954a6b5fd2a
4
+ data.tar.gz: dee205425b435940dc7cc0a7259c5809db7ecbbb
5
5
  SHA512:
6
- metadata.gz: 87ba1a72154774b05550e1969d7e3f6a7129921371cff565bb29067f74b3502d499628886929efb20450b0633dda14d2a37083dd391ce9121c1ff6a573863308
7
- data.tar.gz: 06d0d10142e70be953d73eef0b233eda4e4b4ef25d2b1632d4c7a2fee9b11dedd26a6e5bcadcf1e89008e15033abd7db4c930768ddd88e5b0ed00e92cb452c12
6
+ metadata.gz: 85edf389d8f682d779c59df352607039d787dc3890b075d4e996f91458f4ad6d79af45b69b40690efbe0fa13a4543ea59e3f5d7c59f2c495dec32961d3d421ec
7
+ data.tar.gz: 57c3945315d07a507a57a774656884f483ab2e683a87ac230c241b615b7a14662dda3bdec20ceb63f66820c052b0f1eba31fb301226da489d4de33c3c912a405
data/CHANGELOG.md CHANGED
@@ -1,10 +1,19 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
- This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
4
+ This CHANGELOG follows the format listed at [Our CHANGELOG Guidelines ](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md).
5
+ Which is based on [Keep A Changelog](http://keepachangelog.com/)
5
6
 
6
7
  ## [Unreleased]
7
8
 
9
+ ## [2.1.1] - 2017-00-09
10
+ ### Fixed
11
+ - metrics-aggregates.rb: Refactored to support new named aggregates introduced in Sensu 0.24 (@oba11)
12
+
13
+ ### Changed
14
+ - check-stale-results.rb: made invocation of ok more idiomatic (@rbanffy)
15
+ - updated the location for our changelog guidelines (@majormoses)
16
+
8
17
  ## [2.1.0] - 2017-08-29
9
18
  ### Added
10
19
  - check-stale-results.rb: new script to check for stale results in sensu (@m4ce)
@@ -12,9 +21,9 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
12
21
 
13
22
  ## [2.0.0] - 2017-08-20
14
23
  ### Breaking Changes
15
- - check-aggregates.rb: Changed the default behaviour to alert with the severity of the aggregated checks.
24
+ - check-aggregates.rb: Changed the default behavior to alert with the severity of the aggregated checks. (@Moozaliny)
16
25
 
17
- ### Added
26
+ ### AddedMoozaliny
18
27
  - check-aggregates.rb: Added new flag to ignore severities. If --ignore-severity is supplied all non-ok will count for critical, critical_count, warning and warning_count option.
19
28
 
20
29
  ### Fixed
@@ -70,6 +79,7 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
70
79
  - initial release
71
80
 
72
81
  [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.1.0...HEAD
82
+ [2.1.1]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.1.0...2.1.1
73
83
  [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.0.0...2.1.0
74
84
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/1.1.1...2.0.0
75
85
  [1.1.1]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/1.1.0...1.1.1
@@ -104,6 +104,6 @@ class CheckStaleResults < Sensu::Plugin::Check::CLI
104
104
  warning(msg)
105
105
  end
106
106
 
107
- ok("No stale check results found (>= #{config[:warn]})")
107
+ ok "No stale check results found (>= #{config[:warn]})"
108
108
  end
109
109
  end
@@ -24,8 +24,9 @@
24
24
  # LICENSE for details.
25
25
 
26
26
  require 'sensu-plugin/metric/cli'
27
- require 'rest-client'
28
27
  require 'json'
28
+ require 'net/http'
29
+ require 'net/https'
29
30
 
30
31
  class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
31
32
  option :api,
@@ -68,20 +69,18 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
68
69
  description: 'Verbose output'
69
70
 
70
71
  def api_request(resource)
71
- request = RestClient::Resource.new(config[:api] + resource, timeout: config[:timeout],
72
- user: config[:user],
73
- password: config[:password])
74
- JSON.parse(request.get, symbolize_names: true)
75
- rescue RestClient::ResourceNotFound
76
- warning "Resource not found: #{resource}"
72
+ uri = URI.parse(config[:api])
73
+ http = Net::HTTP.new(uri.host, uri.port)
74
+ if uri.scheme == 'https'
75
+ http.use_ssl = true
76
+ end
77
+ req = Net::HTTP::Get.new(resource)
78
+ r = http.request(req)
79
+ JSON.parse(r.body)
77
80
  rescue Errno::ECONNREFUSED
78
81
  warning 'Connection refused'
79
- rescue RestClient::RequestFailed
80
- warning 'Request failed'
81
- rescue RestClient::RequestTimeout
82
+ rescue Timeout::Error
82
83
  warning 'Connection timed out'
83
- rescue RestClient::Unauthorized
84
- warning 'Missing or incorrect Sensu API credentials'
85
84
  rescue JSON::ParserError
86
85
  warning 'Sensu API returned invalid JSON'
87
86
  end
@@ -95,27 +94,29 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
95
94
 
96
95
  def get_aggregate(check)
97
96
  uri = "/aggregates/#{check}"
98
- issued = api_request(uri + "?age=#{config[:age]}")
99
- unless issued.empty?
100
- issued_sorted = issued.sort
101
- time = issued_sorted.pop
102
- unless time.nil?
103
- uri += "/#{time}"
104
- [time, api_request(uri)]
105
- else
106
- warning "No aggregates older than #{config[:age]} seconds"
107
- end
108
- else
97
+ issued = api_request(uri + "?max_age=#{config[:age]}")
98
+ if issued.empty?
109
99
  warning "No aggregates for #{check}"
100
+ else
101
+ issued
110
102
  end
111
103
  end
112
104
 
113
105
  def run
106
+ timestamp = Time.now.to_i
114
107
  acquire_checks.each do |check|
115
- timestamp, aggregate = get_aggregate(check[:check])
116
- puts "#{check[:check]} aggregates: #{aggregate}" if config[:debug]
108
+ aggregate = get_aggregate(check['name'])
109
+ puts "#{check['name']} aggregates: #{aggregate}" if config[:debug]
117
110
  aggregate.each do |result, count|
118
- output "#{config[:scheme]}.#{check[:check]}.#{result}", count, timestamp
111
+ # in 0.24 they changed the api results for aggregates this helps
112
+ # maintain backwards compatibility with 0.23 and newer versions.
113
+ if count.is_a?(Hash)
114
+ count.each do |x, y|
115
+ output "#{config[:scheme]}.#{check['name']}.#{x}", y, timestamp
116
+ end
117
+ else
118
+ output "#{config[:scheme]}.#{check['name']}.#{result}", count, timestamp
119
+ end
119
120
  end
120
121
  end
121
122
  ok
@@ -3,7 +3,7 @@ module SensuPluginsSensu
3
3
  module Version
4
4
  MAJOR = 2
5
5
  MINOR = 1
6
- PATCH = 0
6
+ PATCH = 1
7
7
 
8
8
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-sensu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
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: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2017-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  version: '0'
246
246
  requirements: []
247
247
  rubyforge_project:
248
- rubygems_version: 2.6.11
248
+ rubygems_version: 2.6.13
249
249
  signing_key:
250
250
  specification_version: 4
251
251
  summary: Sensu plugins for sensu