Skip to content

Instantly share code, notes, and snippets.

View inokappa's full-sized avatar
😴
zzzzz

Yohei Kawahara inokappa

😴
zzzzz
View GitHub Profile
@inokappa
inokappa / gist:f265a987eceabe894a39
Created May 11, 2014 13:20
Chef の role にて定義する sensu-server.json
{
"name": "sensu-server",
"default_attributes": {
},
"override_attributes": {
},
"run_list": [
"sensu",
"sensu::redis",
"sensu::rabbitmq",
@inokappa
inokappa / gist:ea084cbcacdd0e203e43
Last active August 29, 2015 14:01
CloudWatch にカスタムメトリクスを飛ばしてインスタンスのリソースを監視する
#!/usr/bin/env bash
# Config
export AWS_CLOUDWATCH_HOME=/opt/aws/CloudWatch
export AWS_CREDENTIAL_FILE=$AWS_CLOUDWATCH_HOME/credentials
export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com
export PATH=$AWS_CLOUDWATCH_HOME/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0
function get_instance_id() {
@inokappa
inokappa / gist:dc5264162b1b007d53cb
Created May 12, 2014 22:15
バックアップファイルを確認する spec ファイル
require 'date'
require 'spec_helper'
D = Date.today.strftime("%Y%m%d")
describe file("/path/to/backup/#{D}") do
it { should be_directory }
end
BACKUP_FILE=[
'file1.gz', \
@inokappa
inokappa / gist:602ca3e4a8267755822a
Created May 12, 2014 22:23
Elasticsearch の稼働を監視する spec ファイル
require 'spec_helper'
describe service('elasticsearch') do
it { should be_enabled }
it { should be_running }
end
PORTS=['9200','9300']
PORTS.each do |port|
describe port("#{port}") do
@inokappa
inokappa / gist:54744c7aab1f7494ab16
Created May 13, 2014 21:29
RabbitMQ の HA ポリシーパターンを Google 翻訳して頂いた

Queue is mirrored across all nodes in the cluster. When a new node is added to the cluster, the queue will be mirrored to that node.

キューは、クラスタ内のすべてのノード間でミラーリングされます。新しいノードがクラスタに追加されると、キューはそのノードにミラーリングされます。

Queue is mirrored to count nodes in the cluster. If there are less than count nodes in the cluster, the queue is mirrored to all nodes. If there are more than count nodes in the cluster, and a node containing a mirror goes down, then a new mirror will not be created on another node. (This is to prevent queues migrating across a cluster as it is brought down.)

キューは、クラスタ内のノードをカウントするためにミラーリングされています。 クラスタ内のノードを数えるよりも少ないがある場合は、キューは、すべてのノードにミラーリングされます。そこに、クラスタ内のノードを数えるよりもあり、ミラーを含むノードがダウンした場合、新しいミラーは、別のノード上に作成されることはありません。 (これは、ダウンしているように、クラスタ全体の移行のキューを防ぐためです。)

>Queue is mirrored to the nodes listed in node names. If any of those node names are not a part of the cluster, this does not constitute an error. If none of the nodes in the list are online at the time when the queue is declared then the queue will b

@inokappa
inokappa / gist:ca83b5d0b9a6b3c0996a
Last active August 29, 2015 14:01
RabbitMQ を Ruby から操作する(send.rb)
#!/usr/bin/env ruby
# encoding: utf-8
require "bunny"
conn = Bunny.new(:hostname => "localhost")
conn.start
ch = conn.create_channel
q = ch.queue("hello")
ch.default_exchange.publish("Hello World!", :routing_key => q.name)
@inokappa
inokappa / gist:55616b179e567f19b36f
Last active August 29, 2015 14:01
RabbitMQ を Ruby から操作する(receive.rb)
#!/usr/bin/env ruby
# encoding: utf-8
#
require "bunny"
if ARGV[0] == ""
conn = Bunny.new(:hostname => "localhost")
else
conn = Bunny.new(:hostname => "#{ARGV[0]}")
@inokappa
inokappa / gist:26dc5c7e4b27e2b04102
Last active August 29, 2015 14:01
RabbiMQ の HA 3 パターン
ha-mode ha-params Result
all 無し キューはクラスタ内のすべてのノード間でミラーリングされる。新しいノードがクラスタに追加されるとキューはそのノードにミラーリングされる。
exactly count キューは count に指定した数のノードにミラーリングされる。但し、クラスタ内のノード数が count より>少ない場合には全てのノードにコピーされる。
nodes node names キューは node names に指定したノードにミラーリングされる。
@inokappa
inokappa / gist:09da71518c6771e40e5c
Last active August 29, 2015 14:01
涙の自腹課金検証シリーズ第二弾:Focuslight を試す + eye でプロセス監視してみる

涙の自腹課金検証シリーズ第二弾:Focuslight を試す + eye でプロセス監視してみる

はじめに

  • Growthforecast を調べていたら Focuslight に辿り着いたので試す
  • Growthforecast とのデータ互換もあるようだ(すばらしひ)
  • バックエンドのストレージとして MySQL の利用も可能だが今回は SQLite で試してみる
  • また、TODODaemonize support とありデーモン化は出来ていないようなので別の手段(eye)を使ってデーモン化を試みてみる

@inokappa
inokappa / gist:ab37df8a3bd2271b99bb
Created May 18, 2014 12:09
CloudWatch クライアントツールのダウンロード
wget http://ec2-downloads.s3.amazonaws.com/CloudWatch-2010-08-01.zip
unzip CloudWatch-2010-08-01.zip
sudo cp -rfp CloudWatch-1.0.20.0 /opt/aws/CloudWatch