Skip to content

Instantly share code, notes, and snippets.

@flxai
Created May 19, 2016 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flxai/d5605b8099381bb42475eea2fd3ac672 to your computer and use it in GitHub Desktop.
Save flxai/d5605b8099381bb42475eea2fd3ac672 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Count users currently logged into a list of Freifunk Kassel nodes
url_base=https://graphite.freifunk-kassel.de
url_params="rawData=true"
time_offset="5min"
node_pre="ffks.nodes."
node_post=".clients"
declare -a node_ids=(ffks-Flipdot flipdot-offloader liberation-box calden-test-a00 calden-test-a07 calden-test-a11 calden-test-a14)
nodes=""
for n in ${node_ids[@]}; do
nodes="$nodes$node_pre$n$node_post,"
done
nodes="$(echo $nodes| rev | cut -c2- | rev)"
target_pre="sum("
target_post=")"
target="$target_pre$nodes$target_post)"
url="$url_base/render/?$url_params&target=$target&from=now-$time_offset&to=now"
echo "URL: $url"
n=$(curl -k "$url" | awk -F \| '{print $2}' | awk -F\, '{print $NF}')
if [[ "$n" == "None" ]]; then
n=0
else
n=${n/.*}
fi
echo $n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment