Skip to content

Instantly share code, notes, and snippets.

@rottenbytes
rottenbytes / pkgng.rb
Created August 28, 2012 20:11
quick & dirty chef pkgng provider
require 'chef/mixin/command'
require 'chef/log'
require 'chef/file_cache'
require 'chef/platform'
require 'chef'
class Chef
class Provider
class Package
class Pkgng < Chef::Provider::Package
@rottenbytes
rottenbytes / .vim_chef.rb
Created August 29, 2012 11:54
Hook chef to your vim
def test(cb_name)
result=%x[knife cookbook test #{cb_name}]
if $? != 0 then
VIM::message("Testing cookbook '#{cb_name}' failed")
else
VIM::message("Cookbook '#{cb_name}' is OK.")
end
end
@rottenbytes
rottenbytes / pkgng.rb
Created September 4, 2012 11:09
package provider
require 'chef/mixin/command'
require 'chef/log'
require 'chef/file_cache'
require 'chef/platform'
require 'chef'
class Chef
class Provider
class Package
class Pkgng < Chef::Provider::Package
@rottenbytes
rottenbytes / pkgng.rb
Created September 5, 2012 08:29
chef+pkgng
require 'chef/mixin/shell_out'
require 'chef/platform'
require 'chef'
include Chef::Mixin::ShellOut
class Chef
class Provider
class Package
class Pkgng < Chef::Provider::Package
@rottenbytes
rottenbytes / nagios.coffee
Created October 2, 2012 12:05 — forked from oremj/nagios.coffee
Nagios script for hubot
# Description:
# This script receives pages in the formats
# /usr/bin/curl -d host="$HOSTALIAS$" -d output="$SERVICEOUTPUT$" -d description="$SERVICEDESC$" -d type=service -d state="$SERVICESTATE$" $CONTACTADDRESS1$
# /usr/bin/curl -d host="$HOSTNAME$" -d output="$HOSTOUTPUT$" -d type=host -d state="$HOSTSTATE$" $CONTACTADDRESS1$
#
# Author:
# oremj
irc = require('irc')
def ask_question(question, opts={})
question = question + "[#{opts[:default]}] " if opts[:default]
STDOUT.print question
a = STDIN.readline.strip
if opts[:default]
a.empty? ? opts[:default] : a
else
a
PreCacheChain "PreCache"
LoadPlugin "match_regex"
LoadPlugin "target_notification"
LoadPlugin "target_set"
<Chain "PreCache">
# sanitize plugin names, to get a better naming
<Rule "tail_to_postfix">
<Match "regex">
@rottenbytes
rottenbytes / tests.md
Created March 26, 2013 10:50
Some little tests around ES and java 6/7

Logstash + ES + Java 6 & 7

ES VMs : 1 CPU, 2G of RAM, dedicated to ES. ES process got 1G of RAM. Running version 0.20.5 Logstash machine : 1 collector process, input TCP, output to redis and 1 indexer process input redis and output in Y to both ES servers

pre flight test at 10h27, cleaned indices and then started indexing at 10h37. This test is not about performance in itself, but more about ES behaviour when changing the JVM. Ended around 11h15

first is the VM running under java 6, then java 7

@rottenbytes
rottenbytes / gist:5300554
Created April 3, 2013 11:53
resource chef
action "handle" do
validate :resourcetype, String
validate :resourcename, String
require 'chef'
require 'chef/client'
require 'chef/run_context'
begin
Chef::Config[:solo] = true
require "rubygems"
require "couchbase"
require "net/http"
require "json"
def random_string(size=30)
#o = [('a'..'z'),('A'..'Z'),(1..9)].map{|i| i.to_a}.flatten
o = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", 1, 2, 3, 4, 5, 6, 7, 8, 9]
string = (0..size).map{ o[rand(o.length)] }.join
end