Skip to content

Instantly share code, notes, and snippets.

View miah's full-sized avatar
🍕
Dreaming of pizza.

Miah Johnson miah

🍕
Dreaming of pizza.
View GitHub Profile
@danslimmon
danslimmon / logstash_postfix.conf
Last active July 30, 2018 21:32
My logstash config for postfix logs
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"] }
@ranjib
ranjib / Chef_Internal_TOC.md
Last active December 18, 2015 04:28
Topics that we can discuss on chef internal

Topics

  1. 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)

  2. 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

  3. 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).

  4. Anatomy of a chef run (revisited with chef internal) :

    1. setup phase (logging setup, configuration setups, client registration, getting a node's runlist)
  5. cookbook syncing,

@adamhjk
adamhjk / Guardfile
Last active December 17, 2015 03:19
A Guardfile with inline support for test-kitchen, before we turn it into a gem.
# 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")
@jtimberman
jtimberman / nix.rb
Last active December 16, 2015 07:39 — forked from dysinger/nix.sh
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]"
@jeroenvandijk
jeroenvandijk / Readm.md
Last active August 31, 2017 09:13
Instructions to test Logstash with Kafka

Test Logstash with Kafka

Setup Kafka

Download Kafka from:

https://www.apache.org/dyn/closer.cgi/incubator/kafka/kafka-0.7.2-incubating/kafka-0.7.2-incubating-src.tgz

Install Kafka

class Chef
class SubResourceCollection < ResourceCollection
def initialize(parent)
@parent = parent
super()
end
def lookup(resource)
super
rescue Chef::Exceptions::ResourceNotFound
@jtimberman
jtimberman / spec.rb
Last active December 10, 2015 02:48
Starting to add rspec tests for runit_service LWRP.
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
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
@jordansissel
jordansissel / RESULTS.md
Created September 21, 2012 07:41
screenshot + code showing how to query logstash/elasticsearch with a graphite function.

logstash queries graphed with graphite.

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.

@joho
joho / gzip_net_http.rb
Created September 19, 2012 04:12
Handling gzip responses in Ruby Net::HTTP library
# 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" } )