Skip to content

Instantly share code, notes, and snippets.

View miketheman's full-sized avatar

Mike Fiedler miketheman

View GitHub Profile
@miketheman
miketheman / console
Created April 22, 2013 19:29
knife cookbook test slow run.
$ time RUBYOPT="-rprofile" rake knife
bundle exec knife cookbook test mycookbook -o cookbooks
% cumulative self self total
time seconds seconds calls ms/call ms/call name
0.00 0.01 0.00 1 0.00 10.00 #toplevel
checking mycookbook
Running syntax check on mycookbook
Validating ruby files
Validating templates
% cumulative self self total
@miketheman
miketheman / attributes-default.rb
Created April 22, 2013 20:58
chefspec example
node.default['foo']['bar'] = nil
@miketheman
miketheman / .kitchen.yml
Last active December 16, 2015 22:09
Chef 10.24.4 Ubuntu 12.04, mysql 3.0.0
---
driver_plugin: vagrant
platforms:
- name: ubuntu-12.04_chef_11.4.4
driver_config:
box: opscode_ubuntu-12.04_chef-11.4.4
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.4.box
require_chef_omnibus: 11.4.4
- name: ubuntu-12.04_chef_10.24.4
# File dropped of by Chef, local modifications will be overwritten!
# 2013-05-08T00:00:02+00:00 10.87.125.117 haproxy[30746]: 10.44.133.138:39039 [07/May/2013:23:59:56.974] public dogdispatcher/i-5e4d843b:9000 4/0/5001/1002/6009 202 166 - - ---- 132/132/35/11/1 0/0 "POST /api/v1/series/?api_key=<redacted> HTTP/1.1"
# Field numbers, description, example
# Ref: https://code.google.com/p/haproxy-docs/wiki/HTTPLogFormat
# 1 (rsyslog) log time
# 2 (rsyslog) haproxy server
# 3 process_name '[' pid ']:' haproxy[14389]:
# 4 client_ip ':' client_port 10.0.1.2:33317
@miketheman
miketheman / execute
Created June 10, 2013 21:02
erb relative inclusion
$ erubis outer-template.erb
bash -x -c '
echo $(date +%s) > /tmp/test-templates
echo "this is an outer template" >> /tmp/test-templates
'
bash -x -c '
echo "This is an inner template" >> /tmp/test-templates
echo "Some inner ruby: 25"
@miketheman
miketheman / clformat.rb
Last active December 18, 2015 13:39 — forked from jtimberman/clformat.rb
Updated clformat for URL handling
#!/usr/bin/env ruby
#require 'bundler/setup'
require 'date'
require 'jiralicious'
require 'json'
require 'net/https'
require 'uri'
# Pass component name on command line as first argument
@miketheman
miketheman / process_cpu.py
Created July 17, 2013 14:54
using psutil to get a process' cpu times
import psutil
psutil.cpu_times()
# => cputimes(
# user=4482262.9199999999,
# nice=70491.440000000002,
# system=717972.08999999997,
# idle=25366818.309999999,
# iowait=84943.889999999999,
# irq=0.0,
@miketheman
miketheman / zook_grow.md
Created July 22, 2013 21:36
Adding nodes to a ZooKeeper ensemble

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@miketheman
miketheman / events_children.py
Created August 8, 2013 17:24
EXAMPLE: Query Datadog Event stream for time, expand items found in stream
import datetime
import pprint
from dogapi import dog_http_api as api
api.api_key = 'somesecret'
api.application_key = 'yetanothersecret'
start_time = 1375940459
end_time = 1375980459
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'opscode_ubuntu-12.04_chef-11.4.4'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...