Skip to content

Instantly share code, notes, and snippets.

@joemiller
Created May 8, 2012 20:41
Show Gist options
  • Save joemiller/2639107 to your computer and use it in GitHub Desktop.
Save joemiller/2639107 to your computer and use it in GitHub Desktop.
example ruby for silencing checks in Sensu
#!/usr/bin/env ruby
require 'em-http-request'
require 'json'
servers = ["mysql01", "rabbitmq01",
"riak01", "api01", "web01",
"widgets01", "app01", "app02"]
pending = servers.length
EM.run {
servers.each do |server|
request_options = {
:body => {'timestamp' => Time.now.to_i}.to_json,
:head => {'content-type' => 'application/json'} }
http = EM::HttpRequest.new("http://sensuserver:8080/stash/silence/#{server}").post request_options
http.callback {
puts "#{server}\n#{http.response_header.status} - #{http.response.length} bytes\n"
puts http.response
pending -= 1
puts pending
EM.stop if pending == 0
}
end
@joemiller
Copy link
Author

We run this from Jenkins to silence all checks for hosts in the servers array on a regular schedule. Another script is used to unsilence the same servers later.

Note, this silences every check on the listed hosts. You can also silence individual checks within hosts.

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