sensu-plugins-edgelab 1.14.0 → 1.14.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
- SHA1:
3
- metadata.gz: e25e0c5ae2a5c5b6d69cc607b9d87e115aa3d71f
4
- data.tar.gz: 8c680d4beab1d89e0d33c6b58d018c3eac7d8af2
2
+ SHA256:
3
+ metadata.gz: cac9db6c64318afdd3af552c867128d4e220b304afa9ce52e315f17c5f091b1e
4
+ data.tar.gz: d84928b4ccde348c7da971fe0638c18859b6f4d9ee8aeaa75579f47daf7d212e
5
5
  SHA512:
6
- metadata.gz: fe7ce51186caf435880c94b7b97662dbfe2b9cea1ff87c85573d290bd7bfa7bb02d0d1cd2a3c4df01a7ce9d5f5371dfe1c6f22cd0d893918db8fc5b874d08106
7
- data.tar.gz: 7e30e3e28ac3080e213ad0daff4f434fde1334fc496b6756551fbb2e843bf1280df8311b2a3ea48825bb62bb7ce22c92bd1cd1e1ce008f7a9245c558b547afe3
6
+ metadata.gz: 8eb1971adf0e30ac0aa670d6353ffe3b03459d729271070737147ccae8cabdb50719547235acb50f8deeabbfebfbea2ef7d2942d28a4376b6acc26294e379dcd
7
+ data.tar.gz: 2b7ded62142c3443fef65d8f0b5b04a6ff003a2626c4e031c4961842bd6bf3ff47d00f924de3af9c1e112f691a58e9700eeb542b897187ba5ffeafca52079670
@@ -1,5 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  #
4
5
  # check-apt-expired-keys
5
6
  #
@@ -39,7 +40,7 @@ class APTKey < Sensu::Plugin::Check::CLI
39
40
 
40
41
  expired = expired_keys
41
42
 
42
- if expired.count > 0
43
+ if expired.count.positive?
43
44
  if expired.count == 1
44
45
  verb = 'is'
45
46
  noun = 'key'
@@ -108,9 +108,9 @@ class CheckCassandraNode < Sensu::Plugin::Check::CLI
108
108
  ok_nodes << "#{address} is normal (#{node[:status]}#{node[:state]})"
109
109
  end
110
110
 
111
- if error_nodes.count > 0
111
+ if error_nodes.count.positive?
112
112
  criticial error_nodes.join(', ')
113
- elsif warning_nodes.count > 0
113
+ elsif warning_nodes.positive?
114
114
  warning warning_nodes.join(', ')
115
115
  else
116
116
  ok ok_nodes.join(', ')
@@ -123,7 +123,7 @@ class CheckLogstashPipeline < Sensu::Plugin::Check::CLI
123
123
  tries += 1
124
124
  response = RestClient.post(url, body)
125
125
  found = JSON.parse(response)['responses'][0]['hits']['total']
126
- break if found > 0
126
+ break if found.positive?
127
127
  end
128
128
 
129
129
  duration = Time.now.to_i - sent_at.to_i
@@ -74,7 +74,7 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
74
74
  reasons << "Constraint #{constraint} filtered #{count} nodes"
75
75
  end
76
76
 
77
- if metrics['NodesExhausted'] > 0
77
+ if (metrics['NodesExhausted']).positive?
78
78
  reasons << "Resources exhausted on #{metrics['NodesExhausted']} nodes"
79
79
  end
80
80
 
@@ -110,13 +110,12 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
110
110
  end
111
111
 
112
112
  # System jobs don't have blocked evaluation, only one evaluation per job.
113
- if (job['Type'] == 'system' || blocked) && !last_failed.nil?
114
- failure_reasons = placement_failures_reasons last_failed
113
+ return unless (job['Type'] == 'system' || blocked) && !last_failed.nil?
115
114
 
