read
Pingdom does not offer functionality in their web interface to have maintenance windows. As of right now, we have a blocking backup of our MySQL database every night. It is annying to get alerts from Pingdom because of this, so I had to create a simple solution by using the Pingdom API. The following Ruby-script sends a simple HTTP-request to the Pingdom API and disables all available checks in Pingdom. I have configured this to run through cron every night, and it solves my problem with receiving alerts during backups. In the long run, we will of course eliminate the downtime by setting up non-blocking backup with e.g. Percona Xtrabackup
#!/usr/bin/env ruby
require 'em-http'
require 'em-http/middleware/json_response'
require 'optparse'
require 'yaml'
config = YAML.load_file 'pingdom.yml'
pingdom_user = config['username']
pingdom_pass = config['password']
pingdom_appkey = config['appkey']
host = 'https://api.pingdom.com'
request_options = {
:path => '/api/2.0/checks',
:head => {
'accept-encoding' => 'gzip, compressed',
'app-key' => pingdom_appkey,
'authorization' => [pingdom_user, pingdom_pass]
}
}
optparse = OptionParser.new do |opts|
opts.banner = "usage: #{$0} [options]"
opts.on('-h', '--help', 'display this message') do
puts opts
exit
end
opts.on('-p', '--pause', 'pause all checks') do
request_options[:body] = 'paused=true'
end
opts.on('-u', '--unpause', 'unpause all checks') do
request_options[:body] = 'paused=false'
end
end
optparse.parse!
EventMachine.run do
EventMachine::HttpRequest.use EventMachine::Middleware::JSONResponse
http = EventMachine::HttpRequest.new host
request = http.put request_options
request.callback do
if request.response.has_key? 'error'
puts request.response
exit 1
else
EventMachine.stop_event_loop
end
end
end
username: '<pingdom username>'
password: '<pingdom password>'
appkey: 'pingdom application key>'