Skip to content

Instantly share code, notes, and snippets.

View craigw's full-sized avatar
🦄

Craig R Webster craigw

🦄
View GitHub Profile
task :prevent_brainfart_apocalypse do
raise "You're running in production" if Rails.env.production?
end
protect_me_from_myself_tasks = %W(db:setup)
protect_me_from_myself_tasks.each do |task_name|
Rake::Task[task_name].prerequisites << 'prevent_brainfart_apocalypse'
end
#! /usr/bin/env ruby
# 1. Install the gem.
#
# 2. Test by attaching a stompcat[1] client and running this:
#
# /path/to/notify-service-by-stomp.rb mq.example.com \
# /topic/xeriom.nagios.services.checks service-host.example.com \
# "FSCK" WARNING HARD 86492 6 6
#
#! /usr/bin/env ruby
# Run me like this:
#
# ./stompcat.rb mq.example.com /topic/foo.bar.baz.quux
#
require 'rubygems'
require 'smqueue'
require 'json'
# Talk to IRC from Ruby via IRCCat.
require 'socket'
class IRC
def self.say(message)
command = "#xeriom [#{process_name}]: #{message}\n"
socket.send(command, 0)
end
# SUDOERS: xm list --long [a-z0-9\-\.]+
CRITICAL_UPTIME_BOUNDARY=3600 # 1 hour
WARNING_UPTIME_BOUNDARY=86400 # 1 day
if [ -d /var/vm ]; then
VM=`echo $1 |sed 's/\.vm\.xeriom\.net//'`
else
VM=$1
fi
# cat /usr/local/sbin/irccat
#! /usr/bin/env ruby
require 'socket'
message = "#xeriom #{STDIN.read}"
socket = TCPSocket.new('monitor.xeriom.net', 12345)
socket.send(message, 0)
socket.close
#! /usr/bin/env bash
CRITICAL_USE=90
WARNING_USE=80
if [ -d /var/vm ]; then
VM_DEVICE_DIR="/var/vm/store"
VM=`echo $1 |sed 's/\.vm\.xeriom\.net//'`
VM_DEVICE="${VM_DEVICE_DIR}/$VM.img"
else
# I'm not sure how to remove it safely, but you can see the feeds it'll query here:
$ cd ~/Library/PubSub/Database
$ sqlite3 ./Database.sqlite3
# sqlite> select * from Feeds;
# run like this:
# sudo ruby -rubygems what_connects.rb 3000
#
require 'socket'
serv = TCPServer.new(ARGV[0].to_i)
begin
sock = serv.accept_nonblock
rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR
IO.select([serv])
# A Nagios service check skeleton.
#
# Note that you can put more than one line of output in the message,
# and you can include check performance data if you'd like.
#
# Technical details here:
# http://nagios.sourceforge.net/docs/3_0/pluginapi.html
#
if okay?