Skip to content

Instantly share code, notes, and snippets.

View electrical's full-sized avatar

Richard Pijnenburg electrical

View GitHub Profile
@rafl
rafl / elasticsearch_cache
Created March 22, 2012 16:32
Munin ElasticSearch plugins
#!/usr/bin/env perl
# Parameters supported:
#
# config
# autoconf
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
@fluxrad
fluxrad / pre-commit
Created April 11, 2012 19:04
A pre-commit git hook to validate puppet syntax
#!/bin/bash
# pre-commit git hook to check the validity of a puppet manifest
#
# Prerequisites:
# gem install puppet-lint puppet
#
# Install:
# /path/to/repo/.git/hooks/pre-comit
# Source RVM if needed
@stephenc
stephenc / gist:3053561
Created July 5, 2012 13:05
Continuous Deployment with Jenkins and Puppet

Puppet with Jenkins

Setup Jenkins

With Puppet:

puppet module install rtyler-jenkins

puppet apply -v -e "include jenkins"

@afair
afair / tmux.cheat
Last active June 3, 2024 23:26
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New new -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &
@jordansissel
jordansissel / gist:3741723
Last active February 11, 2021 04:56
OpenSSL quick. (generate certs, run server/clients)
# Create a self-signed cert
openssl req -x509 -batch -nodes -newkey rsa:2048 -keyout lumberjack.key -out lumberjack.crt
# Create a self-signed with DNS SAN
openssl req -x509 -nodes -new -subj "/CN=localhost" -addext "subjectAltName = DNS:localhost" -newkey rsa:2048 -keyout
/tmp/server.key -out /tmp/server.crt
@electrical
electrical / RESULTS.md
Created December 2, 2012 12:58 — forked from jordansissel/RESULTS.md
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.

anonymous
anonymous / elasticsearch.yml
Created December 17, 2012 13:59
ElasticSearch configuration for LogStash
cluster:
name: elasticsearch
network:
host: 127.0.0.1
path:
logs: /var/log/elasticsearch
data: /var/lib/elasticsearch
conf: /etc/elasticsearch
input {
tcp {
type => 'json-logger'
port => 3517
format => "json_event"
}
}
filter {
mutate {
# Convert hostname => @source_host, because it's overwritten
@robinsmidsrod
robinsmidsrod / _json-logger.md
Created December 18, 2012 10:10
json-logger: A practical script to capture multiline output from e.g. cron jobs into a single logstash JSON event

Can be used in crontab like this:

SHELL=/bin/bash
BASH_ENV=~/.bash_profile
# m h  dom mon dow   command
0    * * * * /home/portfolio/portfolio/bin/session.pl                2> >(json-logger -ep pf_session)                | json-logger -p pf_session
0    2 * * * /home/portfolio/portfolio/bin/purge_deleted_messages.pl 2> >(json-logger -ep pf_purge_deleted_messages) | json-logger -p pf_purge_deleted_messages
0,30 * * * * /home/portfolio/portfolio/bin/expire_page_views.pl      2> >(json-logger -ep pf_expire_page_views)      | json-logger -p pf_expire_page_views

I would suggest you put it in /usr/bin to avoid having to setup your PATH variable.

#!/usr/bin/ruby
queue_list = `rabbitmqctl list_queues`.split("\n")
queue_list.pop
queue_list.shift
queues = Hash.new
queue_list.each do |queue|
queue = queue.strip.split(/\s+/).collect(&:strip)
queue_stat = queue.pop
queue_name = queue.pop