116
- if failure_reasons.any?
117
- failed << "#{job['ID']}: Placemement failure [" + failure_reasons.join(' / ') + ']'
118
- end
119
- end
115
+ failure_reasons = placement_failures_reasons last_failed
116
+ return unless failure_reasons.any?
117
+
118
+ failed << "#{job['ID']}: Placemement failure [" + failure_reasons.join(' / ') + ']'
120
119
  end
121
120
 
122
121
  # Check for service/system job if he is running.
@@ -180,7 +179,7 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
180
179
  now = Time.new.to_i
181
180
 
182
181
  allocations.each do |alloc|
183
- if %w(running pending).include? alloc['ClientStatus']
182
+ if %w[running pending].include? alloc['ClientStatus']
184
183
  next if alloc['TaskStates'].nil?
185
184
 
186
185
  alloc['TaskStates'].each do |_, state|
@@ -51,10 +51,10 @@ class HipChatNotif < Sensu::Handler
51
51
  room = @event['client']['hipchat_room'] || @event['check']['hipchat_room'] || settings[json_config]['room']
52
52
 
53
53
  mentions = @event['check']['hipchat_mentions'] || []
54
- if not mentions.kind_of?(Array)
54
+ unless mentions.is_a?(Array)
55
55
  mentions = [mentions]
56
56
  end
57
- mentions = mentions.map{ |e| String(e) }
57
+ mentions = mentions.map { |e| String(e) }
58
58
 
59
59
  puts "Will mentions: #{mentions}"
60
60
  puts "Will send to room: #{room}"
@@ -68,7 +68,7 @@ class HipChatNotif < Sensu::Handler
68
68
  if @event['check']['playbook']
69
69
  begin
70
70
  uri = URI.parse(@event['check']['playbook'])
71
- playbook << if %w( http https ).include?(uri.scheme)
71
+ playbook << if %w[http https].include?(uri.scheme)
72
72
  " [<a href='#{@event['check']['playbook']}'>Playbook</a>]"
73
73
  else
74
74
  " Playbook: #{@event['check']['playbook']}"
@@ -78,10 +78,10 @@ class HipChatNotif < Sensu::Handler
78
78
  end
79
79
  end
80
80
 
81
- if message_template && File.readable?(message_template)
82
- template = File.read(message_template)
83
- else
84
- template = '''<%=
81
+ template = if message_template && File.readable?(message_template)
82
+ File.read(message_template)
83
+ else
84
+ '<%=
85
85
  [
86
86
  @event["action"].eql?("resolve") ? "RESOLVED" : "ALERT",
87
87
  " - [#{event_name}] - ",
@@ -89,8 +89,9 @@ class HipChatNotif < Sensu::Handler
89
89
  playbook,
90
90
  "."
91
91
  ].join
92
- %>'''
93
- end
92
+ %>'
93
+ end
94
+
94
95
  eruby = ERB.new(template)
95
96
  message = eruby.result(binding)
96
97
 
@@ -105,9 +106,9 @@ class HipChatNotif < Sensu::Handler
105
106
  notify = true
106
107
  end
107
108
 
108
- mentions = mentions.map{|user| "@#{user}"}.join(", ")
109
+ mentions = mentions.map { |user| "@#{user}" }.join(', ')
109
110
 
110
- if mentions and message_format != "html" and not @event['action'].eql?('resolve')
111
+ if mentions && message_format != 'html' && !@event['action'].eql?('resolve')
111
112
  # Add the mention only if the action is not resolved.
112
113
  message = "#{message} #{mentions}"
113
114
  end
@@ -123,17 +124,17 @@ class HipChatNotif < Sensu::Handler
123
124
  puts "Timed out while attempting to message #{room}"
124
125
  end
125
126
 
