Skip to content

Instantly share code, notes, and snippets.

View masterzen's full-sized avatar

Brice Figureau masterzen

View GitHub Profile
@masterzen
masterzen / scan.rb
Created February 24, 2012 16:27
Parse Puppet AST for global node variables
require 'puppet'
class Parser
def scan(input_file_name)
@input_file_name = input_file_name
environment = Puppet::Node::Environment.new
@known_resource_types = environment.known_resource_types
unless environment.known_resource_types.watching_file?(@input_file_name)
Puppet.info "rdoc: scanning #{@input_file_name}"
if @input_file_name =~ /\.pp$/
equire 'thread'
def scroll
puts "In the thread!!"
end
thread = false
if thread
scroller = Thread.new do
@masterzen
masterzen / pif.sh
Created January 28, 2012 19:54
Puppet intrumentation framework
# Puppet Instrumentation Framework
#
# * probes are code bits that trigger events to the framework
# * listeners receive those events and do what they want. Listeners can
# be subscribed to some events types only.
#
# Currently 4 probes:
# * indirector find
# * indirector save
# * indirector search
@masterzen
masterzen / mk-heartbeat-check.sh
Created January 13, 2012 14:50
Opennms General Poller for mk-heartbeat
#!/bin/sh
set -e
set -o pipefail
hostname=$2
RET=`/usr/bin/mk-heartbeat --database test --table heartbeat --user <user> --pass <pass> --host $hostname --check | sed -r -e 's, ,,g'`
RETVAL="$?"
if [ "$RETVAL" != "0" ]; then
exit $RETVAL
@masterzen
masterzen / commands.rb
Created October 31, 2011 18:57
Puppet Extension Point - part 2
commands ping => "/usr/bin/ping"
...
# we can use it later with:
# ping "www.puppetlabs.com"
@masterzen
masterzen / basename-ast.txt
Created October 29, 2011 10:42
Puppet Extension Point
AST::VarDef
AST::Variable(file)
AST::Function(basename)
AST::String(...)
# /etc/snmp/snmpd.conf
...
extend .1.3.6.1.4.1.20267.3.4 m44stats /bin/cat /var/run/games/m44-beta_stats
# emulating opennms snmp bulk get with the command-line:
snmpbulkget -v 2c -c public localhost .1.3.6.1.4.1.20267.3.4.4.1.2.8.109.52.52.115.116.97.116.115.1
iso.3.6.1.4.1.20267.3.4.4.1.2.8.109.52.52.115.116.97.116.115.2 = STRING: "1660289024"
iso.3.6.1.4.1.20267.3.4.4.1.2.8.109.52.52.115.116.97.116.115.3 = STRING: "1660289024"
@masterzen
masterzen / check-config.txt
Created June 18, 2011 11:26
Puppet Network Device
c2950#sh interfaces FastEthernet 0/1 status
Port Name Status Vlan Duplex Speed Type
Fa0/1 --> to end-user wo connect 1000 auto auto 10/100BaseTX
c2950#sh etherchannel 1 summary
Flags: D - down P - in port-channel
I - stand-alone s - suspended
H - Hot-standby (LACP only)
R - Layer3 S - Layer2
diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb
index 0315b95..b83d235 100644
--- a/lib/puppet/provider/service/runit.rb
+++ b/lib/puppet/provider/service/runit.rb
@@ -71,7 +71,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do
output = sv "status", self.daemon
return :running if output =~ /^run: /
rescue Puppet::ExecutionFailure => detail
- unless detail.message =~ /(warning: |runsv not running$)/
+ unless detail.message =~ /(warning: |runsv not running$|unable to change to service directory$)/
./test/ruby/1.8/gems/mocha-0.9.10/lib/mocha/integration/mini_test.rb:3: uninitialized constant MiniTest (NameError)
from /Users/brice/devl/vagrant/test/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /Users/brice/devl/vagrant/test/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /Users/brice/devl/vagrant/test/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /Users/brice/devl/vagrant/test/ruby/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
rake aborted!
Command failed with status (1): [/opt/local/bin/ruby -I"lib:test" "/Users/b...]