Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using Aggregate Check with "honor_stash" #43

Open
makayez opened this issue Sep 25, 2017 · 1 comment
Open

Error when using Aggregate Check with "honor_stash" #43

makayez opened this issue Sep 25, 2017 · 1 comment

Comments

@makayez
Copy link

makayez commented Sep 25, 2017

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>'"]

@makayez makayez changed the title Error Error when using Aggregate Check with "honor_stash" Sep 25, 2017
@johntdyer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants