Skip to content

Instantly share code, notes, and snippets.

View tagomoris's full-sized avatar

Satoshi Tagomori tagomoris

View GitHub Profile
@tagomoris
tagomoris / gist:1797432
Created February 11, 2012 07:29
RotateHandler doesn't have #call
diff --git a/lib/fluent/plugin/in_tail.rb b/lib/fluent/plugin/in_tail.rb
index 861bcd2..48c3c70 100644
--- a/lib/fluent/plugin/in_tail.rb
+++ b/lib/fluent/plugin/in_tail.rb
@@ -238,7 +238,7 @@ class TailInput < Input
end
def on_change(prev, cur)
- @h.call
+ @h.check
#ls -l /proc/6943/fd
total 0
lr-x------ 1 username group 64 Feb 16 14:51 0 -> pipe:[1353571971]
l-wx------ 1 username group 64 Feb 16 14:51 1 -> pipe:[1353571972]
lrwx------ 1 username group 64 Feb 16 14:51 10 -> socket:[1353576456]
lrwx------ 1 username group 64 Feb 16 14:51 100 -> socket:[1353576926]
lr-x------ 1 username group 64 Feb 16 14:51 101 -> eventpoll:[1353576927]
lrwx------ 1 username group 64 Feb 16 14:51 102 -> socket:[1353576928]
lr-x------ 1 username group 64 Feb 16 14:51 103 -> eventpoll:[1353576929]
lrwx------ 1 username group 64 Feb 16 14:51 104 -> socket:[1353576930]
<source>
type scribe
# port 14631
port 14631
add_prefix scribe
remove_newline true
</source>
<match scribe.**>
type copy
<store>
@tagomoris
tagomoris / gist:2155389
Created March 22, 2012 03:19
pseudo bind mix-in for mysql2
module Mysql2::Client::PseudoBindMixi
def pseudo_bind(sql, values)
sql = sql.dup
placeholders = []
search_pos = 0
while pos = sql.index('?', search_pos)
placeholders.push(pos)
search_pos = pos + 1
end
@tagomoris
tagomoris / gist:2166103
Created March 23, 2012 01:45
Yajl::Parser#<< crashed on ruby 1.9.3-p125
1.9.2p180 :001 > require 'yajl'
=> true
1.9.2p180 :002 > y = Yajl::Parser.new
=> #<Yajl::Parser:0x007f895d098038>
1.9.2p180 :003 > y.on_parse_complete = lambda {|msg| p msg}
=> #<Proc:0x007f895d08de80@(irb):3 (lambda)>
1.9.2p180 :004 > y << '{"message":1}'
{"message"=>1}
=> nil
1.9.2p180 :005 >
1.9.3p125 :001 > require 'yajl'
=> true
1.9.3p125 :002 > y.on_parse_complete = lambda {|msg| p msg}
NameError: undefined local variable or method `y' for main:Object
from (irb):2
from /Users/tagomoris/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'
1.9.3p125 :003 > y = Yajl::Parser.new
=> #<Yajl::Parser:0x007fd2fc92ce90>
1.9.3p125 :004 > y.on_parse_complete = lambda {|msg| p msg}
=> #<Proc:0x007fd2fc926108@(irb):4 (lambda)>
@tagomoris
tagomoris / check_gf_value.pl
Created March 28, 2012 09:28
nagios plugin to check growthforecast values
#!/usr/bin/env perl
use strict;
use warnings;
use lib q!/Users/tagomoris/Documents/nagios-scripts/extlib/lib/perl5!;
use List::Util qw!!;
use Getopt::Long;
Getopt::Long::Configure ("no_ignore_case");
@tagomoris
tagomoris / gist:2233243
Created March 29, 2012 04:17
deliver fluentd configuration
<source>
type forward
# port 24211
port 24211
</source>
<match raw.**>
type copy
<store>
type scribe
host central1.local
def emit(tag, es, chain)
t = if @sample_unit == :all
'all'
else
tag
end
# Access to @counts SHOULD be protected by mutex, with a heavy penalty.
# Code below is not thread safe, but @counts (counter for sampling rate) is not
# so serious value (and probably will not be broke...),
# then i let here as it is now.
def emit(tag, es, chain)
t = if @sample_unit == :all
'all'
else
tag
end
# Access to @counts SHOULD be protected by mutex, with a heavy penalty.
# Code below is not thread safe, but @counts (counter for sampling rate) is not
# so serious value (and probably will not be broke...),
# then i let here as it is now.