Skip to content

Instantly share code, notes, and snippets.

@u1tnk
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u1tnk/daa091e3f693b7c3faf1 to your computer and use it in GitHub Desktop.
Save u1tnk/daa091e3f693b7c3faf1 to your computer and use it in GitHub Desktop.
working以外のサーバを一括retire
# -*- coding: utf-8 -*-
# mackrel-client-ruby 0.0.2 使用
require 'mackerel'
client = Mackerel::Client.new(:mackerel_api_key => ENV['MACKEREL_APIKEY'])
client.get_hosts(service: 'service_name').each do |host|
# working以外で初期登録から一週間以上経過している
if host.status != "working" && host.createdAt < Time.now.to_i - (60 * 60 * 24 * 7)
p "retire host id:#{host.id}"
p client.retire_host(host.id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment