Skip to content

Instantly share code, notes, and snippets.

View brianjolly's full-sized avatar

Brian Jolly brianjolly

View GitHub Profile
@brianjolly
brianjolly / sshtest.rb
Created June 7, 2011 02:06
Quick net-ssh example
#!/usr/bin/env ruby
#gem install net-ssh
require 'rubygems'
require 'net/ssh'
HOST = '192.168.1.1'
USER = 'me'
PASS = 'secret'
@brianjolly
brianjolly / hog_killer.rb
Created March 3, 2011 21:51
Emergency script to kill out of control Rails processes. Thanks to /dev/urandom :(
grep_output = `ps aux | grep Rails`
kill_list = []
any_rails = grep_output.scan(/^www-480\s+(\d+)\s+(\d+.\d+).*Rails/)
any_rails.each do |process|
pid = process[0]
cpu = process[1]
if cpu.to_f > 95.0
kill_list << process