Skip to content

Instantly share code, notes, and snippets.

View ripienaar's full-sized avatar

R.I.Pienaar ripienaar

View GitHub Profile
bin/cucumber --require features/ features/example-script.feature
<%=
nodes = Puppet::Util::MongoQuery.instance.find_nodes({"facts.customer" => "rip"})
nodes.map do |node|
"%s: %s" % [node["hostname"],
node["facts"]["operatingsystem"]]
end.join("\n")
%>
module MCollective
module Facts
require 'yaml'
# A factsource that reads a hash of facts from a YAML file
#
# Multiple files can be specified seperated with a : in the
# config file, they will be merged with later files overriding
# earlier ones in the list.
class Yaml<Base
exec{"foo":
command => "/bin/ln -s /tmp/foo /tmp/bar",
onlyif => "/usr/bin/test -e /tmp/foo",
}
file{"/tmp/foo":
require => Exec["foo"]
}
#!/usr/bin/env ruby
#
# This script reads lines from STDIN and sends a notification for each line.
# It's intended to be used with the fnotify.pl IRSSI script to write notices
# and hilights to a plain text file. tail -f links the two systems together.
require 'mcollective'
include MCollective::RPC
### Module
module MCollective
module Agent
# A simpleRPC Agent that replies with each active config setting.
#
class Confignotify<RPC::Agent
action "get_config" do
config = Config.instance
# A mcollective security plugin that fails to decode messages randomly used to debug
# error propagation issues
module MCollective
module Security
class Randomfail < Base
require 'etc'
require 'yaml'
# Decodes a message by unserializing all the bits etc, it also validates
@ripienaar
ripienaar / agenttest.rb
Created March 8, 2011 15:26
script to test the filemgr agent standalone without requiring mcollective to run
#!/usr/bin/ruby
require 'mcollective'
require 'pp'
configfile = "server.cfg"
agent = "filemgr"
request = {:action => "status",
:data => {:file => "/tmp"}}
@ripienaar
ripienaar / gist:1256476
Created October 1, 2011 18:43
Send munin results to a stomp server as json events
#!/usr/bin/ruby
require 'rubygems'
require 'stomp'
require 'json'
require 'optparse'
require 'facter'
require 'munin-ruby'
require 'yaml'
require 'timeout'
title "Combined CPU Usage"
vtitle "percent"
area :stacked
field :iowait, :scale => 0.001,
:color => "red",
:alias => "IO Wait",
:data => "sumSeries(derivative(mw*munin.cpu.iowait))"
field :system, :scale => 0.001,