Skip to content

Instantly share code, notes, and snippets.

View koemu's full-sized avatar

Yuichiro SAITO koemu

View GitHub Profile
@koemu
koemu / mackerel-agent.conf
Last active August 23, 2017 11:18
Makcerel agent configuration
apikey = "?"
# metric plugins
[plugin.metrics.nginx]
command = "/usr/bin/mackerel-plugin-nginx"
type = "metric"
[plugin.metrics.linux]
command = "/usr/bin/mackerel-plugin-linux"
@koemu
koemu / isucon3_practice_log.md
Last active September 26, 2015 01:01
ISUCON3 過去問 個人演習

選択言語: go

  • 処理系バージョンアップ無し
  • ミドルウェア nginxのみ最新(1.9.4), mysqlはインストール済みのものを利用

initial

Result:   SUCCESS
RawScore: 2632.6
@koemu
koemu / yapc_asia_tokyo_2015_memo.md
Last active August 29, 2015 14:27
YAPC::Asia Tokyo 2015 メモ
@koemu
koemu / mackerel-agent.conf
Last active February 13, 2016 05:50
Get Raspberry pi temperature for Mackerel
# Please append this lines to your config file.
[plugin.metrics.raspberrypi_env_temp]
command = "/usr/local/bin/raspberrypi_env_temp.py"
type = "metric"
@koemu
koemu / cacti_xml_hash_convert.py
Created July 31, 2014 10:19
Replace hash value for Cacti template xml file.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import hashlib
source = open( sys.argv[1] ).read()
result = re.finditer( r'hash\_([0-9]{6})(\w{32})', source )
@koemu
koemu / kvm_guest_state_metrics.sh
Created July 24, 2014 05:32
Get running KVM guests for Mackerel
#!/bin/bash
DATE=$(date +%s)
echo -e "kvm.guest.state.running\t$(virsh list --uuid | sed '/^$/d' | wc -l)\t${DATE}"
echo -e "kvm.guest.state.inactive\t$(virsh list --inactive --uuid | sed '/^$/d'| wc -l)\t${DATE}"
@koemu
koemu / kvm_guest_dominfo.py
Created July 24, 2014 05:29
Get KVM guest information for Mackerel
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import commands
import datetime
argv = sys.argv
if len( argv ) < 2:
print "usage " + sys.argv[0] + " info_name"
@koemu
koemu / kvm_guest_virttop.py
Created July 24, 2014 05:26
Get KVM guest CPU Usage for Mackerel
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import commands
import datetime
unix_time = datetime.datetime.today().strftime('%s')
retval = commands.getstatusoutput( "virt-top -b --stream -n 2 -d 1" )
@koemu
koemu / ksm_metrics.sh
Created July 23, 2014 05:52
Get ksm metrics for Mackerel
#!/bin/bash
DATE=$(date +%s)
echo -e "ksm.pages_volatile\t$(cat /sys/kernel/mm/ksm/pages_volatile)\t${DATE}"
echo -e "ksm.pages_shared\t$(cat /sys/kernel/mm/ksm/pages_shared)\t${DATE}"
echo -e "ksm.pages_sharing\t$(cat /sys/kernel/mm/ksm/pages_sharing)\t${DATE}"
echo -e "ksm.pages_unshared\t$(cat /sys/kernel/mm/ksm/pages_unshared)\t${DATE}"
@koemu
koemu / getswap.sh
Created December 18, 2013 01:09
各プロセスのスワップ使用量を調べる。 なお、root or sudo での実行が必要。 参照元: http://northernmost.org/blog/find-out-what-is-using-your-swap/
#!/bin/bash
# Get current swap usage for all running processes
# Erik Ljungstrom 27/05/2011
# Updated: 2013-11-13 Yuichiro Saito
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`