Last active
August 29, 2015 14:03
-
-
Save u1tnk/daa091e3f693b7c3faf1 to your computer and use it in GitHub Desktop.
working以外のサーバを一括retire
This file contains 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
# -*- 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