Skip to content

Instantly share code, notes, and snippets.

View aasmith's full-sized avatar

Andrew A Smith aasmith

View GitHub Profile
@toolmantim
toolmantim / socket_stats_logger
Created June 16, 2015 07:18
How to monitor Unicorn and Puma unix socket queues with statsd
#!/bin/bash
# Logs the queued and active stats from the application's sockets and posts to statsd
while true; do
proc_lines=`cat /proc/net/unix`
for file in /home/deploy/myapp/tmp/sockets/*.sock; do
# /proc/net/unix lines are of the format:
@philandstuff
philandstuff / haproxy-statsd.rb
Created October 8, 2012 09:34
script to pump haproxy stats into statsd
#!/usr/bin/ruby
require 'socket'
HOSTNAME = `facter hostname`.chomp
SOCKET = UDPSocket.new
IO.popen(["curl","http://localhost:8000/haproxy;csv"]) do |haproxy_csv|
header_line = haproxy_csv.gets
header_line.gsub!(/# /,'')
HEADERS = header_line.split(/,/)[0..-2]
@ahoward
ahoward / net-http-debug.rb
Created December 10, 2010 20:06
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)