Skip to content

Instantly share code, notes, and snippets.

View amuraru's full-sized avatar
:octocat:
Focusing

Adrian Muraru amuraru

:octocat:
Focusing
View GitHub Profile
@amuraru
amuraru / install_thrift.sh
Last active August 22, 2019 08:40 — forked from tscurtu/gist:3033705
install thrift 0.8.0
#/bin/bash
set -e
wget http://archive.apache.org/dist/thrift/0.8.0/thrift-0.8.0.tar.gz
tar zxf thrift-0.8.0.tar.gz
pushd thrift-0.8.0
wget https://issues.apache.org/jira/secure/attachment/12511532/thrift-1465_1.patch
patch -p0 < thrift-1465_1.patch
wget https://issues.apache.org/jira/secure/attachment/12537024/THRIFT-1474-read-exceptions-first.patch
@amuraru
amuraru / project.clj
Created September 25, 2012 20:35
lein dynamic system dependency
lein dynamic system dependency:
[org.zeromq/jzmq "1.1.0" :classifier ~(str "native-" (System/getProperty "os.arch") "-" (System/getProperty "os.name")) ]
@amuraru
amuraru / sudoers nagios
Created February 14, 2013 00:14
Allow nagios user to run hadoop/hbase commands through nrpe
Defaults:nagios !requiretty
Cmnd_Alias HSTACK = /home/hadoop/hadoop/bin/hadoop fsck *, /home/hadoop/hbase/bin/hbase hbck *
nagios ALL=(hadoop) NOPASSWD: HSTACK
@amuraru
amuraru / valgrind - instrument loop
Last active December 15, 2015 21:39
valgrid check-memory leaks infinite loop
#include <valgrind/memcheck.h>
...
while(1) {
VALGRIND_DO_LEAK_CHECK;
...
}
@amuraru
amuraru / limit-nofiles-process
Created May 12, 2013 14:25
Modify process limits at runtime
pgrep -f mongrel-aps | while read pid; do echo -n 'Max open files=65536:65536' > /proc/$pid/limits; done
#!/bin/bash
if [[ "$1" == eth* ]]; then
echo "this part will be executed right after an interface is up."
# find out the ip
IP=$( ifconfig | grep "inet " | head -n 1 | awk '{print $2}' | awk 'BEGIN {FS = ":"} ; {print $2}' )
# delete the existing lines in the file
FQDN=`hostname`
HOSTNAME=`hostname -s`
sed -i "/${HOSTNAME}/d" /etc/hosts
@amuraru
amuraru / check_cpu_stats
Last active December 18, 2015 22:29
Nagios check for CPU usage
#!/bin/bash
# CPU usage check
IOSTAT=/usr/bin/iostat
# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
from socket import socket
import sys
def readlines(sock, recv_buffer=4096, delim='\n', wait=False):
buffer = ''
data = True
while data:
data = sock.recv(recv_buffer)
buffer += data
@amuraru
amuraru / ss-port-query
Created October 20, 2013 00:04
Watch socket queues
watch "ss -n -o state established '( dport = :25001 )' | sort -k3"
@amuraru
amuraru / ss watch sockets.sh
Last active December 26, 2015 03:59
Watch all connections from a load balancer to a pool of servers (check for connection persistence)
watch -n 0.02 "ss -nn state established '( sport >= :8081 and sport <= :8088 )' src `ifconfig | grep inet | sed 's/\s\+/:/g' |cut -f4 -d':' | head -1` dst 10.15.204.0/24 | sed 's/\s\+/ /g' | cut -f 3-6 -d' ' | sort -t ':' -k3 -n"
watch -n 2 "ss -nn state established '( sport = :80 )' src `ifconfig | grep inet | sed 's/\s\+/:/g' |cut -f4 -d':' | head -1` | sed 's/\s\+/ /g' | cut -f 3-6 -d' ' | sort -t ':' -k3 -n"