Skip to content

Instantly share code, notes, and snippets.

View gerhard's full-sized avatar

Gerhard Lazu gerhard

View GitHub Profile
root@freetunes:/tmp# vgcfgrestore --file /etc/lvm/backup/lvm-raid lvm-raid
Restored volume group lvm-raid
root@freetunes:/tmp# vgchange -ay
1 logical volume(s) in volume group "lvm-raid" now active
root@freetunes:/tmp# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lvm0 lvm-raid -wi-a- 5.46t
root@freetunes:/tmp# e2fsck /dev/lvm-raid/lvm0
e2fsck 1.41.11 (14-Mar-2010)
e2fsck: Superblock invalid, trying backup blocks...
@gerhard
gerhard / out.sh
Created June 20, 2012 10:37
git ssh authentication fails even if ssh key is present
Calista ➜ dashboard git:(master) ssh dashboard@nodejs-3 "cd app && git submodule update"
Initialized empty Git repository in /home/dashboard/app/assets/_lib/d3/.git/
Host key verification failed.
fatal: The remote end hung up unexpectedly
Clone of '[email protected]:gosquared/d3' into submodule path 'assets/_lib/d3' failed
Calista ➜ dashboard git:(master) ssh dashboard@nodejs-3 "ssh-keygen -F github.com -f ~/.ssh/known-hosts | head -1"
# Host github.com found: line 1 type RSA
@gerhard
gerhard / shell.sh
Created June 14, 2012 11:59
nginx upstream fail_timeout not respected
$ time curl -I "$uri" &> /dev/null
# when routed to the host that is up
curl -I "$uri" &> /dev/null 0.00s user 0.00s system 2% cpu 0.299 total
# when routed to the host that is down. Should this be ~3s as per fail_timeout & max_fails?
curl -I "$uri" &> /dev/null 0.00s user 0.00s system 0% cpu 21.304 total
@gerhard
gerhard / pmacctd.conf
Created June 14, 2012 11:21
TCP port traffic monitoring
! pmacctd configuration
!
!
!
daemonize: true
pidfile: /var/run/pmacctd.pid
syslog: daemon
!
! interested in in and outbound traffic
aggregate: src_host,src_port,dst_host,dst_port
if [ $(ls | grep -c "backup.*tgz") > 0 ]
then
unless folder _purge exists; do
mkdir _purge
done
mv backup*tgz _purge
mv backup*md5 _purge
fi
@gerhard
gerhard / parallelize.sh
Created June 8, 2012 02:03
Parallelize
__parallelize() {
local _task="$1"
local _hosts="${2:-"$SERVERS_APP_USER"}"
background_task_pids=()
background_tasks=()
for _host in $_hosts
do
( eval "$_task" ) &
@gerhard
gerhard / output.sh
Created June 5, 2012 00:32
bash ssh exit status
Calista ➜ deliver git:(multi-server) ✗ multi
/usr/local/bin/parallel
FAILED!
@gerhard
gerhard / em_test.rb
Created May 30, 2012 23:38
EM with Redis tests
def em(redis_url=REDIS_URL, &block)
EM.run do
redis = EM::Hiredis.connect(redis_url)
block.call(redis)
end
end
# ...
# fluffyness
# ...
@gerhard
gerhard / dashboard.foo.com.conf
Created May 30, 2012 12:18
nginx multiple proxies
server {
listen 80;
server_name dashboard.foo.com;
upstream dashboard_backend {
server 11.11.12.40:5000 max_fails=3 fail_timeout=1s;
}
location /{
proxy_set_header X-Forwarded-Proto $scheme;
@gerhard
gerhard / botnet-apache-proxy-blocker.sh
Created May 28, 2012 23:17
How to stop a botnet attack exploiting Apache ProxyRequests
#!/usr/bin/env sh
tail -f /var/log/apache2/gosquared*access.log | awk '
BEGIN { blocked_ips="" }
/ http/ {
if (! index(blocked_ips, $1)) {
// append this ip to our internal blocked_ips list
blocked_ips = blocked_ips " " $1
"date" | getline current_time