Skip to content

Instantly share code, notes, and snippets.

View bageljp's full-sized avatar

Keisuke Kadoyama bageljp

  • Tokyo, Japan
  • 15:21 (UTC +09:00)
  • X @bageljp
View GitHub Profile
@bageljp
bageljp / knife_base.bash
Last active April 22, 2022 10:58
knife command parallel exec in hosts
#!/bin/bash
SH_KNIFE="/usr/local/chef/chef-repo/knife_parallel.bash"
LOG_FILE="/usr/local/chef/chef-repo/knife_base.log"
func_usage() {
echo "Usage: `basename $0` {bootstrap|prepare|cook}"
return 0
}
@bageljp
bageljp / add_permission.py
Created July 9, 2016 17:04
Add permissions AWS Lambda Function with API Gateway
# encoding=utf-8
import argparse
import boto3
import os
import sys
import json
from datetime import datetime
import re
import uuid
@bageljp
bageljp / unicorn
Created July 21, 2013 09:35
unicorn init script with rbenv and bundler.
#!/bin/sh
#
# unicorn
#
# chkconfig: - 80 20
# description: unicorn
# processname: unicorn
# config: /usr/local/redmine/config/unicorn.rb
# pidfile: /usr/local/redmine/tmp/pids/.pid
@bageljp
bageljp / accesslog_count.bash
Last active October 9, 2019 21:59
access_log parse.
#!/bin/bash
LOG_FILE="access_log-20130310"
for i in `seq 4 1 23`; do
hour=`printf "%02d" ${i}`
# sourceIp
grep "09/Mar/2013:${hour}" ${LOG_FILE} | awk '{print $1}' | sort | uniq -c | sort -r > ip-${hour}.log
# url
grep "09/Mar/2013:${hour}" ${LOG_FILE} | awk '{print $7}' | sort | uniq -c | sort -r > url-${hour}.log
# 'host-notify-by-jabber' command
define command{
command_name host-notify-by-jabber
command_line /usr/bin/perl $USER1$/notify_via_jabber.pl $CONTACTPAGER$ "`/usr/bin/printf \"***** Nagios *****\nHost '$HOSTALIAS$' is $HOSTSTATE$ - Info: $HOSTOUTPUT$\"`"
}
# 'host-notify-by-jabber' command to groupchat
define command{
command_name host-notify-by-jabber-groupchat
command_line /usr/bin/perl $USER1$/notify_via_jabber.pl $CONTACTPAGER$ "`/usr/bin/printf \"***** Nagios *****\nHost '$HOSTALIAS$' is $HOSTSTATE$ - Info: $HOSTOUTPUT$\"`" groupchat
@bageljp
bageljp / fish_prompt.fish
Created January 4, 2019 12:11
fish_prompt with k8s ctx and ns
$ diff ~/.config/fisherman/bobthefish/fish_prompt.fish ~/.config/fisherman/bobthefish/fish_prompt.fish.org Fri Jan 4 21:11:16 2019
509,516c509
< # Customize: START
< set -l ctx (string trim -c '"\' ' -- $val)
< set -l ns (kubectl config view -o "jsonpath={.contexts[?(@.name==\"$ctx\")].context.namespace}")
< [ -z $ns ]; and set -l ns 'default'
< set -l context "$ctx/$ns"
< # Customize: END
<
< #set -l context (string trim -c '"\' ' -- $val)
@bageljp
bageljp / README.md
Created May 4, 2018 14:19
nginx_maintenance_user_id
  • POSTのbodyの中にuser_idというパラメータが含まれており、そのuser_idが特定の値(この例だと1000,2000,5000)の場合のみリクエストを許可
  • それ以外はメンテナンスを返す
@bageljp
bageljp / sigV4Client.js (2016-05-30)
Created July 30, 2016 08:30
ApiGateway SDK encoding (RFC3986 Non-reserved character)
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
@bageljp
bageljp / install
Created November 3, 2013 11:03
nagios on Mac OS X 10.8.3
[user1@canal-mac01 19:58:46 log][315][20]$ brew install nagios
Warning: Your Xcode (4.6.3) is outdated
Please update to Xcode 5.0.1.
Xcode can be updated from the App Store.
==> Installing dependencies for nagios: libpng, jpeg, gd, nagios-plugins
==> Installing nagios dependency: libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.5.14.mountain_lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.5.14.mountain_lion.bottle.tar.gz
🍺 /usr/local/Cellar/libpng/1.5.14: 15 files, 1.0M
@bageljp
bageljp / pssh_command.bash
Created October 13, 2013 11:37
pssh command in hosts
#!/bin/bash
func_usage() {
echo "Usage: `basename $0` {role} {command}"
return 0
}
if [ $# -lt 2 ]; then
func_usage
exit 1