Browse Source

Improve speed, remove insane amounts of jq calls and add time selector

master
Alex 2 years ago
parent
commit
da28bb12e0
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
  1. 12
      fetchparse.sh
  2. 4
      gnuplot

12
fetchparse.sh

@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
#!/bin/zsh
QUEUE="$(curl -sSL 'https://2b2t.io/api/queue?range=1h')"
PRIO="$(curl -sSL 'https://2b2t.io/api/prioqueue?range=1h')"
PLAY="$(curl -sSL 'https://2b2t.io/api/pingstats?range=1h')"
QUEUE="$(curl -sSL https://2b2t.io/api/queue\?range=$1)"
PRIO="$(curl -sSL https://2b2t.io/api/prioqueue\?range=$1)"
PLAY="$(curl -sSL https://2b2t.io/api/pingstats\?range=$1)"
function gnuplot-parsable {
for ((i=0; i<$(print $1 | jq ".|length");i++)); do
printf "%s\t%s\n" $(print $1 | jq ".[$i][0]") $(print $1 | jq ".[$i][1]");
TIMES=($(print $1 | jq '.[][0]'))
VALUES=($(print $1 | jq '.[][1]'))
for ((i=0; i<${#TIMES[@]};i++)); do
printf "%s\t%s\n" $TIMES[$i] $VALUES[$i];
done
}
gnuplot-parsable "$QUEUE" > queuedata

4
gnuplot

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
set xdata time
set timefmt "%s"
set grid
set terminal pngcairo size 1000,1000
set terminal pngcairo size 10000,1000
set output 'graph.png'
f(x)=sprintf("%d", x)
plot "queuedata" u (f($1)):2 w lp title "Queue", "priodata" u (f($1)):2 w lp title "Priority Queue", "playerdata" u (f($1)):2 w lp title "Players"
plot "queuedata" u (f($1)):2 w l title "Queue", "priodata" u (f($1)):2 w l title "Priority Queue", "playerdata" u (f($1)):2 w l title "Players"

Loading…
Cancel
Save