Skip to content

Instantly share code, notes, and snippets.

View philipcristiano's full-sized avatar

Philip Cristiano philipcristiano

View GitHub Profile
@philipcristiano
philipcristiano / gist:3d306c0fd054934152ad
Created December 9, 2014 19:44
Python semver from git tag for PBR
if git describe --exact-match 2> /dev/null; then
VERSION=$(git describe)
else
VERSION=$(git describe | sed -E 's/([0-9]+)\.([0-9]+)-([0-9]+).*/\1.\2.\3/')
git tag -a "$VERSION" -m "Tagging version \"${VERSION}\""
fi
@philipcristiano
philipcristiano / gist:9f16cb30196383580e13
Last active August 29, 2015 14:12
Erlang vnode test init
init_per_testcase(_, Config) ->
{ok, Pid} = riak_core_vnode:start_link(etsdb_vnode, 0, []),
[{vnode, Pid}| Config].
end_per_testcase(_, Config) ->
Pid = ?config(vnode, Config),
send_command(Pid, stop),
ok.
-include_lib("riak_core/include/riak_core_vnode.hrl").
send_command(Pid, Request) ->
Ref = make_ref(),
gen_fsm:send_event(Pid, ?VNODE_REQ{request=Request,
sender={raw, Ref, self()}}),
{ok, Ref}.
get_response(Ref) ->
receive {Ref, M} -> {ok, M}
try:
with util.ipmi(util.get_lom_ip(self.host))) as ipmi:
ipmi.foo()
except exceptions.IPMIError:
self._unwind("Failed to connect to IPMI", exceptions.IPMIError)
raise
@philipcristiano
philipcristiano / test_statsd.py
Created February 22, 2012 19:12
Test script for statsd
import random
import time
from pystatsd import Client, Server
sc = Client('statsd.local.vm',8125)
while True:
sc.increment('python_test.inc_int')
time.sleep(random.random())
@philipcristiano
philipcristiano / alerts.yml
Created October 8, 2012 00:48
Graphite Pager alert example
alerts:
- target: carbon.agents.*.metricsReceived
warning: 10
crticial: 0
name: Graphite Metrics Received
@philipcristiano
philipcristiano / t2g.py
Created October 12, 2012 00:51
Twitter Search to Graphite
import calendar
import json
import socket
import time
import requests
from dateutil.parser import parse
graphite_server = 'localhost'
@philipcristiano
philipcristiano / create_event.py
Created December 12, 2012 17:12
Tracelytics Tornado Oboe errors with version 1.3.4
File "/apps/production/api/virtualenvs/api/local/lib/python2.7/site-packages/tornado/ioloop.py", line 327, in start
self._handlers[fd](fd, events)
File "/apps/production/api/virtualenvs/api/local/lib/python2.7/site-packages/tornado/stack_context.py", line 190, in __call__
return super(_StackContextWrapper, self).__call__(*args, **kwargs)
File "/apps/production/api/virtualenvs/api/local/lib/python2.7/site-packages/tornado/curl_httpclient.py", line 133, in _handle_events
self._finish_pending_requests()
File "/apps/production/api/virtualenvs/api/local/lib/python2.7/site-packages/tornado/curl_httpclient.py", line 187, in _finish_pending_requests
self._finish(curl)
@philipcristiano
philipcristiano / gist:4415737
Last active December 10, 2015 09:39
Running Klout-to-Graphite
pip install klout-to-graphite
export KLOUT_KEY="YOUR KLOUT KEY"
cat twitter_usernames.txt | klout_to_graphite --graphite-host graphite.example.com