Skip to content

Instantly share code, notes, and snippets.

View teddyking's full-sized avatar

Ed King teddyking

View GitHub Profile
@teddyking
teddyking / setup-go-dev.sh
Created December 23, 2016 14:57
Setup an ubuntu machine for Go dev
#!/bin/bash
set -e -x
apt-get -y update
apt-get -y install software-properties-common python-pip python3-dev python3-pip
add-apt-repository -y ppa:neovim-ppa/unstable
apt-get -y update
apt-get -y install neovim
@teddyking
teddyking / pprof-guardian.sh
Last active April 12, 2017 07:35
Install go 1.8 and run a pprof againast a local guardian process
cd /usr/local/
wget "https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz"
tar -zxf go1.8.linux-amd64.tar.gz
rm go1.8.linux-amd64.tar.gz
cd
mkdir go
cd go
mkdir src pkg bin
cd ../
@teddyking
teddyking / cleanup.sh
Created October 27, 2016 10:57
AUFS hang on umount of loop device cleanup script
#!/bin/bash
set -x -e
ps aux | grep namespaced | grep -v grep | awk '{print $2}' | xargs -n1 kill -9 || true
umount /root/workspace/4.4-loop-umount-hang-test/mnt/container-2 || true
umount /root/workspace/4.4-loop-umount-hang-test/diff/container-2 || true
umount /root/workspace/4.4-loop-umount-hang-test/mnt/container-1 || true
@teddyking
teddyking / create.sh
Created October 27, 2016 10:56
AUFS hang on umount of loop device script
#!/bin/bash
set -x -e
WORKSPACE_DIR=~/workspace/4.4-loop-umount-hang-test
# 1. Setup workspace
mkdir -p $WORKSPACE_DIR
mkdir -p $WORKSPACE_DIR/{diff,mnt,layers}
@teddyking
teddyking / tsgnano.go
Created October 27, 2016 10:30
the-secret-garden-nano - a lightweight version of the secret garden that also runs runc's pivot_root func
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"syscall"
"time"
@teddyking
teddyking / mnt_pids.rb
Created October 4, 2016 08:28
Hacktastic script to print a PID from each mount namespace on a host
mntnses = Dir.glob("/proc/*/ns/mnt")
foundmnts = []
foundpids = []
mntnses.each do |mntns|
actualmntns = `readlink "#{mntns}"`
pid = mntns.split("/")[2]
mntnum = actualmntns.gsub(/mnt:\[/, "").gsub(/\]/, "")
#puts "#{pid} - #{mntnum}"
@teddyking
teddyking / waitgroup.go
Created August 23, 2016 10:34
Example of Go sync.WaitGroup
package main
import (
"fmt"
"sync"
"time"
)
func main() {
var myWaitGroup sync.WaitGroup
@teddyking
teddyking / logsearch_properties_manifest_snippet.yml
Last active August 29, 2015 14:08
logsearch Manifest Snippet - properties
# Add the required logsearch properties
properties:
collectd:
hostname_prefix: "dev.logsearch."
python_librato:
include_regex: "collectd\\.cpu\\..*,collectd\\.df\\..*,collectd\\.disk\\..*,collectd\\.elasticsearch\\..*,collectd\\.entropy\\..*,collectd\\.interface\\..*,collectd\\.load\\..*,collectd\\.memory\\..*,collectd\\.processes\\..*,collectd\\.redis_.*,collectd\\.users\\..*"
elasticsearch:
host: 10.244.1.2
cluster_name: logsearch-bosh-lite
drain: true
@teddyking
teddyking / logsearch_jobs_manifest_snippet.yml
Last active August 29, 2015 14:08
logsearch Manifest Snippet - jobs
- name: ls_api
release: logsearch
templates:
- name: api
- name: collectd
- name: elasticsearch
instances: 1
resource_pool: logsearch
networks:
- name: services1
@teddyking
teddyking / logsearch_resource_pools_manifest_snippet.yml
Created October 25, 2014 15:36
logsearch Manifest Snippet - resource_pools
# Add a resource pool for the logsearch jobs.
# Note: We're just using 1 additional resource pool here to keep things simple.
# Note: Update the stemcell name as required (run `bosh stemcells` to get the name of your stemcell).
# Note: We're using the services1 network for this tutorial, update this if you need to.
resource_pools:
- name: logsearch
network: services1
size: 6
stemcell:
name: bosh-warden-boshlite-ubuntu-trusty-go_agent