Skip to content

Instantly share code, notes, and snippets.

View conorsch's full-sized avatar

Conor Schaefer conorsch

View GitHub Profile
@duggan
duggan / inventory.py
Created October 12, 2015 15:01
Present Terraform tfstate data as an Ansible inventory
#!/usr/bin/env python
import sys
import os
import json
import argparse
import collections
__description__ = """Ansible Dynamic Inventory for Terraform."""
__epilog__ = """
@lathspell
lathspell / __etc__logstash__patterns__dpkg.conf
Last active December 3, 2020 16:05
Logstash grok pattern file for /var/log/dpkg.log
DPKG_TIMESTAMP %{TIMESTAMP_ISO8601:timestamp}
DPKG_PACKAGE [-+~\.0-9a-zA-Z]+
DPKG_ARCH [a-z0-9]+
DPKG_PKGARCH %{DPKG_PACKAGE:package}(:%{DPKG_ARCH:arch})?
DPKG_VERSION [-+~<>\.0-9a-zA-Z]+
DPKG_ACTION0 (startup archives|startup packages|conffile)
DPKG_ACTION1 (configure|remove|upgrade|purge|status (config-files|installed|not-installed|triggers-awaited|triggers-pending|unpacked|half-installed|half-configured))
DPKG_ACTION2 (trigproc|upgrade)
DPKG_0_VERSIONS %{DPKG_ACTION0:action}
DPKG_1_VERSIONS (%{DPKG_ACTION1:action} %{DPKG_PKGARCH} %{DPKG_VERSION:version})$

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

@pixyj
pixyj / django_one_step.sh
Created October 27, 2012 10:11
Script to create django project with virtualenv
#!/bin/bash
#Take project name as input
if [ -z "$1" ]
then
echo "Enter project name"
read proj
else
proj="$1"
fi
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ngcrawford
ngcrawford / multiprocessing_template.py
Created March 29, 2012 12:49
Template for multiprocessing large files line by line
#!/usr/bin/env python
# encoding: utf-8
import multiprocessing
from textwrap import dedent
from itertools import izip_longest
def process_chunk(d):
"""Replace this with your own function
that processes data one line at a
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite