Skip to content

Instantly share code, notes, and snippets.

View nathwill's full-sized avatar
🐜
doin' stuff

Nathan Williams nathwill

🐜
doin' stuff
  • Treehouse
  • Portland, OR
View GitHub Profile
@nathwill
nathwill / nginx_stub_status.lua
Created July 22, 2015 00:20
heka nginx_stub_status decoder
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
--]]
local l = require 'lpeg'
@nathwill
nathwill / roles.json
Created July 24, 2015 19:03
packer template for role-based packer builds
{
"description": "build th base image",
"min_packer_version": "0.8.0",
"variables": {
"user": "centos",
"image": "d5f2c6b8-ae55-41d3-b9ba-15e0f2350659",
"flavor": "2",
"role1": "common",
"role2": "common",
"role3": "common",
@nathwill
nathwill / haproxy_http_log.lua
Last active January 8, 2022 17:20
heka haproxy syslog decoder
--[[
Inspired by: https://github.com/mozilla-services/lua_sandbox/pull/22
*Haproxy log-format Directive*
log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r
*Example Config*
[haproxy_udp_input]
type = "UdpInput"
@nathwill
nathwill / pairs-decoder.lua
Last active August 29, 2015 22:17
POC for generic kv pairs decoder for heka
local l = require "lpeg"
require "cjson"
l.locale(l)
local sp = l.space^0
local unreserved = l.digit + l.alnum + l.S"/=-.,_~ "
local name = l.C(unreserved^1) * sp
local comment = l.P"#" * (1 - l.P"\n")^1 * l.P"\n"
local sep = l.P(read_config("pair_separator"))
@nathwill
nathwill / memcached-stats-decoder.lua
Last active September 1, 2015 22:51
heka memcached stats decoder
local l = require 'lpeg'
l.locale(l)
local sp = l.space^1
local unreserved = l.alnum + l.S"/=-.,_~"
local name = l.C(unreserved^1)
local prefix = l.P"STAT "
local pair = prefix^-1 * l.Cg(name * sp * name) * sp
local grammar = l.Cf(l.Ct("") * pair^0, rawset)
@nathwill
nathwill / systemd-nspawn containers on centos
Last active April 12, 2022 03:43
super lightweight containers with systemd-nspawn
assumes centos 7 host, typical configuration
- disable selinux: SELINUX=permissive in /etc/sysconfig/selinux
- disable auditd: systemctl disable auditd.service
- enable journald persistence: `Storage=persistent` in /etc/systemd/journald.conf
- mkdir /var/lib/container
- yum -y --nogpg --releasever=7 --installroot=/var/lib/container/centos install systemd passwd yum vim-minimal openssh-server
- systemd-nspawn -D /var/lib/container/centos
- set root passwd, set ssh port (e.g. 2222)
- set up systemd-nspawn service:
@nathwill
nathwill / pulse.txt
Last active November 28, 2017 22:46
heka monitoring
# heka.toml
[hekad]
base_dir = '/tmp/heka'
[boot]
type = "LogstreamerInput"
log_directory = '/var/log'
file_match = 'boot\.log'
[pulse]
@nathwill
nathwill / openstack-heat-redis-ha.yaml
Last active April 18, 2016 22:06
heat template for an HA redis cluster
heat_template_version: 2015-04-30
description: set up the redis cluster
parameters:
default_image:
type: string
label: default base image
description: glance image id of the base image
default: centos-7.2
@nathwill
nathwill / ha-redis-keepalived.conf
Created April 18, 2016 23:42
keepalived configuration for tracking redis master
vrrp_script chk_redis_master {
script "redis-cli info replication | grep -q 'role:master'"
interval 2
weight 2
rise 2
fall 2
}
vrrp_instance redis_vip {
interface eth0
#!/usr/bin/env python
from sensu_plugin import SensuPluginCheck
import alooma
class AloomaRestreamCheck(SensuPluginCheck):
def setup(self):
self.parser.add_argument(
'-w',
'--warning',