Skip to content

Instantly share code, notes, and snippets.

View ginokent's full-sized avatar
🏠
Working from home

ginokent ginokent

🏠
Working from home
View GitHub Profile
@ginokent
ginokent / check_td-agent_worker_limits.sh
Last active January 7, 2019 03:23
[one-liner] td-agent の worker process の file descriptor の数を確認したい ( worker process が 2 つ以上の場合は考慮していない )
cat /proc/"$(pgrep -f fluentd | xargs -I@ pgrep -P @)"/limits
@ginokent
ginokent / aws-cloudformation-describe-stacks.sh
Last active January 7, 2019 03:24
[one-liner] AWS CloudFormation drift 検知
aws cloudformation describe-stacks --query 'Stacks[].StackName' --output text | tr '[[:blank:]]' '\n' | xargs -I{} aws cloudformation detect-stack-drift --stack-name {}
kill $(uname -s|grep Linux && echo -USR1 || echo -INFO) $(pgrep ^dd$)
sudo sh -c 'while pgrep -q ^dd$; do date; kill $(uname -s|grep Linux && echo -USR1 || echo -INFO) $(pgrep ^dd$); sleep 60; done'
@ginokent
ginokent / ssh_port_forwarding_mysql.md
Last active December 4, 2018 05:53
踏み台サーバとアプリケーションサーバを経由してMySQLサーバのポートをlocalhostにフォワーディング

踏み台サーバとアプリケーションサーバを経由してMySQLサーバのポートをlocalhostにフォワーディング(バックグラウンド実行)

ssh -fN -i ~/.ssh/id_rsa -o "ProxyCommand ssh -p ${BASTION_PORT} ${BASTION_USER}@${BASTION_HOST} -W %h:%p" -L 127.0.0.1:3306:${MYSQL_HOST}:3306 ${APP_USER}@${APP_HOST}

MySQLに接続

mysql -h127.0.0.1
#!/bin/bash
getps() {
/usr/bin/ionice -c 3 /usr/bin/nice -n 19 /bin/bash -c '{
TODAYLOG="$HOME/getps_$(/bin/date +%Y%m%d).log"
YESTERDAYLOG="$HOME/getps_$(/bin/date -d yesterday +%Y%m%d).log"
{
/bin/echo "==> delimiter <==";
/bin/date -Is;
/bin/ps auxfewww;
/bin/echo;
@ginokent
ginokent / replace.py
Last active August 31, 2018 03:41
個人的にsedの代わりに使う
#!/usr/bin/env python
import argparse,re,sys
# opts
parser = argparse.ArgumentParser()
parser.add_argument("-r", "--replace", action="store_true")
parser.add_argument("-b", "--before", dest="before")
parser.add_argument("-a", "--after", dest="after")
parser.add_argument("-f", "--file", dest="file")
if len(sys.argv) <= 1:
parser.print_help()
#!/bin/bash
_err() {
printf "$(date +'%Y-%m-%dT%H:%M:%S%z') [ERROR] $@" >&2
}
_usage() {
_err "Usage: $(basename $0) {$(sed "s/ () /|/g; s/ ()$//g;" <<< $(declare -f | egrep "^[[:alpha:]][[:graph:]]+[[:space:]]\(\)"))} \$IPADDR/\$PREFIX\n"
}
#!/bin/bash
# reference
# https://gogs.io/docs/installation/install_from_source/
# https://linode.com/docs/development/version-control/install-gogs-on-debian/
# https://discuss.gogs.io/t/how-to-backup-restore-and-migrate/991/
# validate
sudo -v || exit 1