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 / 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 / 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 / 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 / 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 / sensu_event.lua
Created June 5, 2015 18:12
sensu event encoder for heka
-- 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/.
--[[
Encodes a heka message as a sensu event
Config:
- status_field (string, optional, default: status)
@nathwill
nathwill / json_decoder.lua
Created May 30, 2015 16:45
heka json 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/.
--[[
Parses a payload containing JSON.
Config:
- type (string, optional, default nil):
@nathwill
nathwill / Makefile
Last active August 29, 2015 14:07
snippet of packer-centric makefile
projs := $(basename $(wildcard *.json))
cmds := validate inspect build fix
aliases := bootstrap rebuild
# Enable packer debug logging
PACKER_LOG := 1
PACKER_LOG_PATH := /tmp/packer-debug
export PACKER_LOG PACKER_LOG_PATH
# call out rules that don't generate output
@nathwill
nathwill / chef_user_monkey_patch.rb
Last active August 29, 2015 14:06
chef user monkey patch for github ssh keys
require 'chef/resource/directory'
require 'chef/resource/file'
require 'chef/resource/remote_file'
require 'chef/resource/user'
require 'chef/provider/user'
class Chef
class Resource::TreehouseUser < Chef::Resource::User
def github_users(arg = nil)
set_or_return(
@nathwill
nathwill / ssh-audit.txt
Last active November 28, 2017 23:00
lazy audit logging
# Set up audit logging for connections outbound from the bastion
default['openssh']['client'].tap do |client|
client['permit_local_command'] = 'yes'
client['local_command'] = '/usr/bin/logger -p INFO -t AUTH %u signed into %h:%p as %r'
end
@nathwill
nathwill / pf.conf
Last active May 4, 2024 03:05
a dummy's sample pf.conf
# $OpenBSD: pf.conf,v 1.52 2013/02/13 23:11:14 halex Exp $
#
# See pf.conf(5) for syntax and examples.
#
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.
### Macros
# system