summary refs log tree commit diff
path: root/bin/kestrel-active-queues.sh
blob: 9cf85ce7cc5d729f320aed02e568ba766afb6100 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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