summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck.cuny@gmail.com>2016-12-08 14:37:55 -0800
committerFranck Cuny <franck.cuny@gmail.com>2016-12-08 14:37:55 -0800
commite70d1a06632f3dfbfcfb034e2445e2e6f96725a0 (patch)
treee8c686e12155aa90d5e7c95164d618ddb83ad550
parent[bin] Some targets were renamed. (diff)
downloademacs.d-e70d1a06632f3dfbfcfb034e2445e2e6f96725a0.tar.gz
[bin] Script to get stats from Kestrel.
Diffstat (limited to '')
-rwxr-xr-xbin/kestrel-active-queues.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/kestrel-active-queues.sh b/bin/kestrel-active-queues.sh
new file mode 100755
index 0000000..9cf85ce
--- /dev/null
+++ b/bin/kestrel-active-queues.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+CLUSTER="${1:-kestrel.prod.low_sla}"
+
+for zone in atla smf1; do
+  echo "querying $zone/$CLUSTER"
+
+  tmpfile=$(mktemp "/tmp/${CLUSTER}-${zone}.XXXXXX")
+  csvout="$(dirname $0)/${CLUSTER}-${zone}.csv"
+
+  # first filter the metrics we want
+  cql -z "${zone}" k "${CLUSTER}" "sd.${CLUSTER}" | grep -e 'get_items_hit' > "${tmpfile}"
+
+  # remove the csv output file if it exists
+  [ -e "${csvout}" ] && rm "${csvout}"
+
+  # then we build the csv
+  for queue in $(cat "${tmpfile}"); do
+    total_hits=$(cql -z "${zone}" q -d 86400 "sum(default(0, rate(ts(sum, ${CLUSTER}, members(sd.${CLUSTER}), ${queue}))))"|awk '{sum+=$8} END{print sum}')
+    queue_name=$(echo ${queue} | sed -e 's/^q\/\(.*\)\/.*$/\1/')
+    echo "${queue_name};${total_hits}" >> "${csvout}"
+  done
+
+  rm "${tmpfile}"
+done