Skip to content

Instantly share code, notes, and snippets.

@garthk
garthk / .gitignore
Last active December 18, 2015 03:29
rendering failure with hyperstream 0.2.0 and markdown-directory 0.1.0 under node 0.10.8..10
node_modules
@garthk
garthk / object-stream-throughput.js
Last active December 17, 2015 02:48
Attempt to benchmark Node.js object streams. See nodejs/node-v0.x-archive#5429 for discussion.
// benchmark/object-stream-throughput.js
//
// Shows performance of pipe()ing new streams in object mode
// through Transform streams.
var OBJECTS_PER_B = 12 / 1024; // I get 12 of my objects per KB of input XML
var SOURCE_WRITE_SIZE = 64*1024;
var common = require('./common');
var net = require('net');
@garthk
garthk / kibana-front-end.conf
Created March 25, 2013 04:34
Lighttpd config to front-end a Kibana site.
server.modules += ( "mod_auth" )
server.modules += ( "mod_proxy" )
accesslog.filename = "/var/log/lighttpd/logs-access.log"
# server.bind = "0.0.0.0"
$SERVER["socket"] == ":80" {
$HTTP["remoteip"] =~ "^10\.10\.10\." {
# hosts in the 10.10.10.10 range can access :80/api/ subroot
$HTTP["url"] !~ "^/api/" {
@garthk
garthk / fun-with-tags.pp
Created March 13, 2013 23:52
A Puppet puzzle involving gathered resources and tags.
# I was expecting this to create either /tmp/ab only, or all three files.
# Instead, it creates /tmp/a and /tmp/ab.
# What's going on?
define x() {
file { "/tmp/${name}": ensure => present }
}
@x { 'a': tag => ['a'] }
@x { 'b': tag => ['b'] }
@garthk
garthk / elastic_template.pp
Created February 6, 2013 04:30
Puppet module to define elastic_template resource type. Doesn't ensure that the index is correct, but does ensure it's present.
define elastic_template($host='localhost', $port='9200', $prefix='', $require=undef) {
$es_templ = "${name}-template.json"
file { "/tmp/${es_templ}":
ensure => present,
source => "puppet:///modules/${module_name}/${prefix}${es_templ}",
require => $require,
}
$es_locn = "http://${host}:${port}/_template/${name}"
exec { "curl -s -XPUT ${es_locn} -d @/tmp/${es_templ}":
diff --git a/manifests/params.pp b/manifests/params.pp
index 3278a7a..06b2db5 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -89,27 +89,4 @@ class logstash::params {
for \"${::operatingsystem}\"")
}
}
-
- # parameters when using a custom jar sourcea
@garthk
garthk / Vagrantfile
Last active December 12, 2015 01:08
Vagrant trick: upgrade Puppet, update apt-get, and install Puppet modules before the Puppet provisioner runs.
MANIFESTS = [
'vagrant-prereq.pp', # prerequisites, e.g. other Puppet modules
'vagrant.pp' # the Logstash configuration we're testing
]
# Run the Puppet provisioner for each manifest
for manifest in MANIFESTS
ls.vm.provision :puppet do |puppet|
puppet.manifests_path = "tests"
puppet.manifest_file = manifest
@garthk
garthk / dashboard-workers
Last active December 11, 2015 23:58
`init.d` script for Puppet Dashboard worker processes.
#!/bin/sh
### BEGIN INIT INFO
# Provides: dashboard-workers
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: dashboard workers
# Description: Start dashboard-workers daemon placed in /etc/init.d.
### END INIT INFO
@garthk
garthk / console.log
Last active December 11, 2015 14:48
Trouble testing modules with Puppet 3.0 under Vagrant
root@lsserver:/tmp/vagrant-puppet/manifests# puppet --version
2.7.19
root@lsserver:/tmp/vagrant-puppet/manifests# which puppet
/usr/bin/puppet
root@lsserver:/tmp/vagrant-puppet/manifests# `which puppet` --version
3.0.2
root@lsserver:/tmp/vagrant-puppet/manifests# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/vagrant_ruby/bin:/opt/vagrant_ruby/bin
root@lsserver:/tmp/vagrant-puppet/manifests# alias
alias egrep='egrep --color=auto'
@garthk
garthk / logposts.js
Created November 27, 2012 04:31
log HTTP POSTs
var http = require('http'),
util = require('util'),
MemoryStream = require('memorystream'),
argv = require('optimist')
.usage('Usage: $0 [-a addr] [-p port]')
.options('a', { alias: 'addr', default: '0.0.0.0' })
.options('p', { alias: 'port', default: 1337 })
.options('h', { alias: 'help' })
.check(function(args) { if (args.h !== undefined) { throw ""; }})
.argv;