Created
January 29, 2013 08:26
-
-
Save okochang/4662683 to your computer and use it in GitHub Desktop.
Storage Gatewayの監視用スクリプト(StorageGatewayState)
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
#!/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