Skip to content

Instantly share code, notes, and snippets.

View shrkw's full-sized avatar

Hiroyuki Shirakawa shrkw

  • Nagano, Japan
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# gunzip -c proxy_access_8844_log-20130720.gz | python ~/ResponseTimeParser.py >> /tmp/proxy_access_8844_log
import sys
import math
class ResponseResult(object):
count = 1
@shrkw
shrkw / capturing_server.js
Last active December 21, 2015 19:09
1 file screen capturing server depended on phantomjs
var page = require('webpage').create();
var server = require('webserver').create();
var system = require('system');
var host, port;
if (system.args.length !== 2) {
console.log('Usage: server.js <some port>');
phantom.exit(1);
} else {
port = system.args[1];
@shrkw
shrkw / userparameter_postgresql.conf
Last active December 20, 2015 02:49
Zabbix template xml and user parameter config file for PostgreSQL 8.2 You need to make public.pg_stat_activity_as_admin view before using postgres.pg_stat_activity.waiting since seeing other owner's processes without superuser permission. http://postgres.sios.com/modules/newbb/viewtopic.php?viewmode=thread&topic_id=117&forum=1
UserParameter=postgres.pg_stat_database[*],$PGSQL_HOME/bin/psql -h localhost -p 5432 -U zabbix-mon YOUR_DB -At -c "SELECT SUM($1) FROM pg_stat_database;"
UserParameter=postgres.pg_locks[*],$PGSQL_HOME/bin/psql -h localhost -p 5432 -U zabbix-mon YOUR_DB -At -c "SELECT COUNT(*) FROM pg_locks WHERE mode='$1';"
UserParameter=postgres.pg_stat_activity.waiting,$PGSQL_HOME/bin/psql -h localhost -p 5432 -U zabbix-mon YOUR_DB -At -c "SELECT COUNT(*) FROM public.pg_stat_activity_as_admin WHERE waiting = false;"
UserParameter=postgres.version,$PGSQL_HOME/bin/psql --version | head -1
@shrkw
shrkw / edit_jenkins_config.sh
Created July 3, 2013 09:33
Manually editing Jenkins config xml
#!/bin/bash
IFS='
'
i=1
for l in `grep -n '<hudson.triggers.SCMTrigger>' /disk1/jenkins/jobs/*/config.xml`
#for l in `head -1 /tmp/src`
do
n=`echo $l | cut -d':' -f2`
@shrkw
shrkw / fw_rule_flattener.py
Created April 26, 2013 06:52
flattening firewall rules
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# sample src
#
# D-U-DENY-1,match,source-address,any
# D-U-DENY-1,match,destination-address,192.0.2.163/32
# D-U-DENY-1,match,destination-address,198.51.100.202/32
# D-U-DENY-1,match,application,any
# D-U-DENY-1,then,deny,
yum -y install python-setuptools
easy_install fabric
@shrkw
shrkw / useradd_wih_ssh_key.sh
Created February 8, 2013 01:53
create new user with ssh key
read USER_NAME
useradd ${USER_NAME}
mkdir -m 700 /home/${USER_NAME}/.ssh
cat << _EOF_ > /home/${USER_NAME}/.ssh/authorized_keys
chmod 400 /home/${USER_NAME}/.ssh/authorized_keys
chown ${USER_NAME}:${USER_NAME} -R /home/${USER_NAME}/.ssh
@shrkw
shrkw / etc init.d unicorn-redmine
Last active July 6, 2016 01:22
init script for unicorn on RHEL, Cent OS, Scientific Linux way
#!/bin/sh
#
# unicorn_redmine Startup script for unicorn for redmine
#
# chkconfig: - 86 14
# processname: unicorn_rails
# pidfile: /opt/redmine/tmp/pids/unicorn.pid
# description: Rails application server for Redmine
#
### BEGIN INIT INFO