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 / gist:6c2fa45b0f194401720a
Last active August 29, 2015 14:26 — forked from mfournier/gist:5883828
example collectd processes plugin
<Plugin "processes">
ProcessMatch "carbon-cache" "python.+carbon-cache"
ProcessMatch "carbon-aggregator" "python.+carbon-aggregator"
</Plugin>
#! /bin/bash
echo Creating Combined console.log
for I in *-riak-debug; do NODE=${I//-riak-debug/}; echo " Processing ${NODE}..."; for J in $I/logs/platform_log_dir/console.lo*; do sed -n -e '/^2015/!{H;d;};/^2015/{x;s/\n/ /g;p;};${x;s/\n/ /g;p;}' $J | awk '!/^$/{print $1"T"$2,"'${NODE}'",$0}' | sed 's/\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\) \(.*\)/\1 \2 \5/' >> temp.log ; done; done; sort temp.log > combined_console.log;rm temp.log;
echo Creating Combined error.log
for I in *-riak-debug; do NODE=${I//-riak-debug/}; echo " Processing ${NODE}..."; for J in $I/logs/platform_log_dir/error.lo*; do sed -n -e '/^2015/!{H;d;};/^2015/{x;s/\n/ /g;p;};${x;s/\n/ /g;p;}' $J | awk '!/^$/{print $1"T"$2,"'${NODE}'",$0}' | sed 's/\([^ ]*\) \([^ ]*\) \([^ ]*\) \([^ ]*\) \(.*\)/\1 \2 \5/' >> temp.log ; done; done; sort temp.log > combined_error.log;rm temp.log;
echo Checking for LevelDB Compaction Errors
find . -name "LOG" -exec grep -l 'Compaction error' {} \;
This gist captures what needs to be done to add a new field to Riak's Yokozuna
search index.
Sources:
- https://github.com/basho/yokozuna/issues/130
- http://riak-users.197444.n3.nabble.com/How-to-update-existed-schema-td4032143.html
The code below is for illustration purposes only. Use at your own risk.
1. Create/Update new schema file
@binarytemple
binarytemple / erlang_notes.markdown
Last active July 30, 2018 15:13 — forked from hcs42/erlang_notes
Csaba's Erlang notes

Loading modules

Purging = removing the old version of the module (so that it will only have a new version).

erlang:check_old_code(mymodule).

Return if the module has an old version loaded.

code:load_file(mymodule).

@binarytemple
binarytemple / gbr.txt
Last active August 29, 2015 14:23 — forked from viktorklang/gbr.txt
alias gbr='git for-each-ref --sort="-authordate:iso8601" --format=" %(color:green)%(authordate:iso8601)%09%(color:white)%(refname:short)" refs/heads'
%% riak_dt_map: OR-Set schema based multi CRDT container
M = riak_dt_map:new(),
%% Braxton adds key and val fields
{ok, M1B} = riak_dt_map:update({update, [
{add, {key, riak_dt_lwwreg}},
{add, {val, riak_dt_pncounter}}
]}, braxton, M),
%% Braxton sets key to 'a' and increments val by 1
{ok, M2B} = riak_dt_map:update({update, [
{update, {key, riak_dt_lwwreg}, {assign, a}},
%% These are shell functions that can be used to output a keylist from a bitcask file in terms of Riak {Bucket,Key} tuples
%% They should be run from `riak attach`. Paste in the contents and run ListAll("filename.txt"). Profit.
ListCask = fun(Vnode,OutFile) ->
Fold_data = fun(Handle) ->
FoldFun = fun(Bytes, X, Y, {ok, Acc}) ->
case Bytes of
<<1:7, 0:1,Sz:16/integer,Bucket:Sz/bytes, Key/binary>> ->
io:format(OutFile, "~s/~s~n", [binary_to_list(Bucket),binary_to_list(Key)]), {ok, Acc + 1};

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two

#Map Reduce Delete Instructions

Set allow_strfun true on all nodes:

echo "rpc:multicall([node() | nodes()], application,set_env,[riak_kv,allow_strfun,true])." | bin/riak attach

Insert 15000 keys:

for i in {1..15000}; do curl -XPUT http://127.0.0.1:9000/buckets/test/keys/test$i -H "content-type: text/plain" -d "Data #$i\n"; done