Skip to content

Instantly share code, notes, and snippets.

@aaronfeng
aaronfeng / mount_socket_to_host.sh
Created April 3, 2015 13:10
Mount unix socket from boot2docker to host
# Requires socat on host and boot2docker
# OSX - brew install socat
# boot2docker - tce-load -wi socat
# change your ssh key path
sudo socat "UNIX-LISTEN:/var/run/docker.sock,reuseaddr,fork" EXEC:'ssh -i /Users/aaron.feng/.ssh/id_boot2docker docker@192.168.59.103 socat STDIO UNIX-CONNECT\:/var/run/docker.sock'
# own the unix socket on host
sudo chown aaron.feng /var/run/docker.sock
@aaronfeng
aaronfeng / etc-nginx-nginx.conf
Created July 30, 2012 14:15
nginx json log format
# /etc/nginx/nginx.conf
log_format main '{'
'"remote_addr": "$remote_addr",'
'"remote_user": "$remote_user",'
'"time_local": "$time_local",'
'"request": "$request",'
'"status": "$status",'
'"body_bytes_sent": "$body_bytes_sent",'
'"http_referer": "$http_referer",'

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

@aaronfeng
aaronfeng / gist:8478425
Last active January 3, 2016 14:49
latest chef with omnibus
Bundler could not find compatible versions for gem "json":
In Gemfile:
chef (~> 11.8.2) ruby depends on
json (<= 1.7.7, >= 1.4.4) ruby
omnibus (~> 1.3.0) ruby depends on
json (1.8.1)
@aaronfeng
aaronfeng / bundle_ruby
Last active December 31, 2015 19:09
Intercepts `ruby` in order to prepend `bundle exec` if Gemfile.lock is present
#!/bin/bash
# remember original ruby location
export CURRENT_RUBY=$(which ruby)
alias ruby="ruby_wrapper"
# call bundle exec if there's a Gemfile.lock
function ruby_wrapper() {
# unalias it to get the real ruby version
─➤ vagrant provision 1 ↵
[default] The cookbook path '/Users/aaron.feng/code/artifact-cookbook-good/fixtures/databags' doesn't exist. Ignoring...
[Berkshelf] This version of the Berkshelf plugin has not been fully tested on this version of Vagrant.
[Berkshelf] You should check for a newer version of vagrant-berkshelf.
[Berkshelf] If you encounter any errors with this version, please report them at https://github.com/RiotGames/vagrant-berkshelf/issues
[Berkshelf] You can also join the discussion in #berkshelf on Freenode.
[Berkshelf] Updating Vagrant's berkshelf: '/Users/aaron.feng/.berkshelf/default/vagrant/berkshelf-20131029-50324-z5k7zn-default'
[Berkshelf] Using artifact (1.10.3)
[Berkshelf] Using artifact_test (0.1.0) at './fixtures/artifact_test'
[Berkshelf] Using windows (1.8.10)
@aaronfeng
aaronfeng / gist:6907828
Created October 9, 2013 20:31
by default /mnt can't be mounted. pass -lxc-conf to allow mounting of /mnt from host to the container
docker run -lxc-conf="lxc.pivotdir = lxc_putold" -v /mnt/data:/mnt/data ubuntu touch /mnt/data/hello
@aaronfeng
aaronfeng / nginx_open_sockets
Created September 27, 2013 16:59
number of sock opened by nginx
ps aux | grep ngin[x] | tr -s ' ' | echo -n `cut -d' ' -f2` | tr ' ' ',' | xargs -I pid sh -c "ls -alh /proc/{pid}/fd" | grep socket | wc -l
@aaronfeng
aaronfeng / tsocks.rb
Created January 29, 2013 01:23
homebrew tsocks formula
require 'formula'
class Tsocks < Formula
# The original is http://tsocks.sourceforge.net/
# This GitHub repo is a maintained fork with OSX support
homepage 'http://github.com/pc/tsocks'
head 'https://github.com/pc/tsocks.git'
depends_on 'autoconf' => :build if MacOS.xcode_version.to_f >= 4.3

ERROR [2013-01-23 00:58:51,186] New I/O server worker #2-3 - aleph.netty - Unhandled error in Netty pipeline. java.io.IOException: Connection timed out at sun.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:218) at sun.nio.ch.IOUtil.read(IOUtil.java:186) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359) at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:315) at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274) at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)