Skip to content

Instantly share code, notes, and snippets.

echo 'stats' |nc localhost 11211
echo 'flush_all' |nc localhost 11211
@u1tnk
u1tnk / retire_hosts.rb
Last active August 29, 2015 14:03
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)