Skip to content

Instantly share code, notes, and snippets.

View mikehale's full-sized avatar

Michael Hale mikehale

  • RoleModel Software
  • Holly Springs, NC
View GitHub Profile
before_fork do |server, worker|
fork do
begin
STDOUT.sync = true
start = Time.now
sockets = `netstat -lnae|grep #{ENV['PORT']}|grep ESTABLISHED|awk '{print $2,$3}'`.split("\n")
queue_sums = sockets.map{|s| s.split(/\s+/).map(&:to_i) }.inject([0,0]){|m,e| [m[0] + e[0], m[1] + e[1]] }
puts "measure.tcp_recv_q=#{queue_sums[0]} measure.tcp_send_q=#{queue_sums[1]} elapsed_netstat_time=#{Time.now - start}"
end while sleep(10)
end
@mikehale
mikehale / Gemfile
Last active December 17, 2015 07:09
gem 'raindrops'
#!/usr/bin/env ruby
require 'net/https'
https = Net::HTTP.new('logplex.herokai.com', 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
# use system defaults
https.cert_store = OpenSSL::X509::Store.new
https.cert_store.set_default_paths
echo '{
"handlers": ["debug"],
"name": "push_woot_test",
"output": "woot!",
"status": 1
}' | nc -w1 127.0.0.1 3030
@mikehale
mikehale / nagios-debug-log-introspector.rb
Created February 27, 2013 03:13
parse nagios.debug log and print start and finished times for host and service checks
#!/usr/bin/env ruby
require 'time'
STDOUT.sync = true
def time(stuff)
Time.at(stuff.to_f).strftime("%H:%M:%S")
end
while line = $stdin.readline
if line =~ /\A\[(.*?)\] \[.*?\] \[.*?\] Attempting to run scheduled check of service '([^']+)' on host '([^']+)'/
[["*.heroku.com", "kyoto-5887.herokussl-eu-west-1-a.com"],
["testapp.com", "gifu-2160.herokussl-eu-west-1-a.com"],
["testapp.com", "saga-2555.herokussl-eu-west-1-a.com"],
["*.herokai.com", "nagios-default.herokussl-eu-west-1-a.com"],
["mls.herokussl-eu-west-1-a.com",
"eu-west-1-a-mls-default.herokussl-eu-west-1-a.com"],
["elb000003-1944048936.eu-west-1.elb.amazonaws.com",
"eu-west-1-a-maestro-default.herokussl-eu-west-1-a.com"],
["psmgr.herokussl-eu-west-1-a.com",
"eu-west-1-a-psmgr-default.herokussl-eu-west-1-a.com"],
[[1, "*.herokuapp.com"],
[2, "psmgr.herokussl-eu-west-1-a.com"],
[3, "elb000003-1944048936.eu-west-1.elb.amazonaws.com"],
[4, "mls.herokussl-eu-west-1-a.com"],
[5, "canary-eu-west-1-a-endpoint-1.herokuapp.com"],
[6, "canary-eu-west-1-a-endpoint-2.herokuapp.com"],
[7, "canary-eu-west-1-a-endpoint-3.herokuapp.com"],
[8, "canary-eu-west-1-a-endpoint-4.herokuapp.com"],
[9, "canary-eu-west-1-a-endpoint-5.herokuapp.com"],
[11, "*.heroku.com"],
[[1, "*.herokuapp.com"],
[2, "psmgr.herokussl-eu-west-1-a.com"],
[3, "elb000003-1944048936.eu-west-1.elb.amazonaws.com"],
[4, "mls.herokussl-eu-west-1-a.com"],
[5, "canary-eu-west-1-a-endpoint-1.herokuapp.com"],
[6, "canary-eu-west-1-a-endpoint-2.herokuapp.com"],
[7, "canary-eu-west-1-a-endpoint-3.herokuapp.com"],
[8, "canary-eu-west-1-a-endpoint-4.herokuapp.com"],
[9, "canary-eu-west-1-a-endpoint-5.herokuapp.com"],
[11, "*.heroku.com"],
[[1, "*.herokuapp.com"],
[2, "psmgr.herokussl-eu-west-1-a.com"],
[3, "elb000003-1944048936.eu-west-1.elb.amazonaws.com"],
[4, "mls.herokussl-eu-west-1-a.com"],
[5, "canary-eu-west-1-a-endpoint-1.herokuapp.com"],
[6, "canary-eu-west-1-a-endpoint-2.herokuapp.com"],
[7, "canary-eu-west-1-a-endpoint-3.herokuapp.com"],
[8, "canary-eu-west-1-a-endpoint-4.herokuapp.com"],
[9, "canary-eu-west-1-a-endpoint-5.herokuapp.com"],
[11, "*.heroku.com"],
;; Packages
;;
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)