Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
tkuchiki / memo.md
Last active February 14, 2017 07:25
parted 3.2 の SPEC ファイル (Amazon Linux 2016.09 で検証)
  • tarball は ftp://ftp.gnu.org/gnu/parted/parted-3.2.tar.xz
  • 解凍すると spec ファイルが入っているが、以下の理由により修正
    • Source が間違っている (tar.bz2 になっている)
    • BuildRequires に libuuid-devel を追加
    • %files も間違っている
    • check-rpath でこけるので無効にした (%undefine __arch_install_post)
  • あまり良くない対応
@tkuchiki
tkuchiki / sed.md
Created February 9, 2017 02:01
sed の使い方まとめ

マッチした行+以下N行を消す

$ cat /tmp/test.txt
foo
bar
baz
hoge

$ gsed -e '/foo/,+2d' /tmp/test.txt
@tkuchiki
tkuchiki / redis.md
Last active February 7, 2017 03:05
CentOS 6 で Redis 3.2.7 を make すると undefined reference to 'clock_gettime' and 'clock_settime' というエラーがでる

CentOS 6 で Redis 3.2.7 を make すると以下のようなエラーが出ます。

cc    -rdynamic -o redis-check-aof redis-check-aof.o -lm -ldl -pthread ../deps/jemalloc/lib/libjemalloc.a
../deps/jemalloc/lib/libjemalloc.a(nstime.o): In function `nstime_get':
/path/to/rpmbuild/BUILD/redis-3.2.7/deps/jemalloc/src/nstime.c:120: undefined reference to `clock_gettime'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/path/to/rpmbuild/BUILD/redis-3.2.7/src'
@tkuchiki
tkuchiki / memo.md
Created February 6, 2017 07:26
fluentd で time というキーを in_tail -> out_xxx で出力したい場合の注意点

in_tail

  • keep_time_key は default = false なので time キーは消される
    • keep_time_key true を追加

out_xxx

  • include_time_key true を設定しただけでは time_key は default = time なので in_tail した time は上書きされる
  • include_time_key true かつ time_key を time 以外にする
@tkuchiki
tkuchiki / memo.md
Last active August 2, 2017 01:48
CloudFront + S3 で static website hosting のリダイレクトルールを使用するときの注意点 & API Gateway
  • CloudFront の origin を static website hosting のドメインにする(foobar.s3-website-ap-northeast-1.amazonaws.com みたいなやつ)
    • S3 の bucket を設定すると static website hosting ではないのでリダイレクトルールが適応されない
  • S3 の policy の Principal は "AWS": "*" でないと 403
  • redirect_rule.xml は 404 だったら your.domain にリダイレクト
    • path を維持したい場合は <ReplaceKeyWith/> を削除
    • https にしたければ <Redirect></Redirect><Protocol>https</Protocol> を追加
  • POST を受けたい場合は API Gateway + Lambda を使う
    • Origin を API Gateway の endpoint にする
  • (当然だが)Host ヘッダを透過させると動かない
@tkuchiki
tkuchiki / zbx_crond_template.xml
Created December 26, 2016 07:38
zabbix Template_crond for (RHEL, Ubuntu)
<?xml version="1.0" encoding="UTF-8"?>
<zabbix_export>
<version>2.0</version>
<date>2016-12-26T07:34:40Z</date>
<groups>
</groups>
<templates>
<template>
<template>Template_crond</template>
<name>Template_crond</name>
@tkuchiki
tkuchiki / query.md
Last active June 13, 2017 03:23
Norikra でクエリの実行結果(event)を別のクエリで処理する
-- QUERY:{"name":"filtered_username","group":"LOOPBACK(filtered_username)","targets":["users"],"suspended":false}
SELECT id, username, age
  FROM users.win:time_batch(1 min)
  WHERE username LIKE 'foobar%'

-- QUERY:{"name":"user_count","group":"STDOUT()","targets":[],"suspended":false}
SELECT
  COUNT(*) AS cnt,
 COUNT(*) / 60.0 AS cnt_per_sec
# redash.0.11.0.b2016 to redash.0.12.0.b2449
$ upgrade.sh 0.12.0.b2449
@tkuchiki
tkuchiki / result.md
Last active November 17, 2016 06:04
json を mackerel plugin の出力形式に変換
$ cat /tmp/test.json
{
  "foo": 0,
  "bar": 100
}

$ cat /tmp/test.json | jq -r '. | to_entries | map("\(.key)\t\(.value)") | join("\n")'
foo     0
bar 100
@tkuchiki
tkuchiki / stretcher.spec
Created November 16, 2016 04:10
stretcher.spec
Summary: A deployment tool with Consul / Serf event
Name: stretcher
Version: 0.8.0
Release: 1%{?dist}
License: MIT
Group: Applications/Services
URL: https://github.com/fujiwara/stretcher
Source: https://github.com/fujiwara/stretcher/releases/download/v%{version}/stretcher-v%{version}-linux-amd64.zip
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)