Skip to content

Instantly share code, notes, and snippets.

View dalehamel's full-sized avatar

Dale Hamel dalehamel

View GitHub Profile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_libbcc is a Catch v1.4.0 host application.
Run with -? for options
-------------------------------------------------------------------------------
test bpf stack_id table
-------------------------------------------------------------------------------
/home/dale.hamel/workspace/bcc/tests/cc/test_bpf_table.cc:226
...............................................................................
#!/usr/bin/env ruby
require 'ruby-static-tracing'
DEBUG = ENV['DEBUG']
t = StaticTracing::Tracepoint.new('global', 'hello_nsec', Integer, String)
p = StaticTracing::Provider.fetch(t.provider)
p.enable
l = StaticTracing.nsec
Displaying notes found in: .note.ABI-tag
Owner Data size Description
GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag)
OS: Linux, ABI: 2.6.24
Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 2fda2cc264d59b38763507fa44cf79f94636aed2
@dalehamel
dalehamel / fetch-linux-headers.sh
Last active January 27, 2019 00:02
Fetch containeros linux headers
#!/bin/bash
LSB_FILE="/mnt/root/etc/lsb-release"
OS_RELEASE_FILE="/mnt/root/etc/os-release"
generate_headers()
{
echo "Generating kernel headers"
cd ${SOURCES_DIR}
zcat /proc/config.gz > .config
@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 / 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"