Created
May 19, 2016 21:28
-
-
Save flxai/d5605b8099381bb42475eea2fd3ac672 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# 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