Skip to content

Instantly share code, notes, and snippets.

# yum install glibc-static
# yum install ncurses-static
LOCALHOME=${HOME}/usr/opt
mkdir -p ${LOCALHOME}
cd ${LOCALHOME}
# Get tmux
wget http://downloads.sourceforge.net/tmux/tmux-1.9a.tar.gz
cat /vol2/home/bounce/opwv_pac/lg_smpl/log/smtp_smpl_1/smtp_128.stat | sed -E "s/^\t([^\t ]+)(( [^\s]+){0,})\t\s*/\t\1 /; s/ {1,}/ /g;" | sed -E ":a;N;s/\n\t/ /;t a;P;D" | sed -E "s/^(....)(..)(..) (..)(..)(.)..*\) /\1-\2-\3T\4:\5:\60 /; s/[][] ?/ /g;"
for f in $(ls *stats); do cat ${f} | sed -E "s/^\t([^\t ]+)(( [^\s]+){0,})\t\s*/\t\1 /; s/ {1,}/ /g;" | sed -E ":a;N;s/\n\t/ /;t a;P;D" | sed -E "s/^(....)(..)(..) (..)(..)(.)..*\) /\1-\2-\3T\4:\5:\60 /; s/[][] ?/ /g;" > ${f}.csv; done
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other
# stuff too? No support for SuperColumns, but that should be easy enough to add.
import bisect
import copy
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn
class SSTable(object):
site packageの場所
```
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
```
@aminamid
aminamid / gist:12b6a970a3381f1b7c6c
Last active August 29, 2015 14:20
Mx operation 1liner
D=${INTERMAIL}/log; diff <(find ${D}/. -type l -exec readlink {} \; | sort | uniq -u) <(find ${D}/. -type f -exec basename {} \; | sort | uniq -u) | sed -n -E 's#^> (.*)$#'${D}'/\1#p' | xargs rm
5,15,25,35,45,55 * * * * bash -l -c "~/mxlogdel.sh 2>&1 | logger -t mxlogdel -p local0.info "
tcpdump -i <IF> -G <rotation seconds> -W <rotation num> -w /tmp/tcpdump_%Y%m%d_%H%M%S.cap host <src ip> and host <dst ip> and port <dst port>
echo 1 > /proc/sys/net/ipv4/ip_forward
smtp_ip='192.168.100.1'
smtp_port='25'
smtp_port1='12125'
smtp_port2='12225'
smtp_port3='12325'
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -t mangle -F
iptables -t mangle -A PREROUTING -p tcp -d $smtp_ip --dport $smtp_port -m state --state NEW -m statistic --mode nth --every 3 --packet 0 -j CONNMARK --set-mark 1
@aminamid
aminamid / gist:98809e7ca0b9ba64e41c
Last active August 29, 2015 14:18
pstack one liner
sed -e ":a;N;s/\(abc\)\n\(def\)/\1\2/;t a;P;D"
sed -e ":a;N;s/\n\([^T].*\) .* in \(.*\)/ \2/;t a;P;D" | sed "s/Thread .* (Thread .* (LWP \(.*\))): \(.*\)/\1 \2/; s/ from [^ ]*\($\| \)/ /g; s/@@GLIBC[^ ]*//g; s/ ()\($\| \)/--/g; s/([^)]*)/()/g; s/ \[[^]]\+\]/\[\]/g; s/<[^<>]*>/<>/g; s/<\([^<>]*<>[^<>]*\)\{1,\}>/<<>>/g; s/<\([^<>]*<<>>[^<>]*\)\{1,\}>/<<<>>>/g; s/<\([^<>]*<<<>>>[^<>]*\)\{1,\}>/<<<<>>>>/g; s/ /-/2g " | awk '{print $2}' | sort | uniq -c | sort -nk1
pstack 26459 | sed -e ":a;N;s/\n\([^T].*\) .* in \(.*\)/ \2/;t a;P;D" | sed "s/Thread .* (Thread .* (LWP \(.*\))): \(.*\)/\1 \2/; s/ from [^ ]*\($\| \)/ /g; s/@@GLIBC[^ ]*//g; s/ ()\($\| \)/--/g; s/([^)]*)/()/g; s/ \[[^]]\+\]/\[\]/g; s/<[^<>]*>/{}/g; s/<[^<>]*>/{}/g; s/<[^<>]*>/{}/g;s/<[^<>]*>/{}/g;s/{}/<>/g; s/ /-/2g " | awk '{print $2}' |
sort | uniq -c | sort -nk1
pstack $(pgrep mta) | sed -e ":a;N;s/\n\([^T].*\) .* in \(.*\)/ \2/;t a;P;D" | sed -e "s/Thread .* (Thread .* (LWP \(.*\))): \(.*\)/\1 \2/; s/ from [^ ]*\($\| \)/ /g; s/@@GLIBC[^ ]*
@aminamid
aminamid / gist:6061c596761b6c6b6c5f
Last active August 29, 2015 14:18
which process use each cpu onliner
while true ; do echo -e "\033[H\033[J"; ps -A -L -o pid,tid,psr,pcpu,comm= | grep -v PSR | awk '{sum[$3" "$1" "$5]+=$4};END { for (key in sum) {print key,sum[key]}}' | sort -nk1 | column -t | grep -v " 0$" ; sleep 1 ; done
while true; do NOW=$(date "+%Y-%m-%dT%H:%M:%S"); ps -A -L -o pid,tid,psr,pcpu,comm= | grep -v PSR | awk '{sum[$3" "$1" "$5]+=$4};END { for (key in sum) {print key,sum[key]}}' | sort -nk1 | column -t | grep -v " 0$" | awk '{ print "'${NOW}'", $0; fflush() }' ; sleep 2 ; echo ; done
pidstat -I -u -t -d -p ALL 3 65535 | grep -v -e " 0.00 0.00 0.00 " -e " 0.00 0.00 0.00 0.00 "
@aminamid
aminamid / gist:ee0ec2697a91a3ea00e9
Last active August 29, 2015 14:18
cpu usage per cpu per pid
#!/bin/bash
# from stackoverflow http://stackoverflow.com/questions/3342889/how-to-measure-separate-cpu-core-usage-for-a-process
# Note: These stats are based on process lifetime, not the last X seconds, so
# you'll need to restart your process to reset the counter.
pids=()
while [ $# != 0 ]; do
pids=("${pids[@]}" "$1")
shift
done