Skip to content

Instantly share code, notes, and snippets.

Christian Dahlqvist cdahlqvist

Block or report user

Report or block cdahlqvist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cdahlqvist
cdahlqvist / keylister.erl
Last active Dec 15, 2015
Script to list all keys in a Riak bucket and spool to a file. To be run while attached to riak console.
View keylister.erl
%% -------------------------------------------------------------------
%%
%% keylister: Utility for listing all keys in a bucket
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
@cdahlqvist
cdahlqvist / riak_graphite.erl
Last active Dec 16, 2015
Server process for sending statistics to Graphite from Riak
View riak_graphite.erl
%% -------------------------------------------------------------------
%%
%% riak_graphite: Server process to emit statistics to Graphite
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
View pb_status_anon.txt
PBStatusFun = fun() ->
VnodePids = [Pid || {_, Pid} <- riak_core_vnode_manager:all_index_pid(riak_kv_vnode)],
Links = [process_info(Pid, [links]) || Pid <- VnodePids],
WorkerPoolPids = [WPPid || [{links,[_, WPPid]}] <- Links],
WorkerPoolLinks = [process_info(Pid, [links]) || Pid <- WorkerPoolPids],
PoolboyPids = [PoolboyPid || [{links,[_, PoolboyPid]}] <- WorkerPoolLinks],
[poolboy:status(Pid) || Pid <- PoolboyPids]
end.
PBStatusCountFun = fun() ->
@cdahlqvist
cdahlqvist / pb_status_monitor.erl
Created May 24, 2013
Process that monitors the status of the poolboy worker pool used for coverage queries.
View pb_status_monitor.erl
%% -------------------------------------------------------------------
%%
%% pb_status_monitor: PoolBoy pool monitor
%%
%% Copyright (c) 2013 Basho Technologies, Inc. All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
View gist:5823692
#!/usr/bin/env escript
%% -*- erlang -*-
-include_lib("kernel/include/file.hrl").
-compile(export_all).
-define(LOG(S), io:format(S)).
-define(LOG(S,A), io:format(S,A)).
main(Dirs) ->
CodePath = case os:getenv("RIAK_LIB") of
View _.md

This is an erlang snippet to be run from a riak attach session

After pasting the following into the attach session, to repair all riak_kv partitions, run

RepairProc = RepairAllKv(60).

or, to repair all riak_search partitions, run

RepairProc = RepairAllSearch(60).
View robin_handoff.erl
-module(robin_handoff).
-export([start/0,start/1,start/2,stop/0]).
-export([step/0]).
%% see if a handoff is in progress
active_count(Node) when is_atom(Node) ->
Receivers=rpc:call(Node,supervisor,count_children,[riak_core_handoff_receiver_sup]),
View riak_cs_data_usage.erl
#!/usr/bin/env escript
main(Args) ->
% - From nodetool ------------------------------------------------------- %
{_, TargetNode} = process_args(Args, [], undefined),
case {net_kernel:connect_node(TargetNode), net_adm:ping(TargetNode)} of
{true, pong} ->
View Riak CRDT HTTP Examples
Start a Riak 2.0 cluster. This has been tested against Riak 2.0.0pre11.
First set up bucket types (note you can name these as you like for your domain (and add other properties)
$ rel/riak/bin/riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
maps created
$ rel/riak/bin/riak-admin bucket-type create sets '{"props":{"datatype":"set"}}'
sets created
$ rel/riak/bin/riak-admin bucket-type create counters '{"props":{"datatype":"counter"}}'
counters created
@cdahlqvist
cdahlqvist / statslogger.py
Last active Aug 29, 2015
Simple script that logs a set of Riak statistics to a daily CSV file once a minute
View statslogger.py
#!/usr/bin/env python
import httplib
import json
from datetime import datetime, date, time
from time import sleep
import os.path
from multiprocessing import Process
You can’t perform that action at this time.