Skip to content

Instantly share code, notes, and snippets.

View dch's full-sized avatar
🛋️

Dave Cottlehuber dch

🛋️
View GitHub Profile
sudo apt-get install -q -y \
  build-essential git autoconf autoconf-archive \
  gnu-standards help2man texinfo gnupg \
  erlang-base-hipe erlang-dev erlang-manpages erlang-eunit erlang-nox \
  erlang-xmerl erlang-inets libmozjs185-dev libicu-dev curl libcurl4-gnutls-dev \
  libtool help2man texinfo python-sphinx python-pip python-pygments texinfo \
  texlive-fonts-recommended  texlive-latex-extra texlive-latex-recommended  texlive-latex-base
sudo mount -t tmpfs -o size=1024M tmpfs /mnt
cd /mnt
@dch
dch / freebsd-ports-couchdb-1.6.0.patch
Last active August 29, 2015 14:01
homebrew & freebsd-ports update to Apache CouchDB 1.6.0
From f25f0e495a8b0bfbc443ea2e042784f36f577d02 Mon Sep 17 00:00:00 2001
From: Dave Cottlehuber <dch@apache.org>
Date: Thu, 15 May 2014 09:41:35 +0000
Subject: [PATCH] couchdb: 1.6.0
---
databases/couchdb/Makefile | 11 +-
databases/couchdb/distinfo | 4 +-
databases/couchdb/pkg-plist | 311 +++++++++++++++++++++++---------------------
3 files changed, 163 insertions(+), 163 deletions(-)
@dch
dch / Makefile
Last active August 29, 2015 14:01
riemann BSD port
# Created by: Dave Cottlehuber <dch@skunkwerks.at>
# $FreeBSD$
PORTNAME= riemann
PORTVERSION= 0.2.5
CATEGORIES= net-mgmt
MASTER_SITES= http://aphyr.com/${PORTNAME}/
MAINTAINER= dch@skunkwerks.at
COMMENT= Riemann monitors distributed systems

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"

@dch
dch / hashify.erl
Last active August 29, 2015 14:01
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
%% Licensed under the Apache License, Version 2.0 (the "License"); you may not
%% use this file except in compliance with the License. You may obtain a copy of
%% the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
{module, mpegts_alloc}. %% version = 0
{exports, [{module_info,0},{module_info,1},{new,1}]}.
{attributes, []}.
{labels, 7}.
{function, new, 1, 2}.

I was able to install FreeBSD on GCE in a very direct way, without the hurdles of Qemu, gcutil, and the FreeBSD installer. All are great tools, but I think my apporach is somewhat more suitable for GCE, or at least much simpler. Much of this is well-known practice for installing manually, with some fluff for managing it as a disk image, as well as the few odd networking requirements of GCE (MTU and netmask).

My basic approach is to:

  • Use my FreeBSD machine at home to build a self-hosting "rescue" disk image for GCE.
  • Start a temporary Linux machine in GCE from a provided image.
  • Copy my image from home to a raw block device.
  • Start a FreeBSD machine in GCE using that block device as the root.
@dch
dch / reflect.py
Created May 28, 2014 06:58 — forked from huyng/reflect.py
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
(ns your.namespace
(:require [riemann.transport :as rtransport]
[riemann.transport.udp :as rudp]
[interval-metrics.core :as metrics]
[clojure.tools.logging :as log])
(:import (java.nio ByteBuffer ByteOrder)
(org.jboss.netty.buffer ChannelBufferInputStream)
(org.jboss.netty.handler.codec.oneone OneToOneDecoder)
(org.jboss.netty.handler.execution ExecutionHandler
MemoryAwareThreadPoolExecutor)))