Commit 9b6eb4d5 authored by Ralf's avatar Ralf

init

parents
TIME=$(date +%s)
STEP=120
function display {
# $1: first line
# $2: 2nd line
echo -ne '\e[1;1H\e[2J' # reset display content and cursor
echo -n "$1"
echo -ne '\n' # move to second line
echo -n "$2"
}
function show_bw {
RX=$(curl -s "https://mgmt.saar.freifunk.net/grafana/api/datasources/proxy/1/api/v1/query_range?query=total_traffic_rx_bits_per_second&start=$TIME&end=$TIME&step=$STEP" | jq .data.result[0].values[0][1] | cut -d '"' -f 2)
TX=$(curl -s "https://mgmt.saar.freifunk.net/grafana/api/datasources/proxy/1/api/v1/query_range?query=total_traffic_tx_bits_per_second&start=$TIME&end=$TIME&step=$STEP" | jq .data.result[0].values[0][1] | cut -d '"' -f 2)
RX=$(bc <<< "scale=1; $RX/1024/1024")
TX=$(bc <<< "scale=1; $TX/1024/1024")
display "$RX MBit/s down" "$TX MBit/s up"
}
function show_users {
CLIENTS=$(curl -s "https://mgmt.saar.freifunk.net/grafana/api/datasources/proxy/1/api/v1/query_range?query=total_clients&start=$TIME&end=$TIME&step=$STEP" | jq .data.result[0].values[0][1] | cut -d '"' -f 2)
NODES=$(curl -s "https://mgmt.saar.freifunk.net/grafana/api/datasources/proxy/1/api/v1/query_range?query=meshnodes_online_total&start=$TIME&end=$TIME&step=$STEP" | jq .data.result[0].values[0][1] | cut -d '"' -f 2)
display "$CLIENTS Clients" "$NODES Knoten"
}
while true; do
show_bw
sleep 5
show_users
sleep 5
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment