sensu-plugins-sensu 2.5.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9aa75ea723585cc7af3f900c4e22ee869a96e6200469ab098c40a5d8e7eeafa9
4
- data.tar.gz: 2dd6b40d04e074df31497dce630d0a74bef06fc848782decefc0a59a73945802
3
+ metadata.gz: 74be22e9979ca4bce08680ae287bbdc861afff3afc3783fccd98a1d0a9fbd528
4
+ data.tar.gz: bd7f1ed317662a1892ed771d7d74b3e8e6a7f8936fa0efd93942631b62b34821
5
5
  SHA512:
6
- metadata.gz: bd8a4fd76eb42ca0efbeab04a7bb73af2f9578ce8ac2af490d8ebb8eecae60b64535299389ee261ca77cf66c5532a06a8b0a126d74f92f4debc2413e30104cd3
7
- data.tar.gz: 5ce1de20012311c1eac79c174f636e769ef1e3b43504ed9fecf2e4e1f83cf5288c4732550615555f1457fc5be201c135383bb6e5d5e62825fe00f0a702cf262b
6
+ metadata.gz: bc717f238a82fcd66675ff1b5b4c441c2f065f2d90f92c89d784f84262d4dbdcebb0c74f91f7be9700b129f98fdc9c765c319d93fe13f83d02c57242c2836fbc
7
+ data.tar.gz: c2c3a8b78237a623c30484fbdb8e193abced393ae1cbf4e9055cfa0d358c9435d9faddeee4afa58a5896a55262b501f5cf7774c794d392593251409d56061c8a
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Breaking Change
10
+ - bumped dependency of `sensu-plugin` to 2.x you can read about it [here](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v200---2017-03-29)
11
+
12
+ ### Changed
13
+ - `bin/metrics-*`: Used `Sensu::Plugin::Metric::CLI::Generic` class instead of Graphite specific class for metrics. (@bergerx)
14
+
9
15
  ## [2.5.0] - 2018-03-06
10
16
  ### Changed
11
17
  - check-stale-results.rb: support https protocol via api/host declaration
@@ -116,7 +122,8 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
116
122
  ### Added
117
123
  - initial release
118
124
 
