Open makayez opened 6 years ago
From: /root/check-aggregate.rb @ line 151 CheckAggregate#honor_stash:
149: def honor_stash(aggregate)
150: require "pry"
=> 151: binding.pry
152: aggregate[:results].delete_if do |entry|
153: begin
154: api_request("/stashes/silence/#{entry[:client]}/#{config[:check]}")
155: if entry[:status] == 0
156: aggregate[:ok] = aggregate[:ok] - 1
157: elsif entry[:status] == 1
158: aggregate[:warning] = aggregate[:warning] - 1
159: elsif entry[:status] == 2
160: aggregate[:critical] = aggregate[:critical] - 1
161: else
162: aggregate[:unknown] = aggregate[:unknown] - 1
163: end
164: aggregate[:total] = aggregate[:total] - 1
165: true
166: rescue RestClient::ResourceNotFound
167: false
168: end
169: end
170: aggregate
171: end
aggregate is a hash, not an array. delete_if
isn't a method on hash
Running sensu-server 1.0.2, sensu-plugins-sensu 2.2.0, sensu-plugin (2.3.0, 1.4.5), when using the "honor_stash" switch, I receive the following error. I've tried this on a fresh install and fresh plugin install.
/opt/sensu/embedded/bin/ruby /opt/sensu/embedded/bin/check-aggregate.rb -a http://localhost:4567 -c agg-check-feeds -i --critical_count 1 -A 600
Check failed to run: undefined method 'delete_if' for nil:NilClass, ["/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-2.2.0/bin/check-aggregate.rb:164:in 'honor_stash'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-sensu-2.2.0/bin/check-aggregate.rb:317:in 'run'", "/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in 'block in <class:CLI>'"]