- High-performance Linux monitoring with eBPF
- Netdev 1.2 - eBPF Offload to Hardware: cls_bpf and XDP - Nick Viljoen, Jakub Kicinski
- Alex Gartrell Executing python functions in the linux kernel by transpiling to bpf PyCon 2017
- Transparent eBPF Offload: Playing Nice with the Linux Kernel
- Golang bcc/BPF Function Tracing
- Go bindings for creating BPF programs
- eBPF program using kprobes to trace TCP events without run-time compilation dependencies
- BPF: Tracing and More
- Give me 15 minutes and I'll change your view of Linux tracing
- [Infrastructure 2017 - Alfo
apt-get -y install ngrep tcpflow httpry scapy tshark
httpry
ngrep -l -q -d eth0 "^GET|^POST " tcp and port 80
tcpflow -p -c -i eth0 port 80 | grep -oE '(GET|POST|HEAD) .* HTTP/1.[01]|Host: .*'
tcpdump -s 0 -A 'tcp dst port 80 and (tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x504f5354)'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find packages that depend on PACKAGE | |
apt-cache rdepends PACKAGE | |
# Find packages that PACKAGE depends on | |
apt-cache depends PACKAGE | |
# Find packages that provide FILE | |
dpkg -S FILE | |
apt-file find FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by https://stackoverflow.com/questions/10644925/randomly-interleave-2-arrays-in-python | |
def mix_with_ratio(a, b, ratio): | |
c = [] | |
while a and b: | |
which_list = random.random() | |
if which_list < ratio: | |
c.append(a.pop(0)) | |
else: | |
c.append(b.pop(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks | |
def chunks(l, n): | |
"""Yield successive n-sized chunks from l.""" | |
for i in xrange(0, len(l), n): | |
yield l[i:i + n] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TimeoutError(Exception): | |
pass | |
class timeout: | |
def __init__(self, seconds=1, error_message='Timeout'): | |
self.seconds = seconds | |
self.error_message = error_message | |
def handle_timeout(self, signum, frame): | |
raise TimeoutError(self.error_message) | |
def __enter__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def RateLimited(maxPerSecond): | |
minInterval = 1.0 / float(maxPerSecond) | |
def decorate(func): | |
lastTimeCalled = [0.0] | |
def rateLimitedFunction(*args,**kargs): | |
elapsed = time.clock() - lastTimeCalled[0] | |
leftToWait = minInterval - elapsed | |
if leftToWait>0: | |
time.sleep(leftToWait) | |
ret = func(*args,**kargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type A interface { | |
Set(string) error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# myapp daemon | |
# chkconfig: 345 20 80 | |
# description: myapp daemon | |
# processname: myapp | |
DAEMON_PATH="/home/wes" | |
DAEMON=myapp | |
DAEMONOPTS="-my opts" |