-
Mixlib-shell out interface :: A portable , cross platform command execution module. How to use it with any arbitrary code, how chef interfaces with it (shellout, shellout! etc)
-
Mixlib-Cli :: The awesome command line argument processor. How to use it with any arbitrary program , pitfalls associated with reusing classes that uses mixlib-cli
-
A generic overview of the chef rest class (Chef::Rest) and main domain objects (Node, Role, ApiClient etc). How to access them from any arbitrary scripts (#load, #list . #search etc).
-
Anatomy of a chef run (revisited with chef internal) :
- setup phase (logging setup, configuration setups, client registration, getting a node's runlist)
-
cookbook syncing,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter { | |
# Capture all the generic syslog stuff and populate @timestamp | |
if [type] == "postfix" { | |
grok { | |
match => [ "message", "%{SYSLOGBASE} %{GREEDYDATA:_syslog_payload}" ] | |
singles => true | |
} | |
# Postfix pads single-digit numbers with spaces (WHYYYYY) | |
mutate { gsub => [ "timestamp", " ", " 0" ] } | |
date { match => [ "timestamp", "MMM dd HH:mm:ss"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A sample Guardfile | |
# More info at https://github.com/guard/guard#readme | |
require 'guard/guard' | |
require 'mixlib/shellout' | |
module ::Guard | |
class Kitchen < ::Guard::Guard | |
def start | |
::Guard::UI.info("Guard::Kitchen is starting") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
remote_file "/tmp/nix-1.5.1-x86_64-linux.tar.bz2" do | |
source "http://hydra.nixos.org/build/4253979/download/1/nix-1.5.1-x86_64-linux.tar.bz2" | |
notifies :run, "execute[untar nix]", :immediately | |
end | |
execute "untar nix" do | |
cwd "tmp" | |
command "tar -jxf /tmp/nix-1.5.1-x86_64-linux.tar.bz2 -C /" | |
action :nothing | |
notifies :run, "execute[nix-finish-install]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chef | |
class SubResourceCollection < ResourceCollection | |
def initialize(parent) | |
@parent = parent | |
super() | |
end | |
def lookup(resource) | |
super | |
rescue Chef::Exceptions::ResourceNotFound |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
champagne:~OPSCODE_COOKBOOKS/runit (1.9.3-p327) | |
CHEF-154 ✗ % rake spec | |
bundle exec rspec -c -f d spec.rb | |
Chef::Provider::RunitService | |
load_current_resource | |
should create a current resource with the name of the new resource | |
Finished in 0.00362 seconds | |
1 example, 0 failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Carbon relay - performance | |
alias(color(sumSeries(group(carbon.agents.*.updateOperations)), "blue"),"Updates") | |
alias(color(sumSeries(group(carbon.agents.*.metricsReceived)), "green"), "Metrics Received") | |
alias(color(sumSeries(group(carbon.agents.*.committedPoints)),"orange"),"Committed Points")) | |
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.pointsPerUpdate)),"yellow")),"PPU") | |
alias(secondYAxis(color(averageSeries(group(carbon.agents.*.cpuUsage)),"red")),"CPU (avg)") | |
alias(secondYAxis(color(sumSeries(group(carbon.agents.*.creates)),"purple")),"Creates") | |
Metrics received | |
carbon.agents.*.metricsReceived |
Operation: Decouple whisper from graphite.
Method: Create a graphite function that does a date histogram facet query against elasticsearch for a given query string for the time period viewed in the current graph.
Reason: graphite has some awesome math functions. Wouldn't it be cool if we could use those on logstash results?
The screenshot below is using logstash to watch the twitter stream of keywords "iphone" "apple" and "samsung" - then I graph them each, so we get an idea of popularity. As a bonus, I also do a movingAverage() on the iphone curve to show you why this is awesome.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from http://pushandpop.blogspot.com.au/2011/05/handling-gzip-responses-in-ruby-nethttp.html | |
# i wanted syntax highlighting | |
require 'net/http' | |
debug = Proc.new{|msg| STDERR.puts "[#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] #{msg}" } | |
page = nil | |
http = Net::HTTP.new( "www.google.com", 80 ) | |
req = Net::HTTP::Get.new( "/search?num=20&hl=en&noj=1&q=test&btnG=Search", { "Accept-Encoding" => "gzip", "User-Agent" => "gzip" } ) |