Skip to content

Instantly share code, notes, and snippets.

View dalehamel's full-sized avatar

Dale Hamel dalehamel

View GitHub Profile
@dalehamel
dalehamel / gist:782cbbb9f343c48a112f
Last active March 10, 2020 22:30
Convert /etc/fstab to use UUID's for any matching /dev/sd* device.
#!/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 / gist:5528d054d3ad4035f06a
Last active August 29, 2015 14:11
Hadoop root drive swap
#!/bin/bash
set -x # verbosity
# This script is meant to be run from inside alchemy linux, our PXE rescue system.
# To boot into alchemy, connect to a serial console with ipmitool sol activate, and set the bootdev with 'chassis bootdev pxe'
# The default user:pass is alchemy:transmute
# This script covers swapping out the OS drive of a hadoop node, and is very coupled to this task. The individual sections however may be reused.
# This script should never be run without being watched, and should never be run all at once. Run each section on its own. Ye be warned.
# The first step is to pick a data drive to remove. We'll need to find out the serial for that drive. The only mapping between the physical and logical here is done through "megaraid target id's", which map to the scsi sub slot. Sound confusing? Don't worry, that's because it is, so we'll confuse it more by using the folliwng magical regex:
@dalehamel
dalehamel / gist:88f041647188af123511
Created January 5, 2015 20:40
Datadog Snapshot poll
checklength = (url) ->
robot.http(result['snapshot_url']).get() (err,res,body) ->
size = res['headers']['content-length']
checklength url unless size > 1000
if size > 1000
setTimeout ->
msg.send "Here's your graph for #{dash} #{graph}, #{msg.message.user.name}: #{result['snapshot_url']}"
, 3000
@dalehamel
dalehamel / gist:ce9bfe7c8a2f4addb03a
Last active August 29, 2015 14:13
Victorops coffeescript WIP
# Description:
# This script can be used to interact with VictorOps schedules, and page VictorOps teams
#
# Configuration:
# HUBOT_VICTOROPS_USER - The username of the hubot user in the VictorOps org
# HUBOT_VICTOROPS_PASS - The password of the hubot user in the VictorOps org
# HUBOT_VICTOROPS_REST - The API token to use
# Commands:
# hubot oncall - Lists the teams you can check (working)
@dalehamel
dalehamel / gist:629f41bdcb8c0627f985
Last active August 29, 2015 14:13
Hubot Datadog WIP
# Description:
# Query Datadog using Hubot.
#
# Configuration:
# HUBOT_DATADOG_APIKEY - Your Datadog API key
#  HUBOT_DATADOG_APPKEY - Your Datadog app Key
#
# Commands:
# opsbot (datadog|dd|dog|graph) [dashboard] [graph] - snapshot a specific graph from a dashboard that you've already told hubot about.
# opsbot (datadog|dd|dog) graphs - Show the available graphs
# Update glibc to your systems recommended patched version first
# As root, run this. If you're system is ok, you'll see nothing. Otherwise, this will tell you all infected processes.
for proc in $(ls /proc); do if [ -e /proc/$proc/maps ];then if [ -n "`cat /proc/$proc/maps | grep -i libc- | grep -i deleted`" ];then echo $proc; echo "CMDLINE"; cat /proc/$proc/cmdline; echo -e "CMDLINE\n"; cat /proc/$proc/maps | grep -i libc- | grep -i deleted; fi fi done
rasplex Version: 0.5.1
rasplex git: 55113f6ddae290c431fdf96171c28c1778fbe1ff
RasPlex:~ $ ls
lost+found
RasPlex:~ $ cd /flash/overlays/
RasPlex:/flash/overlays $ ls
README.TXT hifiberry-dac-overlay.dtb iqaudio-dac-overlay.dtb pcf2127-rtc-overlay.dtb w1-gpio-overlay.dtb
ds1307-rtc-overlay.dtb hifiberry-dacplus-overlay.dtb iqaudio-dacplus-overlay.dtb pcf8523-rtc-overlay.dtb w1-gpio-pullup-overlay.dtb
hifiberry-amp-overlay.dtb hifiberry-digi-overlay.dtb lirc-rpi-overlay.dtb pps-gpio-overlay.dtb
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCd9MR4lTtEreJqyXWjVRxxMzYMUxYTLr0PMDkY52BgiBVHL+JY8Pbx7hcEaSkd9wMlun6Jverq3QYXUk+1FOOBJwC/ATZloCav0sqn9/37QrMvBPcwHgH054abKZJ0ctkpBTUa7AS+IRtco30i7J7Irzr6jbRvZ2BO6Nh1TlhGBQ0y5IOEMBhWMq9sUXBNmsNxDSGaabEX83Dkgk4pkTtr4Sk0oUpWWI94E3zttYAP6e7gRhiOn6LeYiDfTvIRkN9c/scErs1W3Pa6WY0EWLR7TeVtSWVEo5QIYbJbXRJTOCWyoMc8u5f9c82kIPG+4Ufe9wLUd7t2kVUDh6v89Ord daleha@trololol
@dalehamel
dalehamel / gist:4b61ac93109b8bb14b99
Created February 27, 2015 03:27
Deluge curator script
#!/bin/bash
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
unreg=0
error=0
max_ratio=0
target_tracker=""
days_ago=0
@dalehamel
dalehamel / gmailstats.gs
Last active November 16, 2020 20:52
Basic Gmail statistics
// 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.