Skip to content

Instantly share code, notes, and snippets.

@wakwanza
wakwanza / consul.ini
Last active December 6, 2016 09:29
supervisord script for consul
[program:consul]
command=/usr/local/bin/consul agent -config-dir=/etc/consul.d/client
stopsignal=INT
user=consul
stdout_logfile=/var/log/consul.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
autostart=true
autorestart=true
@wakwanza
wakwanza / supervisord
Last active December 14, 2016 13:13
Supervisord init.d script
#!/bin/sh
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
@wakwanza
wakwanza / supervisord.conf
Last active October 24, 2016 11:55
Suprvisord config file
[unix_http_server]
file=/var/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
minfds = 1024
minprocs = 200
loglevel = info
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
nodaemon = false
@wakwanza
wakwanza / proxysqlglobals
Last active September 22, 2016 11:55
proxysql global vars
+----------------------------------------+-----------------------------------------------------------------------+
| variable_name | variable_value |
+----------------------------------------+-----------------------------------------------------------------------+
| admin-stats_credentials | stats:stats |
| admin-telnet_admin_ifaces | (null) |
| admin-telnet_stats_ifaces | (null) |
| admin-refresh_interval | 2000 |
| admin-read_only | false |
| admin-version | 1.2.2
@wakwanza
wakwanza / mtq.py
Created April 11, 2015 21:23
Mersienne Twister with quantum random seed
from __future__ import absolute_import
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import repeat
from math import fmod
import quantumrandom
try:
range = xrange
except NameError:
@wakwanza
wakwanza / setnat.sh
Created April 5, 2015 12:16
Create NAT route on GCE
#!/bin/bash
#
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT
sudo service iptables save
sudo sed -i 's/.*net.ipv4.ip_forward = 0*/net.ipv4.ip_forward = 1/' /etc/sysctl.conf
sudo sysctl -e -p /etc/sysctl.conf
sudo service iptables restart
@wakwanza
wakwanza / mountformat.sh
Created April 5, 2015 12:16
Mount and format disk on Google Compute Engine
#!/bin/bash
# Mount and format the disks
sudo mkdir -p /data
sudo yum install xfsprogs -y
sudo /usr/share/google/safe_format_and_mount -m "mkfs.xfs -isize=512" /dev/sdb /data
sudo echo "Mount persists"
sudo sh -c "echo \"/dev/sdb /data xfs noatime,data=writeback,errors=remount-ro 0 1\" >> /etc/fstab"
sudo echo "fstab done"
@wakwanza
wakwanza / archivelogs.sh
Created April 5, 2015 11:57
log backup script for nginx and fail2ban
#!/bin/bash
BackupDir=logbackup
HomeDir=/archive/$HOSTNAME
# Set $BackupYear equal to 4 characters of $f starting with the first character, the YYYY
BackupYear=$(date +"%Y")
# Set $BackupMonth equal to 2 characters of $f starting with the fifth character, the MM
BackupMonth=$(date +"%m")
# Test to see if the main backup directory exists if not then create it
if [ ! -d $HomeDir/$BackupDir ]; then
@wakwanza
wakwanza / builds3fuse.sh
Created April 2, 2015 07:21
Build latest fuse and s3fs-fuse module for Google Cloud Storage and AWS S3 , Centos6
#!/bin/sh
#
function compile_bin { ./configure --prefix=/usr; make && make install; wait 3; }
function download_untar { wget -O - "http://downloads.sourceforge.net/fuse/fuse-2.9.3.tar.gz" | tar -xzvf - ; wget -O - "https://github.com/s3fs-fuse/s3fs-fuse/archive/v1.78.tar.gz" | tar -xzvf - ; }
echo "Build the S3 fuse with native binaries"
download_untar
#
cd fuse-2.9.3
compile_bin
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
@wakwanza
wakwanza / extern.py
Created March 26, 2015 23:59
shlex and subprocess Popen in python to execute external command and get return code plus result.
#!/usr/bin/python
import subprocess, sys, shlex
def main(argv):
args = shlex.split(argv)
op = subprocess.Popen(args,stdout=subprocess.PIPE)
result, err = op.communicate()
op.wait()
tw = op.returncode
# Use the result , error and return code here for extra processing