riak -> librato stats cron job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# * * * * * root /path/to/riak_stats.sh | |
set -e | |
SOURCE=$(hostname) | |
LIBRATO_USERID="" | |
LIBRATO_TOKEN="" | |
PREFIX="test.riak" | |
STATUS=$(riak-admin status) | |
VARIABLES=("vnode_gets" "vnode_puts" "read_repairs" "node_gets" "node_puts" "cpu_nprocs" "sys_process_count" "pbc_connects" "pbc_active" \ | |
"node_get_fsm_time_mean" "node_get_fsm_time_median" "node_get_fsm_time_95" "node_get_fsm_time_99" "node_get_fsm_time_100" \ | |
"node_put_fsm_time_mean" "node_put_fsm_time_median" "node_put_fsm_time_95" "node_put_fsm_time_99" "node_put_fsm_time_100") | |
IDX=0 | |
PARAMS=() | |
for STAT in ${VARIABLES[@]}; do | |
RE_PREFIX=$'(\n|^)' | |
RE_SUFFIX=$' : ([^\n]*)' | |
RE="$RE_PREFIX$STAT$RE_SUFFIX" | |
if [[ "$STATUS" =~ $RE ]]; then | |
VALUE=${BASH_REMATCH[2]} | |
PARAMS+=("-d" "gauges[$IDX][name]=$PREFIX.$STAT") | |
PARAMS+=("-d" "gauges[$IDX][value]=$VALUE") | |
PARAMS+=("-d" "gauges[$IDX][source]=$SOURCE") | |
IDX=$(($IDX + 1)) | |
fi | |
done | |
curl -v --max-time 15 \ | |
-u ${LIBRATO_USERID}:${LIBRATO_TOKEN} \ | |
${PARAMS[@]} \ | |
-X POST https://metrics-api.librato.com/v1/metrics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment