Skip to content

Instantly share code, notes, and snippets.

View jroyalty's full-sized avatar

James Royalty jroyalty

View GitHub Profile
@jroyalty
jroyalty / haproxy_observe_check.md
Last active August 29, 2015 13:57
Notes on where HAProxy handles the "observe" check

Various HTTP states along the pipline are grouped into HANA_STATUS_* codes, which are defined in checks.h. Then health_adjust() is called with that status code, which ends up calling __health_adjust() if the observe config parameter is enabled.

Example from proxy_http.c:

/* Adjust server's health based on status code. Note: status codes 501
 * and 505 are triggered on demand by client request, so we must not
 * count them as server failures.
 */
if (objt_server(s->target)) {

This creates a self-signed cert.

openssl req \
-x509 -nodes -days 365 \
-newkey rsa:2048 -keyout mycert.pem -out mycert.pem
@jroyalty
jroyalty / init.js
Last active August 29, 2015 14:07
A Javascript-based query library for time series data. This is particular to OpenTSDB-style data at the moment.
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
@jroyalty
jroyalty / Rule.java
Created January 19, 2015 04:07
OpenTSDB KV match rule
public class Rule {
static enum MatchAction {
OUTPUT, OUTPUT_WITH_TAGS, IGNORE;
};
static enum OutputFormat {
KV, KV_DELIM, KV_JSON, LIST, LIST_DELIM, LIST_JSON, HASH;
};
private String metricMatch;
UP
@jroyalty
jroyalty / pyKairosDB-graphite.py
Created January 2, 2014 21:48
Snippet from that takes time-series data without a fixed interval and returns it bucketed by a configurable size (interval_seconds). This is abstracted from: https://github.com/pcn/pyKairosDB/blob/master/pyKairosDB/graphite.py ... This would be easily adapted for use by an OpenTSDB reader for Graphite.
def read_absolute(conn, metric_name, start_time, end_time):
"""
:type conn: pyKairosDB.KairosDBConnection
:param conn: The connection to KairosDB
:type metric_name: string
:param metric_name: The name of the metric to query (graphite does one at a time, though KairosDB can do more)
:type start_time: float
@jroyalty
jroyalty / test.c
Created January 19, 2016 20:36
Netmask for IPv4 source
#include <stdio.h>
#include <stdlib.h>
#include <maxminddb.h>
int main(int argc, const char * argv[]) {
MMDB_s *mmdb = (MMDB_s *)malloc(sizeof(MMDB_s));
MMDB_open("/tmp/GeoIP2-City_20160105/GeoIP2-City.mmdb",
MMDB_MODE_MMAP, mmdb);
int gai_error = 0;
@jroyalty
jroyalty / CMakeLists.txt
Last active February 29, 2016 15:53
dhewm3neo/CMakeLists.txt ... Patches to builds on OS X.
project(dhewm3)
cmake_minimum_required(VERSION 2.6)
# TODO
# osx: place game .dylib's in the bundle (next to the binary)
# osx: -weak_framework ?
# maybe add these as options:
# TARGET_MONO
@jroyalty
jroyalty / nfqlistener.py
Created December 28, 2016 20:14
Twisted listener for NFQ
import logging
import socket
from twisted.internet import abstract, address, interfaces, defer
from zope.interface import implementer
try:
import netfilterqueue
except:
netfilterqueue = None
@jroyalty
jroyalty / CMakeLists.txt
Created May 5, 2017 04:23
Little CMake config for LMDB
# vim: set ai ts=4 expandtab:
# ::=========================================================================::
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# The following must be set BEFORE doing project() or enable_language().
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type defined; defaulting to 'Debug'")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"The type of build. Possible values are: Debug, Release, RelWithDebInfo and MinSizeRel.")