Skip to content

Instantly share code, notes, and snippets.

View okochang's full-sized avatar
🏠
Working from home

okochang okochang

🏠
Working from home
View GitHub Profile
@okochang
okochang / estimated_monthly_report_mail.rb
Created May 11, 2012 06:40
monthly charge report using cloudwath
# -*- coding: utf-8 -*-
# AWSのアカウント料金からグラフを生成して、メールでレポートするスクリプトです
# $ sudo yum install ImageMagick ImageMagick-devel
# $ gem install rmagick
# $ gem install gruff
# $ gem install right_aws
# $ gem install aws-sdk
require 'right_aws'
@okochang
okochang / smtp-sesmail.rb
Created June 30, 2012 10:53
send sesmail by smtp-interface
# -*- coding: utf-8 -*-
require 'time'
require 'net/smtp'
HOST = 'email-smtp.us-east-1.amazonaws.com'
PORT = 465
HELO = 'localhost'
ACCESS_KEY = 'YOUR_SMTP_USERNAME'
SECRET_KEY = 'YOUR_SMTP_PASSWORD'
FROM_ADDR = 'yanase@okochang.com'
@okochang
okochang / rightaws_runstop_dbinstance.rb
Created July 11, 2012 15:55
AWS RDS auto start/stop ruby script
# -*- coding: utf-8 -*-
require 'rubygems'
require 'right_aws'
### 使用例
# ruby rightaws_runstop_dbinstance.rb rds_instance_name db.m1.small security-group parameter_group
### 事前に指定するパラメータ
# * RDSのインスタンス名
# * RDSのインスタンスタイプ
@okochang
okochang / recovery-ec2instance.rb
Created September 30, 2012 15:27
recovery script for degraded ec2 instance
# -*- coding: utf-8 -*-
## 必要なライブラリ
require 'right_aws'
## 引数チェック
unless ARGV.size == 1 then
puts "引数が正しく設定されていません"
exit 1
end
@okochang
okochang / create_snapshot.sh
Created October 4, 2012 09:12
create new snapshot and delete old snapshot
#!/bin/sh
##Setup
TODAY=`date +\%Y\%m\%d`
INSTANCE_NAME="set your instance name"
LOG="path to your log file"
EBS_VOLUME="set your ebs id"
EC2_REGION=ap-northeast-1
EBS_GENERATION=5
@okochang
okochang / copy-snapshot.sh
Last active December 10, 2015 13:38
Get a snapshot on a daily and copy the snapshot to a different region
#!/bin/sh -x
## setup
TODAY=`date +\%Y\%m\%d`
INSTANCE_NAME="set your instance name"
EBS_VOLUME="set your ebs volume id"
EBS_GENERATION=5
SRC_REGION="ap-northeast-1"
DST_REGION="ap-southeast-1"
TAG="set your management tag"
@okochang
okochang / copy-security-group-contents.rb
Created January 28, 2013 15:41
特定のEC2のセキュリティグループを元に、同じ内容のセキュリティグループを作成するスクリプト
# -*- coding: utf-8 -*-
## 必要なライブラリ
require 'right_aws'
## 各種設定
src_group_id = ARGV[0]
dst_group_name = ARGV[1]
description = ARGV[2]
ACCESS_KEY = 'set your access key id'
@okochang
okochang / CacheHitPercent.rb
Created January 29, 2013 06:56
Storage Gatewayの監視用スクリプト(CacheHitPercent)
#!/bin/env ruby
# -*- coding: utf-8 -*-
require 'aws-sdk'
require 'time'
ACCESS_KEY = "#{ARGV[0]}"
SECRET_KEY = "#{ARGV[1]}"
gateway_id = "#{ARGV[2]}"
gateway_name = "#{ARGV[3]}"
@okochang
okochang / CachePercentDirty.rb
Created January 29, 2013 07:09
Storage Gatewayの監視用スクリプト(CachePercentDirty)
#!/bin/env ruby
# -*- coding: utf-8 -*-
require 'aws-sdk'
require 'time'
ACCESS_KEY = "#{ARGV[0]}"
SECRET_KEY = "#{ARGV[1]}"
gateway_id = "#{ARGV[2]}"
gateway_name = "#{ARGV[3]}"
@okochang
okochang / CachePercentUsed.rb
Created January 29, 2013 07:11
Storage Gatewayの監視用スクリプト(CachePercentUsed)
#!/bin/env ruby
# -*- coding: utf-8 -*-
require 'aws-sdk'
require 'time'
ACCESS_KEY = "#{ARGV[0]}"
SECRET_KEY = "#{ARGV[1]}"
gateway_id = "#{ARGV[2]}"
gateway_name = "#{ARGV[3]}"