Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
@binarytemple
binarytemple / file_server.py
Last active August 29, 2015 14:19
quick n dirty file server written using the bottle framework... hardly any security, don't use for anything of value
from __future__ import unicode_literals
from bottle import Bottle, request, response,redirect,static_file,SimpleTemplate
import string, re, os, time
if not "uploads" in os.listdir("."):
raise Exception("'uploads' directory is not in the current directory")
app = Bottle()
template = """<html>
```
sudo pip install --upgrade pip setuptools
curl -L https://gist.githubusercontent.com/binarytemple/bc0e6f3e3586e4b9771e/raw/f446d289fc82a0d22b8720e2b6a1e233fce61078/plotiostat.py > ./plotiostat.py
chmod 755 ./plotiostat.py
sudo yum install sysstat
sudo yum install python-devel
pip install matplotlib
#!/bin/zsh
TARGS_W="-k ha_cnt_nosrv 'within[.] binh 900 1,10,100,1000,10000,100000' +k chat 'within[.] event' -k chat '+ within[.] duration drop binh 60 1,10,100,1000,10000,100000' -k '^ha_cnt' 'within[.] binh 900 1,10,100,1000,10000,100000' +k '^[^h]*[^a]*cnt' '+ within[.] binf 900 1,10,100,1000,10000,100000' -k cnt '+ within[.] binh 900 1,10,100,1000,10000,100000' +k err 'within[.] acount 900' -k err '+ within[.] event' -k evt 'within[.] acount 900' -dk none"
TARGS="-k ha_cnt_nosrv 'within[.] binh 900 1,10,100,1000,10000,100000' +k chat 'event' -k chat '+ duration drop binh 60 1,10,100,1000,10000,100000' -k '^ha_cnt' 'within[.] binh 900 1,10,100,1000,10000,100000' +k '^[^h]*[^a]*cnt' '+ within[.] binf 900 1,10,100,1000,10000,100000' -k cnt '+ within[.] binh 900 1,10,100,1000,10000,100000' +k err 'within[.] acount 900' -k err '+ within[.] event' -k evt 'within[.] acount 900' -dk none"
CHAT_ONLY="+k chat 'within[.] event' -k chat '+within[.] duration drop lines' -k -dk none"
eval "tplot -if ./haproxy.cs.p
#!/bin/zsh
TARGS_W="-k ha_cnt_nosrv 'within[.] binh 900 1,10,100,1000,10000,100000' +k chat 'within[.] event' -k chat '+ within[.] duration drop binh 60 1,10,100,1000,10000,100000' -k '^ha_cnt' 'within[.] binh 900 1,10,100,1000,10000,100000' +k '^[^h]*[^a]*cnt' '+ within[.] binf 900 1,10,100,1000,10000,100000' -k cnt '+ within[.] binh 900 1,10,100,1000,10000,100000' +k err 'within[.] acount 900' -k err '+ within[.] event' -k evt 'within[.] acount 900' -dk none"
TARGS="-k ha_cnt_nosrv 'within[.] binh 900 1,10,100,1000,10000,100000' +k chat 'event' -k chat '+ duration drop binh 60 1,10,100,1000,10000,100000' -k '^ha_cnt' 'within[.] binh 900 1,10,100,1000,10000,100000' +k '^[^h]*[^a]*cnt' '+ within[.] binf 900 1,10,100,1000,10000,100000' -k cnt '+ within[.] binh 900 1,10,100,1000,10000,100000' +k err 'within[.] acount 900' -k err '+ within[.] event' -k evt 'within[.] acount 900' -dk none"
CHAT_ONLY="+k chat 'within[.] event' -k chat '+within[.] duration drop lines' -k -dk none"
eval "tplot -if /tmp/haproxy.r
#!/bin/sh
tplot -if /tmp/everything.plot -o /tmp/everything.png -or 3000x25000 -k ha_nosrv 'within[.] acount 1' -k size 'within[.] dots' -k life 'within[.] dots' -k queue_time 'within[.] dots' -k connection 'within[.] binh 60 1,10,100,1000' -k connect_time 'within[.] dots' -k total_time 'within[.] dots' -k time 'within[.] duration dots' +k chat 'within[.] event' -k chat '+ within[.] duration drop binh 60 1,10,100,1000,10000,100000' +k cnt 'within[.] binf 900 1,10,100,1000,10000,100000' -k cnt '+ within[.] binh 900 1,10,100,1000,10000,100000' +k err 'within[.] acount 900' -k err '+ within[.] event' -k evt 'within[.] acount 900' -dk none &
tplot -fromTime '2014-11-07 00:00:00.000' -toTime '2014-11-09 23:59:00.000' -if /tmp/everything.plot -o /tmp/everything789.png -or 3000x25000 -k ha_nosrv 'within[.] acount 1' -k size 'within[.] dots' -k life 'within[.] dots' -k queue_time 'within[.] dots' -k connection 'within[.] binh 60 1,10,100,1000' -k connect_time 'within[.] dots' -k total_time 'within[.] dots' -k ti
sort -k1 /tmp/dvag.all.processed > /tmp/dvag.plot ;
tplot -if /tmp/dvag.plot -o /tmp/dvag.png -or 3000x25000 -k ha_nosrv 'within[.] acount 1' -k size 'within[.] dots' -k life 'within[.] dots' -k queue_time 'within[.] dots' -k connection 'within[.] binh 60 1,10,100,1000' -k connect_time 'within[.] dots' -k total_time 'within[.] dots' -k time 'within[.] duration dots' +k chat 'within[.] event' -k chat '+ within[.] duration drop binh 60 1,10,100,1000,10000,100000' +k cnt 'within[.] binf 900 1,10,100,1000,10000,100000' -k cnt '+ within[.] binh 900 1,10,100,1000,10000,100000' +k err 'within[.] acount 900' -k err '+ within[.] event' -k evt 'within[.] acount 900' -dk none
#!/bin/sh
cat /tmp/dvag.all.processed /tmp/haproxy.riakcs.plot /tmp/haproxy.riakeds.plot | sort -k1 > /tmp/everything.plot
#!/bin/sh
cat /tmp/haproxy.riakcs.plot /tmp/haproxy.riakeds.plot | sort -k1 > /tmp/haproxy.both.plot

Wrapper shell script:

$ cat ./riak_cs_inspector.sh
#!/bin/bash
ERL_LIBS=dev/dev1/lib dev/dev1/erts-5.9.3.1/bin/escript \
    dev/dev1/lib/riak_cs/priv/tools/internal/riak_cs_inspector.erl $*

Usage:

@binarytemple
binarytemple / ring.erl.converted.for.tanodb.mark
Last active November 18, 2015 17:40 — forked from bsparrow435/ring.erl
tanodb getting preflist
```
Calc = fun(Bucket,Key) ->
BKey = {Bucket,Key},
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
DocIdx = riak_core_util:chash_key(BKey),
NValue = 1,
UpNodes = riak_core_node_watcher:nodes(tanodb),
Preflist2 = riak_core_apl:get_apl_ann(DocIdx, NValue, Ring, UpNodes),
[Res] = [Part || {{Part,Node}, Type} <- Preflist2],
Res