Skip to content

Instantly share code, notes, and snippets.

View dalehamel's full-sized avatar

Dale Hamel dalehamel

View GitHub Profile
@dalehamel
dalehamel / tcpacceptqsnoop.bt
Created November 24, 2018 01:44
Re-implement several tcp.* utils from iovisor/bcc in bpftrace (with some limitations)
#!/usr/bin/env bpftrace
/*
Watches for all ipv4 tcp accepts, displays:
- remote and local addresses of the accepted connection
- accept queue size and maximum
*/
#include <linux/tcp.h>
---
src/clang_parser.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/clang_parser.cpp b/src/clang_parser.cpp
index 6adb5f0..5b47555 100644
--- a/src/clang_parser.cpp
+++ b/src/clang_parser.cpp
@@ -221,10 +221,23 @@ void ClangParser::parse(ast::Program *program, StructMap &structs)
./bpftrace /usr/share/shopiftools/acceptqfull.bt | grep -i sock_common
Parsed: union sock_common::(anonymous at include/net/sock.h:155:2) parent: ident: skc_addrpair
Parsed: sock_common::(anonymous at include/net/sock.h:157:3) parent: ident: skc_daddr
Parsed: sock_common::(anonymous at include/net/sock.h:157:3) parent: ident: skc_rcv_saddr
Parsed: union sock_common::(anonymous at include/net/sock.h:162:2) parent: ident: skc_hash
Parsed: union sock_common::(anonymous at include/net/sock.h:162:2) parent: ident: skc_u16hashes
Parsed: union sock_common::(anonymous at include/net/sock.h:167:2) parent: ident: skc_portpair
Parsed: sock_common::(anonymous at include/net/sock.h:169:3) parent: ident: skc_dport
Parsed: sock_common::(anonymous at include/net/sock.h:169:3) parent: ident: skc_num
Parsed: sock_common parent: sock_common ident: skc_family
@dalehamel
dalehamel / ekexec
Created March 1, 2018 20:47
exec into eks container
#!/bin/bash
POD_ID=$1
NS_ID=$2
CONTAINER_NAME=$3
shift
shift
shift
container=$(kubectl get pod ${POD_ID} -n ${NS_ID} -o json | jq ".status.containerStatuses[] | select(.name == \"${CONTAINER_NAME}\") | .containerID" | sed -e 's/^"//' -e 's/"$//' | sed 's|docker://||g')
@dalehamel
dalehamel / eklogs
Last active March 1, 2018 20:40
eks container logs
#!/bin/bash
POD_ID=$1
NS_ID=$2
CONTAINER_NAME=$3
container=$(kubectl get pod ${POD_ID} -n ${NS_ID} -o json | jq ".status.containerStatuses[] | select(.name == \"${CONTAINER_NAME}\") | .containerID" | sed -e 's/^"//' -e 's/"$//' | sed 's|docker://||g')
echo "Container ID is ${container}"
@dalehamel
dalehamel / Setup minikube on OS X
Last active February 7, 2017 02:40
Minikube init
curl https://storage.googleapis.com/minikube/releases/v0.16.0/minikube-darwin-amd64 > minikube
chmod +x minikube
# https://github.com/kubernetes/minikube/blob/v0.16.0/DRIVERS.md#kvm-driver
# Xhyve is a lot less shit to deal with than virtualbox.
# you might get a panic if you have virtualbox < version 5, if so just upgrade.
brew install docker-machine-driver-xhyve
# Note: this is needed because there's no other way for xhyve to get networknig to work (see xhyve repo's issues)
@dalehamel
dalehamel / snmp-trap-enable
Created June 17, 2016 04:56
Enable snmp traps on supermicro ipmi
# Enable SNMP
USER=
PASS=
IPMI_HOST=
TARGET=127.0.0.1
INDEX=1 # one indexed alert to set
SESSION_ID=$(curl -d "name=${USER}&pwd=${PASS}" "https://${IPMI_HOST}/cgi/login.cgi" --silent --insecure -i | awk '/Set-Cookie/ && NR != 2 { print $2 }')
# Severity ->
@dalehamel
dalehamel / smt-snmp-ipmi.sh
Created June 16, 2016 15:49
enable snmp via web interface hack for supermircro
# Enable SNMP
USER=
PASS=
IPMI_HOST=
SESSION_ID=$(curl -d "name=${USER}&pwd=${PASS}" "https://${IPMI_HOST}/cgi/login.cgi" --silent --insecure -i | awk '/Set-Cookie/ && NR != 2 { print $2 }')
curl -X POST -H "Cookie: ${SESSION_ID}" --insecure "https://${IPMI_HOST}/cgi/op.cgi" -d "&op=config_snmp&en_snmp=on&ver_snmp=v2&rocommunity=public&rwcommunity=public"
@dalehamel
dalehamel / scrape.sh
Created June 11, 2016 02:19
Supermicro iKVM preview scraper
USER=
PASS=
IPMI_HOST=
SESSION_ID=$(curl -d "name=${USER}&pwd=${PASS}" "https://${IPMI_HOST}/cgi/login.cgi" --silent --insecure -i | awk '/Set-Cookie/ && NR != 2 { print $2 }')
ipmi_scrape()
{
curl -H "Cookie: ${SESSION_ID}" --insecure "https://${IPMI_HOST}/$1"
}
time=$(ruby -e 'require "time"; require "uri"; puts URI.escape Time.now.httpdate.gsub(",", "")')
@dalehamel
dalehamel / .kitchen-docker.yml
Last active June 1, 2016 21:29
docker test kitchen for runit
driver:
name: docker
use_sudo: false # this depends if you need to do `sudo` to run `docker` command or not
disable_upstart: false
run_command: /sbin/init
provisioner:
name: chef_zero
platforms: