Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'rubygems'
require 'fastercsv'
#!/usr/bin/env ruby
source :rubygems
gem "newrelic_rpm"
#!/usr/bin/env ruby
require 'benchmark'
require 'socket'
i = 10_000
Benchmark.bm(9) do |x|
x.report("shell out") do
i.times { `hostname -f`.strip }
$ watch -n1 ruby notus.rb
Every 1.0s: ruby notus.rb Thu Jun 28 09:08:11 2012
[1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0]
8
30667
Sending individual alerts
#!/usr/bin/env ruby
require 'redis'
require 'json'
require 'msgpack'
require 'benchmark'
# mock event
event = {
'host' => 'app-01',
@auxesis
auxesis / gist:3174963
Created July 25, 2012 07:44
no exported resources - how do it then?
node /^mostage-dvmh-sphinx-\d+.cust.bulletproof.net$/ {
movember_sphinx_server { $::fqdn:
collectd_client_report_to => 'mostage-dvmh-mgmt-01.cust.bulletproof.net',
syslog_client_report_to => 'mostage-dvmh-mgmt-01.cust.bulletproof.net',
}
}
node /^mostage-dvmh-slave-\d+.cust.bulletproof.net$/ {
if $::fqdn =~ /slave-02/ {
movember_sphinx_server { $::fqdn:
#!/usr/bin/env ruby
require 'eventmachine'
require 'colorize'
EM.run do
@queue = EM::Queue.new
EM.add_periodic_timer(1) do
puts "[#{Time.now}] Running indexing...".green
before do
content_type :jsonp
@backend = Visage::Config.backend
end
# /data/:host/:plugin/:optional_plugin_instance
get %r{/data/([^/]+)/([^/]+)((/[^/]+)*)} do
# parameter unpacking
options = {
server "stub", :stub
namespace :deploy do
task :default do
# Get list of stages
# Run the deploy task on each stage
puts "Deploying..."
end
end

Ript: making Linux firewall change management resilient

Netfilter is an extremely powerful framework for manipulating packets, but does anyone enjoy using iptables? Tools for managing small rulesets have a steep learning curve, and most tools don't take availablity into account when managing large rulesets.

Enter Ript, a clean and opinionated Domain Specific Language for describing firewall rules, and a tool that implements database migrations-like functionality for applying these rules with zero downtime.

At Ript's core is an easy to use Ruby DSL for describing both simple and complex sets of iptables firewall rules, with helpers for all the common use cases: accepting, dropping, & rejecting packets, as well as for performing DNAT and SNAT.

Ript provides a method to group common sets of rules together called "partitions", which are used at rule application time to perform zero-downtime migrations.