Skip to content

Instantly share code, notes, and snippets.

View fujiwara's full-sized avatar

FUJIWARA Shunichiro fujiwara

View GitHub Profile
@fujiwara
fujiwara / multitail-consul
Created May 20, 2015 07:47
multitail-consul
#!/usr/bin/perl
use strict;
use warnings;
my $regex = shift;
my $cmd = quotemeta(shift);
my @nodes = `consul members -status alive`;
shift @nodes; # dispose header
@nodes = grep /$regex/, map { (split /\s+/, $_)[0] } @nodes;
@fujiwara
fujiwara / multitail-consul
Created May 18, 2015 01:58
multitail-consul
#!/bin/bash
set -e
node="$1"
cmd="$2"
nodes=$(consul members -status alive | awk "/$node/{ print \$1 }")
args=()
for n in $nodes
package mapbench_test
import "testing"
var N = 1000000
func BenchmarkMap(b *testing.B) {
for i := 0; i < b.N; i++ {
m := map[int]int{}
for j := 0; j < N; j++ {
@fujiwara
fujiwara / build.txt
Last active August 29, 2015 14:13
go-bindata backend file server
$ go-bindata -prefix=public public/...
$ go build
@fujiwara
fujiwara / bench.go
Created January 6, 2015 07:26
toInt64 bench
package fluent_test
import (
"reflect"
"testing"
)
var testNumbers = []interface{}{
int(10),
uint(10),
@fujiwara
fujiwara / trapper.go
Created December 12, 2014 06:50
An example for your zabbix trapper daemon.
package main
import (
"log"
"github.com/fujiwara/go-zabbix-get/zabbix"
)
func main() {
err := zabbix.RunTrapperServer(
@fujiwara
fujiwara / gist:8a2c30d40dec6403aa88
Created September 5, 2014 01:22
in_tail wrong time parsing?
[fluentd]
$ fluentd -c fluentd.conf
2014-09-05 10:17:57 +0900 [info]: starting fluentd-0.10.53
2014-09-05 10:17:57 +0900 [info]: reading config file path="fluentd.conf"
2014-09-05 10:17:57 +0900 [info]: gem 'fluentd' version '0.10.53'
2014-09-05 10:17:57 +0900 [info]: using configuration file: <ROOT>
<source>
type tail
tag ltsv
format ltsv
@fujiwara
fujiwara / fluentd.conf
Created September 4, 2014 10:10
in_tail wrong time parsing?
<source>
type forward
</source>
<source>
tag test
type tail
format json
path /tmp/test.log
</source>
<match **>
@fujiwara
fujiwara / bench.pl
Created August 25, 2014 09:30
Data::Validator vs Data::Util
#!/usr/bin/env perl
use 5.12.1;
use Data::Validator;
use Data::Util;
use Benchmark qw/ :all /;
cmpthese 0, {
"Data::Validator" => sub {
dv(100);
},
@fujiwara
fujiwara / agent.conf
Created August 14, 2014 08:39
benchmark fluentd vs fluent-agent-lite vs fluent-agent-hydra
<source>
type tail
path /dev/shm/tmp/dummy.log
pos_file /var/tmp/_var_log_dummy.pos
format none
tag dummy
</source>
<match dummy>
type copy
<store>