126
- if message_format == 'html' and mentions and not @event['action'].eql?('resolve')
127
- # HTML messages won't notify when using @mentions.
128
- begin
129
- Timeout.timeout(5) do
130
- hipchatmsg[room].send(from, mentions,
131
- color: color,
132
- message_format: "text")
133
- end
134
- rescue Timeout::Error
135
- puts "Timed out while attempting to send mentions to #{room}"
127
+ return unless message_format == 'html' && mentions && !@event['action'].eql?('resolve')
128
+
129
+ # HTML messages won't notify when using @mentions.
130
+ begin
131
+ Timeout.timeout(5) do
132
+ hipchatmsg[room].send(from, mentions,
133
+ color: color,
134
+ message_format: 'text')
136
135
  end
136
+ rescue Timeout::Error
137
+ puts "Timed out while attempting to send mentions to #{room}"
137
138
  end
138
139
  end
139
140
  end
@@ -129,11 +129,8 @@ class RDSMetrics < Sensu::Plugin::Metric::CLI::Graphite
129
129
  r = cloud_watch_metric key, rdsname
130
130
  result[config[:scheme] + '.' + rdsname + '.' + key] = r[:datapoints][0] unless r[:datapoints][0].nil?
131
131
  end
132
- unless result.nil?
133
- result.each do |key, value|
134
- output key.to_s, value.average, value[:timestamp].to_i
135
- end
132
+ result.each do |key, value|
133
+ output key.to_s, value.average, value[:timestamp].to_i
136
134
  end
137
- exit
138
135
  end
139
136
  end
@@ -62,7 +62,7 @@ class CassandraBasicMetrics < Sensu::Plugin::Metric::CLI::Graphite
62
62
  def connect
63
63
  @cluster = Cassandra.cluster(
64
64
  hosts: [config[:hostname]],
65
- port: config[:port],
65
+ port: config[:port]
66
66
  )
67
67
  end
68
68
 
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.14.0
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgelab
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 3.0.0
83
- - !ruby/object:Gem::Dependency
84
- name: json
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 1.8.6
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 1.8.6
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: redis
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +114,14 @@ dependencies:
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '1.2'
117
+ version: '2.0'
132
118
  type: :runtime
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '1.2'
124
+ version: '2.0'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: bundler
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -170,32 +156,32 @@ dependencies:
170
156
  requirements:
171
157
  - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: 0.40.0
159
+ version: 0.49.0
174
160
  type: :development
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
164
  - - "~>"
179
165
  - !ruby/object:Gem::Version
180
- version: 0.40.0
166
+ version: 0.49.0
181
167
  description: Sensu plugins developed by Edgelab
182
168
  email:
183
169
  executables:
184
- - check-nomad-leader.rb
185
- - metrics-es-indices.rb
170
+ - check-apt-expired-keys.rb
171
+ - check-cassandra-nodes.rb
186
172
  - check-consul-services.rb
173
+ - check-logstash-pipeline.rb
187
174
  - check-nomad-jobs.rb
188
- - metrics-aws-rds.rb
189
- - check-apt-expired-keys.rb
190
- - metrics-swarm-cluster.rb
175
+ - check-nomad-leader.rb
191
176
  - check-swarm-cluster.rb
192
- - metrics-cassandra-basic.rb
193
- - metrics-redis-key-pattern.rb
194
- - check-cassandra-nodes.rb
195
- - metrics-aws-elb.rb
196
177
  - handler-multi-hipchat.rb
197
- - check-logstash-pipeline.rb
198
178
  - metrics-aws-asg.rb
179
+ - metrics-aws-elb.rb
180
+ - metrics-aws-rds.rb
181
+ - metrics-cassandra-basic.rb
182
+ - metrics-es-indices.rb
183
+ - metrics-redis-key-pattern.rb
184
+ - metrics-swarm-cluster.rb
199
185
  extensions: []
200
186
  extra_rdoc_files: []
201
187
  files:
@@ -233,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
219
  version: '0'
234
220
  requirements: []
235
221
  rubyforge_project:
236
- rubygems_version: 2.6.3
222
+ rubygems_version: 2.7.6
237
223
  signing_key:
238
224
  specification_version: 4
239
225
  summary: Contains Edgelab plugins for Sensu