Skip to content

Instantly share code, notes, and snippets.

View johann8384's full-sized avatar

Jonathan Creasy johann8384

View GitHub Profile
@johann8384
johann8384 / metrics.scala
Created October 24, 2012 19:16
Metric Handler
type MetricHandler = (MetricName, Map[String, Any]) => String
val metricHandlers = Map("counter" -> handleCounter _, "timer" -> handleTimer _, "meter" -> handleMeter _)
/*
* This is the core function in this class
* accept a parsed metric object and delegate it to an appropriate handler
*/
def handleMetric(metricMap : Map[String, Any]) : String = {
@johann8384
johann8384 / render_graphs.js
Created November 8, 2012 00:10
Render TSDB Graphs for Cacti Style Display
var page = require('webpage').create(),
address, output, size;
var tsdb_host = 'opentsdb.sv2.box.net';
var tsdb_port = 4242;
var start = '1h-ago';
var metric = 'sum:' + phantom.args[0];
var width = 1280;
var height = 720;
@johann8384
johann8384 / histogram.php
Created December 11, 2012 08:52
PHP Stats Library
/**
*
* Extend Stats class to include Histogram support
* borrows heavily from Jesus M Castagnetto's code published here: http://px.sklar.com/code.html?id=119
* @author jcreasy
*/
/*
* // Original Header
* This is a histogram class that accepts and unidimensional array of data
* Returns 2 arrays by using the getStats() and getBins() methods.
@johann8384
johann8384 / server.php
Created December 12, 2012 05:42
DNS Server
<?php
/**
* DNS Server Class
*
* @author Jonathan Creasy <jcreasy@box.com>
* @version 0.1.0
* @package Dns
* @subpackage Server
* @url http://www.phpclasses.org/browse/file/18217.html
* This code is released into the public domain. Feel free to use it and distribute it however you wish.
<?php
function get_tsdb_data($metric, $range = 'hour', $time = '')
{
$date_format = 'Y/m/d-H:i:s';
$aggregator = 'sum';
if (empty($time)) {
$time = date('U');
}
@johann8384
johann8384 / create_table.rb
Last active October 30, 2017 03:23
Creating Tables for OpenTSDB
# usage: ./create_table.rb tsdb 255
include Java
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.HTableDescriptor
import org.apache.hadoop.hbase.client.HBaseAdmin
import org.apache.hadoop.hbase.HColumnDescriptor
conf = HBaseConfiguration.create
conf.set("zookeeper.znode.parent", "/hbase-unsecure");
@johann8384
johann8384 / post-receive
Created October 17, 2013 19:39
post-receive hook for synchronizing BIND masters
#!/bin/bash
unset GIT_DIR
REPO_DIR=/var/lib/gitosis/repositories/internal_dns.git
CLONE_DIR=/var/named/chroot/var/named/data
ERR_OUT=/tmp/named_error.out.$$
if [ ! -e "${CLONE_DIR}/.git" ]; then
git clone "$REPO_DIR" "$CLONE_DIR"
@johann8384
johann8384 / example.pp
Created November 5, 2013 18:53
Exported vars through PuppetDB I find it useful sometimes to be able to share bits of information between nodes. For example, I can have all of the nodes in a cluster register their IP addresses.
::magic::register { 'hadoop_datanode_fqdn':
value => $fqdn,
}
::magic::register { 'hadoop_datanode_ip':
value => $ip,
}
$reg = query_registrations('hadoop_datanode_fqdn')
@johann8384
johann8384 / auth.php
Last active December 28, 2015 11:49 — forked from cubehouse/auth.php
#!/usr/bin/php
<?php
/*
Copyright (c) <2005> LISSY Alexandre, "lissyx" <alexandrelissy@free.fr>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software andassociated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
#! /usr/bin/env bash
BRANCH=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
TARGET=Contegix
ISSUE=0
USER=johann8384
while getopts “hi:p:r:l:cf” OPTION
do