Skip to content

Instantly share code, notes, and snippets.

View ykhrustalev's full-sized avatar

Yuri Khrustalev ykhrustalev

View GitHub Profile
def makedirs(path)
cur_path = ''
path.split('/').each do |sub_directory|
cur_path = "#{cur_path}/#{sub_directory}"
Dir.mkdir(cur_path) unless File.directory?(cur_path)
end
end
@ykhrustalev
ykhrustalev / gfid-resolver.sh
Created May 24, 2016 14:04 — forked from louiszuckerman/gfid-resolver.sh
Glusterfs GFID Resolver Turns a GFID into a real path in the brick
#!/bin/bash
if [[ "$#" < "2" || "$#" > "3" ]]; then
cat <<END
Glusterfs GFID resolver -- turns a GFID into a real file path
Usage: $0 <brick-path> <gfid> [-q]
<brick-path> : the path to your glusterfs brick (required)
logger = None
def configure_loggging():
global logger
fmt = logging.Formatter(logging.BASIC_FORMAT)
stream = logging.StreamHandler()
stream.setLevel(logging.DEBUG)
stream.setFormatter(fmt)
#!/usr/bin/env python
import grp
import json
import logging
import optparse
import os
import pwd
import re
import subprocess
http://serverfault.com/a/316704/69170
netstat -ptu will give you the owning process ids (along with standard netstat info) for all tcp and udp conections. (Normal users will not be able to id all processes.)
If something is sending out a fair amount of constant traffic you should see it on Recv-Q or Send-Q columns 2 and 3 respectively.
Examples:
Recv-Q
sudo watch -n .1 'netstat -tup | grep -E "^[t,u]cp[6]{0,1}" | sort -nr -k2'
# source http://small-code.blogspot.ru/2008/05/nslookup-in-python.html
from socket import gethostbyaddr
def nslooky(ip):
try:
output = gethostbyaddr(ip)
return output[0]
except:
output = "not found"
return output
@ykhrustalev
ykhrustalev / gist:3899173
Created October 16, 2012 13:09
flush iptables
#!/bin/sh
echo "Flushing iptables rules..."
sleep 1
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT