Skip to content

Instantly share code, notes, and snippets.

Avatar

Dale Hamel dalehamel

View GitHub Profile
@dalehamel
dalehamel / snmp-trap-enable
Created June 17, 2016 04:56
Enable snmp traps on supermicro ipmi
View snmp-trap-enable
# 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 / repack.sh
Created October 2, 2021 16:52
Repack OpenPHT images to update certificate authority
View repack.sh
#!/bin/bash
set -e
echo "Checking required dependencies..."
which wget >& /dev/null
which parted >& /dev/null
which mksquashfs >& /dev/null
which unsquashfs >& /dev/null
@dalehamel
dalehamel / test patch
Created July 26, 2021 14:08
Test rbspy patch
View test patch
---
src/core/initialize.rs | 17 +++++++++++++++++
src/main.rs | 4 ++++
2 files changed, 21 insertions(+)
diff --git a/src/core/initialize.rs b/src/core/initialize.rs
index c6bed8b..2ea1b2e 100644
--- a/src/core/initialize.rs
+++ b/src/core/initialize.rs
@@ -92,10 +92,18 @@ impl StackTraceGetter {
@dalehamel
dalehamel / gmailstats.gs
Last active November 16, 2020 20:52
Basic Gmail statistics
View gmailstats.gs
// To load this script, open a Google Sheet (yeah, weird I know), then select "Tools->Script Editor"
// From there, past this content into a script. You can set up triggers to run this script every day at a certain time
// by selecting Resources -> Triggers.
// I recommend you set the trigger to every 5-10 minutes. This will let the batches complete. If the trigger is too infrequent, it wont have time to finish.
// https://developers.google.com/apps-script/reference/gmail/
// For large inboxes (the ones you want to analyze) gmail will rate limit you.
// They recommend adding a sleep to call less, but then your exec time will be too long.
// To solve this, we run in batches. This is the batch size. Decrease this if exec time is too long.
View 0001-Pull-patch-onto-1.17.8-drop-systemtap-specifics.patch
From d75537062f1f72b8dc6115f1960d6f56a47c3793 Mon Sep 17 00:00:00 2001
From: Dale Hamel <dale.hamel@shopify.com>
Date: Tue, 10 Mar 2020 18:46:03 -0400
Subject: [PATCH] Pull patch onto 1.17.8, drop systemtap specifics
---
README | 17 +++++++-
auto/make | 43 ++++++++++++++++++
auto/modules | 3 +-
auto/options | 11 ++++-
@dalehamel
dalehamel / gist:782cbbb9f343c48a112f
Last active March 10, 2020 22:30
Convert /etc/fstab to use UUID's for any matching /dev/sd* device.
View gist:782cbbb9f343c48a112f
#!/bin/bash
cp /etc/fstab /etc/fstab.bak
while read line; do
drive=$(echo $line | awk '{print $1}')
if [[ $drive =~ /dev/sd.* ]];then
uuid=$(blkid | grep $drive | sed 's/.*\sUUID="\([a-zA-Z0-9-]*\)".*/\1/g')
sed -i "s:$drive:UUID=$uuid:g" /etc/fstab
fi
done < /etc/fstab
@dalehamel
dalehamel / mcsnopp.bt
Created March 10, 2020 01:47
bpftrace script to attach to memcached and probe connections and commands
View mcsnopp.bt
usdt::memcached:command__get,
usdt::memcached:command__set,
usdt::memcached:command__add,
usdt::memcached:command__replace,
usdt::memcached:command__prepend,
usdt::memcached:command__append,
usdt::memcached:command__cas
{
@calls[str(arg1, arg2)]++;
@bytes[str(arg1, arg2)]+= arg3;
@dalehamel
dalehamel / simple_epoll_inotify_test.c
Created February 7, 2020 19:56
Test inotify on memfd with epoll api
View simple_epoll_inotify_test.c
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@dalehamel
dalehamel / simple_epoll_inotify_test.c
Created February 7, 2020 19:56
Test inotify on memfd with epoll api
View simple_epoll_inotify_test.c
#include <stdio.h>
#include <sys/inotify.h>
#include <sys/time.h>
#include <sys/epoll.h>
#include <errno.h>
#include <linux/memfd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
@dalehamel
dalehamel / docker-desktop-headers.sh
Last active February 6, 2020 20:13
install kernel headers for docker desktop, for BCC
View docker-desktop-headers.sh
#!/bin/bash
set -x
set -e
KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}"
kernel_version="$(echo "${KERNEL_VERSION}" | awk -vFS=- '{ print $1 }')"
major_version="$(echo "${KERNEL_VERSION}" | awk -vFS=. '{ print $1 }')"
apt-get install -y build-essential bc curl flex bison libelf-dev