119
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.4.1...HEAD
125
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/3.0.0...HEAD
126
+ [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.5.0...3.0.0
120
127
  [2.5.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.4.1...2.5.0
121
128
  [2.4.1]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.4.0...2.4.1
122
129
  [2.4.0]: https://github.com/sensu-plugins/sensu-plugins-sensu/compare/2.3.1...2.4.0
@@ -5,11 +5,14 @@
5
5
  # Walks the /aggregates API to return metrics for
6
6
  # the aggregated output states of each check.
7
7
  #
8
+ # sensu.aggregates.some_aggregated_check.clients 1 1380251999
9
+ # sensu.aggregates.some_aggregated_check.checks 125 1380251999
8
10
  # sensu.aggregates.some_aggregated_check.ok 125 1380251999
9
11
  # sensu.aggregates.some_aggregated_check.warning 0 1380251999
10
12
  # sensu.aggregates.some_aggregated_check.critical 0 1380251999
11
13
  # sensu.aggregates.some_aggregated_check.unknown 0 1380251999
12
14
  # sensu.aggregates.some_aggregated_check.total 125 1380251999
15
+ # sensu.aggregates.some_aggregated_check.stale 0 1380251999
13
16
  # ===
14
17
  #
15
18
  # Authors
@@ -28,7 +31,7 @@ require 'json'
28
31
  require 'net/http'
29
32
  require 'net/https'
30
33
 
31
- class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
34
+ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Generic
32
35
  option :api,
33
36
  short: '-a URL',
34
37
  long: '--api URL',
@@ -60,10 +63,15 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
60
63
  proc: proc(&:to_i)
61
64
 
62
65
  option :scheme,
63
- description: 'Metric naming scheme',
66
+ description: 'Metric naming scheme for graphite format',
64
67
  long: '--scheme SCHEME',
65
68
  default: "#{Socket.gethostname}.sensu.aggregates"
66
69
 
70
+ option :measurement,
71
+ description: 'Measurement for influxdb format',
72
+ long: '--measurement MEASUREMENT',
73
+ default: 'sensu.aggregates'
74
+
67
75
  option :debug,
68
76
  long: '--debug',
69
77
  description: 'Verbose output'
@@ -76,12 +84,12 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
76
84
  end
77
85
  req = Net::HTTP::Get.new(resource)
78
86
  r = http.request(req)
79
- JSON.parse(r.body)
87
+ ::JSON.parse(r.body)
80
88
  rescue Errno::ECONNREFUSED
81
89
  warning 'Connection refused'
82
90
  rescue Timeout::Error
83
91
  warning 'Connection timed out'
84
- rescue JSON::ParserError
92
+ rescue ::JSON::ParserError
85
93
  warning 'Sensu API returned invalid JSON'
86
94
  end
87
95
 
@@ -112,10 +120,28 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
112
120
  # maintain backwards compatibility with 0.23 and newer versions.
113
121
  if count.is_a?(Hash)
114
122
  count.each do |x, y|
115
- output "#{config[:scheme]}.#{check['name']}.#{x}", y, timestamp
123
+ output metric_name: x,
124
+ value: y,
125
+ graphite_metric_path: "#{config[:scheme]}.#{check['name']}.#{x}",
126
+ statsd_metric_name: "#{config[:scheme]}.#{check['name']}.#{x}",
127
+ influxdb_measurement: config[:measurement],
128
+ tags: {
129
+ check: check['name'],
130
+ host: Socket.gethostname
131
+ },
132
+ timestamp: timestamp
116
133
  end
117
134
  else
118
- output "#{config[:scheme]}.#{check['name']}.#{result}", count, timestamp
135
+ output metric_name: result,
136
+ value: count,
137
+ graphite_metric_path: "#{config[:scheme]}.#{check['name']}.#{result}",
138
+ statsd_metric_name: "#{config[:scheme]}.#{check['name']}.#{result}",
139
+ influxdb_measurement: config[:measurement],
140
+ tags: {
141
+ check: check['name'],
142
+ host: Socket.gethostname
143
+ },
144
+ timestamp: timestamp
119
145
  end
120
146
  end
121
147
  end
@@ -16,7 +16,7 @@ require 'socket'
16
16
 
17
17
  include Sensu::Plugin::Utils
18
18
 
19
- class CheckSilenced < Sensu::Plugin::Metric::CLI::Graphite
19
+ class CheckSilenced < Sensu::Plugin::Metric::CLI::Generic
20
20
  default_host = begin
21
21
  settings['api']['host']
22
22
  rescue
@@ -59,6 +59,11 @@ class CheckSilenced < Sensu::Plugin::Metric::CLI::Graphite
59
59
  description: 'Do not delete expired stashes',
60
60
  default: false
61
61
 
62
+ option :measurement,
63
+ description: 'Measurement for influxdb format',
64
+ long: '--measurement MEASUREMENT',
65
+ default: 'sensu.stashes'
66
+
62
67
  def api
63
68
  endpoint = URI.parse("http://#{@config[:host]}:#{@config[:port]}")
64
69
  endpoint.scheme = if @config[:use_ssl?]
@@ -71,7 +76,7 @@ class CheckSilenced < Sensu::Plugin::Metric::CLI::Graphite
71
76
  end
72
77
 
73
78
  def acquire_stashes
74
- all_stashes = JSON.parse(api['/stashes'].get)
79
+ all_stashes = ::JSON.parse(api['/stashes'].get)
75
80
  filtered_stashes = []
76
81
  all_stashes.each do |stash|
77
82
  filtered_stashes << stash if stash['path'] =~ /^#{@config[:filter]}\/.*/
@@ -81,7 +86,7 @@ class CheckSilenced < Sensu::Plugin::Metric::CLI::Graphite
81
86
  warning 'Connection refused'
82
87
  rescue RestClient::RequestTimeout
83
88
  warning 'Connection timed out'
84
- rescue JSON::ParserError
89
+ rescue ::JSON::ParserError
85
90
  warning 'Sensu API returned invalid JSON'
86
91
  end
87
92
 
@@ -102,6 +107,13 @@ class CheckSilenced < Sensu::Plugin::Metric::CLI::Graphite
102
107
  end
103
108
  end
104
109
  end
105
- ok "#{config[:scheme]}.sensu.stashes.expired", @count
110
+ ok metric_name: 'expired',
111
+ value: @count,
112
+ graphite_metric_path: "#{config[:scheme]}.sensu.stashes.expired",
113
+ statsd_metric_name: "#{config[:scheme]}.sensu.stashes.expired",
114
+ influxdb_measurement: config[:measurement],
115
+ tags: {
116
+ host: Socket.gethostname
117
+ }
106
118
  end
107
119
  end
@@ -4,9 +4,11 @@
4
4
  #
5
5
  # Use the /events API to collect events and their severity.
6
6
  #
7
- # sensu.events.total 2 1234535436
8
- # sensu.events.warning 0 1234535436
9
- # sensu.events.critical 0 1234535436
7
+ # sensu.events.total 156 1518300288
8
+ # sensu.events.warning 6 1518300288
9
+ # sensu.events.critical 64 1518300288
10
+ # sensu.events.status.3 79 1518300288
11
+ # sensu.events.status.127 7 1518300288
10
12
  #
11
13
  # ===
12
14
  #
@@ -23,7 +25,7 @@ require 'sensu-plugin/metric/cli'
23
25
  require 'rest-client'
24
26
  require 'json'
25
27
 
26
- class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
28
+ class EventMetrics < Sensu::Plugin::Metric::CLI::Generic
27
29
  option :api,
28
30
  short: '-a URL',
29
31
  long: '--api URL',
@@ -52,6 +54,11 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
52
54
  long: '--scheme SCHEME',
53
55
  default: "#{Socket.gethostname}.sensu.events"
54
56
 
57
+ option :measurement,
58
+ description: 'Measurement for influxdb format',
59
+ long: '--measurement MEASUREMENT',
60
+ default: 'sensu.events'
61
+
55
62
  option :debug,
56
63
  long: '--debug',
57
64
  description: 'Verbose output'
@@ -60,7 +67,7 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
60
67
  request = RestClient::Resource.new(config[:api] + resource, timeout: config[:timeout],
61
68
  user: config[:user],
62
69
  password: config[:password])
63
- JSON.parse(request.get, symbolize_names: true)
70
+ ::JSON.parse(request.get, symbolize_names: true)
64
71
  rescue RestClient::ResourceNotFound
65
72
  warning "Resource not found: #{resource}"
66
73
  rescue Errno::ECONNREFUSED
@@ -71,7 +78,7 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
71
78
  warning 'Connection timed out'
72
79
  rescue RestClient::Unauthorized
73
80
  warning 'Missing or incorrect Sensu API credentials'
74
- rescue JSON::ParserError
81
+ rescue ::JSON::ParserError
75
82
  warning 'Sensu API returned invalid JSON'
76
83
  end
77
84
 
@@ -100,14 +107,28 @@ class AggregateMetrics < Sensu::Plugin::Metric::CLI::Graphite
100
107
  status_count[event[:check][:status]] += 1
101
108
  end
102
109
 
103
- output "#{config[:scheme]}.total", total_count, timestamp
110
+ output metric_name: 'total_events_count',
111
+ value: total_count,
112
+ graphite_metric_path: "#{config[:scheme]}.total",
113
+ statsd_metric_name: "#{config[:scheme]}.total",
114
+ influxdb_measurement: config[:measurement],
115
+ tags: {
116
+ host: Socket.gethostname
117
+ },
118
+ timestamp: timestamp
119
+
104
120
  status_count.each do |status, count|
105
- name = status_names[status]
106
- if name
107
- output "#{config[:scheme]}.#{name}", count, timestamp
108
- else
109
- output "#{config[:scheme]}.status.#{status}", count, timestamp
110
- end
121
+ name = status_names[status] || "status.#{status}"
122
+ output metric_name: 'event_count',
123
+ value: count,
124
+ graphite_metric_path: "#{config[:scheme]}.#{name}",
125
+ statsd_metric_name: "#{config[:scheme]}.#{name}",
126
+ influxdb_measurement: config[:measurement],
127
+ tags: {
128
+ host: Socket.gethostname,
129
+ event_status: name
130
+ },
131
+ timestamp: timestamp
111
132
  end
112
133
 
113
134
  ok
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsSensu
2
2
  # This defines the version of the gem
3
3
  module Version
4
- MAJOR = 2
5
- MINOR = 5
4
+ MAJOR = 3
5
+ MINOR = 0
6
6
  PATCH = 0
7
7
 
8
8
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
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.5.0
4
+ version: 3.0.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: 2018-03-07 00:00:00.000000000 Z
11
+ date: 2018-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '2.4'
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
- version: '1.2'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rest-client
29
29
  requirement: !ruby/object:Gem::Requirement