Skip to content

Instantly share code, notes, and snippets.

@okochang
Created January 29, 2013 08:26
Show Gist options
  • Save okochang/4662683 to your computer and use it in GitHub Desktop.
Save okochang/4662683 to your computer and use it in GitHub Desktop.
Storage Gatewayの監視用スクリプト(StorageGatewayState)
#!/bin/env ruby
# -*- coding: utf-8 -*-
require 'aws-sdk'
ACCESS_KEY = "#{ARGV[0]}"
SECRET_KEY = "#{ARGV[1]}"
REGION = "#{ARGV[2]}"
gateway_arn = "#{ARGV[3]}"
## AWSへの認証を行います
sg = AWS::StorageGateway.new(
:access_key_id => ACCESS_KEY,
:secret_access_key => SECRET_KEY,
:storage_gateway_endpoint => REGION
).client
## Storage Gatewayのステータスを取得します
begin
sgw_state = sg.describe_gateway_information({:gateway_arn => gateway_arn})[:gateway_state]
rescue
end
## 取得したステータスを出力します
if sgw_state.nil? then
puts "DOWN"
else
puts sgw_state
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment