Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
use strict;
use Data::Dumper;
print "Content-Type: text/plain\n\n";
print Dumper(\@ARGV);
@fujiwara
fujiwara / bench.rb
Last active August 29, 2015 14:00
benchmark of fluent-plugin-parser time_parse cache
#!/usr/bin/env ruby
start = Time.now
`cat access.log.ltsv | fluent-agent-lite accesslog - 127.0.0.1`
puts "elapsed #{(Time.now - start)*1000} ms"
@fujiwara
fujiwara / main.go
Created May 31, 2014 14:05
consul-catalogを使って監視しているserviceのNode自体に変更があったことを検知する
package main
import (
"encoding/json"
"github.com/mizzy/consul-catalog"
"log"
"os"
"reflect"
"time"
)
@fujiwara
fujiwara / ZabbixAPI.pm
Created June 9, 2014 02:07
Quick open to Zabbix screen by percol.
package ZabbixAPI;
use strict;
use warnings;
use Mouse;
use Try::Tiny;
use JSON;
use HTTP::Request::Common;
use LWP::UserAgent;
$ zabbix_get_eval.sh system.uname agent.version '[[ $1 =~ "foo" || $2 =~ ^1\.8 ]]'
$ perl s.pl
keys:10000 size:1348738
keys:20000 size:2708562
keys:30000 size:3478562
keys:40000 size:5428210
keys:50000 size:6198210
keys:60000 size:6968210
keys:70000 size:10097506
keys:80000 size:10867506
keys:90000 size:11637506
@fujiwara
fujiwara / main.go
Created July 15, 2014 15:05
Listen 80 and drop root privileges Go http server example
package main
import (
"net"
"net/http"
"syscall"
"log"
)
func main() {
@fujiwara
fujiwara / Makefile
Last active August 29, 2015 14:05
benchmark set for packing msgpack (fluentd packed forward)
bench: packedforward test.log extlib
@echo "testing perl"
@cat test.log | PERL5LIB=extlib time perl ./packedforward.pl > /dev/null
@echo "testing go"
@cat test.log | time ./packedforward > /dev/null
check: packedforward test.log extlib
@head -1234 test.log | TIME=1407856567 PERL5LIB=extlib perl ./packedforward.pl | md5sum
@head -1234 test.log | TIME=1407856567 ./packedforward | md5sum
@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 / 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