Created
May 8, 2012 20:41
-
-
Save joemiller/2639107 to your computer and use it in GitHub Desktop.
example ruby for silencing checks in Sensu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.