Skip to content

Instantly share code, notes, and snippets.

View sawanoboly's full-sized avatar
🤷‍♂️
🙃

Yukihiko SAWANOBORI sawanoboly

🤷‍♂️
🙃
View GitHub Profile
@sawanoboly
sawanoboly / smartos_GrowthForecast.sh
Created June 4, 2012 05:10
Install GrowthForecast for smartos.
#!/usr/bin/bash
pkgin -y install scmgit tmux rrdtool gmake gcc-compiler
mkdir -p /usr/local/bin
curl -Lk http://xrl.us/cpanm -o /usr/local/bin/cpanm
chmod +x /usr/local/bin/cpanm
cd /usr/local
git clone https://github.com/kazeburo/GrowthForecast.git
@sawanoboly
sawanoboly / tcp_wait_push.rb
Created May 15, 2012 06:20
TCP Simple push2
require "socket"
require "time"
require "date"
gs = TCPServer.open(0, 20000)
socks = [gs]
addr = gs.addr
addr.shift
printf("server is on %s\n", addr.join(":"))
@sawanoboly
sawanoboly / tcp_push.rb
Created May 13, 2012 12:35
TCP Simple push
require "socket"
gs = TCPServer.open(0, 20000)
socks = [gs]
addr = gs.addr
addr.shift
printf("server is on %s\n", addr.join(":"))
while true
Thread.start(gs.accept) do |s|
@sawanoboly
sawanoboly / install.sh
Created April 12, 2012 02:10
Munin Plugin. "Check Number of Nagios3."
#!/usr/bin/env bash
curl -f -s https://raw.github.com/gist/2364272/f9a2cfd9bad80455d30ba5c9250db2a4aab6c8ea/monitoring_processes.sh -o /usr/local/bin/monitoring_processes
chmod +x /usr/local/bin/monitoring_processes
ln -f -s /usr/local/bin/monitoring_processes /etc/munin/plugins/
service munin-node reload
@sawanoboly
sawanoboly / github_toepoch.sh
Created April 9, 2012 02:27
Check last commit on Github.
#!/bin/bash
date -d `curl -s -f https://github.com/hissy/kobe-it-fes/commits/master.atom | grep -o -m 1 -E '<updated>.+</updated>' | sed s@\</*updated\>@@g | cut -c1-19` +%s
@sawanoboly
sawanoboly / etc_init.d_redis-server.sh
Created April 6, 2012 05:57
redis 2.4.x install
#!/bin/bash
cat >/etc/init.d/redis-server<<'EOFEOF'
#!/bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
#!/bin/bash
HOST=example.com
echo / | tr '\n' '\0' > httperf_list
wget -nv -r -l 1 http://$HOST/
find $HOST -type f | sed s@$HOST@@g | grep -v 'html$' | tr '\n' '\0' >> httperf_list
rm -rf $HOST
@sawanoboly
sawanoboly / install_pkg_func.sh
Created February 23, 2012 08:00
insatll packeage wrapper for SmartOS
# insatll packeage wrapper for SmartOS
# install function
install_pkg ()
{
echo -n "Installing $1... "
# RESULT=`pkgin -y install $1 | grep -xv "$1 is not available on the repository"`
RESULT=`pkgin -y install $1`
echo "$RESULT" | grep -x "$1 is not available on the repository" > /dev/null
if [ $? -eq 0 ]
@sawanoboly
sawanoboly / def_compare_yaml_hash.rb
Created February 20, 2012 07:03
config check for jenkins auto test.
def compare_yaml_hash(cf1, cf2, context = [])
case
when cf1.is_a?(Hash)
cf1.each do |key, value|
unless cf2.key?(key)
puts "Missing key : #{key} in path #{context.join(".")}"
raise "format error" #=> RuntimeError: format error
next
end
@sawanoboly
sawanoboly / compare_yaml_hash.rb
Created February 17, 2012 10:28
Compare keys in yaml files
def compare_yaml_hash(cf1, cf2, context = [])
case
when cf1.is_a?(Hash)
cf1.each do |key, value|
unless cf2.key?(key)
puts "Missing key : #{key} in path #{context.join(".")}"
next
end