Skip to content

Instantly share code, notes, and snippets.

View rasputnik's full-sized avatar
💭
trying out graphiQL

rasputnik rasputnik

💭
trying out graphiQL
View GitHub Profile
@rasputnik
rasputnik / gist:7561122
Created November 20, 2013 10:43
how to build a statsd RPM using FPM.
# get required build bits
yum install -y jdk jruby nodejs rpm-build
# setup jruby (add /opt/jruby/bin to your path)
jgem install fpm
# checkout statsd
@rasputnik
rasputnik / gist:7334377
Created November 6, 2013 11:08
think this setup is wonky
(let [host "0.0.0.0"]
(tcp-server :host host)
(udp-server :host host)
(ws-server :host host))
; keep data for 5 minutes, just throw into index
(let [index (default :ttl 300 (update-index (index)))
graph (graphite {:host "graphite.cf.ac.uk"
:protocol :udp
:pool-size 10})]
@rasputnik
rasputnik / trappy.rb
Last active December 17, 2015 02:59
dropping this into $pluginpath/logstash/inputs/trappy.rb works for me. Just populate an external directory, then point the plugin at it with a "yamlmibdir" config option.
require "logstash/inputs/base"
require "logstash/namespace"
# Read snmp trap messages as events
#
# Resulting @message looks like :
# #<SNMP::SNMPv1_Trap:0x6f1a7a4 @varbind_list=[#<SNMP::VarBind:0x2d7bcd8f @value="teststring",
# @name=[1.11.12.13.14.15]>], @timestamp=#<SNMP::TimeTicks:0x1af47e9d @value=55>, @generic_trap=6,
# @enterprise=[1.2.3.4.5.6], @source_ip="127.0.0.1", @agent_addr=#<SNMP::IpAddress:0x29a4833e @value="\xC0\xC1\xC2\xC3">,
# @specific_trap=99>
@rasputnik
rasputnik / hotbunny.rb
Created April 29, 2013 14:04
Logstash hot_bunnies based AMQP output.
require "logstash/outputs/base"
require "logstash/namespace"
# Push events to a RabbitMQ exchange using the (JRuby-only) hot_bunnies library.
#
# This has been tested with hot_bunnies 1.5.0.
# find links to both here:
#
# * RabbitMQ - <http://www.rabbitmq.com/>
# * Hot Bunnies - <https://github.com/ruby-amqp/hot_bunnies>
Gem found matching: jruby-openssl (= 0.8.7)
Gem found matching: jruby-win32ole (>= 0)
Gem found matching: jdbc-mysql (>= 0)
Gem found matching: msgpack-jruby (>= 0)
Gem found matching: cinch (>= 0)
Gem found matching: spoon (>= 0)
Gem found matching: mocha (>= 0)
Gem found, but funky: shoulda (>= 0) (Unable to activate bourne-1.1.2, because mocha-0.13.3 conflicts with mocha (= 0.10.5))
Gem found matching: rspec (>= 0)
Gem found matching: insist (= 0.0.8)
# run with "jruby --1.9 /path/to/this.rb" and wait 10 minutes
class Thing
def initialize
require 'cabin'
@logger = Cabin::Channel.new
sout = Logger.new(STDOUT)
@logger.level = :debug
@rasputnik
rasputnik / gist:3c4a846b5aedcef6ea02
Created November 4, 2015 14:43
bamboo haproxy template
{{ range $index, $app := .Apps }}
listen {{ $app.EscapedId }}_{{ $app.ServicePort }}
bind *:{{ $app.ServicePort }}
mode http
{{ if $app.HealthCheckPath }}
option httpchk GET {{ $app.HealthCheckPath }}
{{ end }}
balance leastconn
capture request header X-Forwarded-For len 15
{{ range $page, $task := .Tasks }}
@rasputnik
rasputnik / core.clj
Created December 11, 2012 11:44
this is throwing a stacktrace starting with : "Exception in thread "main" java.lang.IllegalArgumentException: Parameter declaration wrap-json-response should be a vector"
(ns tyrekick.core
(:use ring.adapter.jetty ring.util.response ring.middleware.json)
(:gen-class))
(defn handler
"dead simple to get benchmark reqs/sec"
[request]
(response {:message "hello nasty"}))
(defn app
@rasputnik
rasputnik / gist:3634727
Created September 5, 2012 10:30
4clojure #23 : reversing a sequence
(defn widdershins [coll]
(letfn [(flip [tocoll fromcoll]
(if (empty? fromcoll)
tocoll
(flip (cons (first fromcoll) tocoll) (rest fromcoll))
)
)]
(flip [] coll)
)
)
@rasputnik
rasputnik / gist:1048575
Created June 27, 2011 09:38
logstash not parsing syslog?
[root@topcat logstash]# java -jar logstash-1.0.12-monolithic.jar agent -f logstash-simple.cnf
{:args=>["agent", "-f", "logstash-simple.cnf"]}
W, [2011-06-27T10:36:21.439000 #27280] WARN -- runner.class: Input #<LogStash::Inputs::Syslog:0x12297d7> shutting down
2011-06-27T09:36:21.991000Z syslog://10.1.2.3: <30>ntpd[3355]: synchronized to 1.2.3.4, stratum 2
2011-06-27T09:36:22.631000Z syslog://10.2.32.2: <14>ncpd: cmd=0, len=14, data: BB BB 00 1C 00 00 00 00 1C 3F 00 00 00 00
...
...
[root@topcat logstash]# cat logstash-simple.cnf
input {
syslog {