storj_telegraf_mon icon indicating copy to clipboard operation
storj_telegraf_mon copied to clipboard

Show GET/PUT, etc Count By Satellite

Open gsxryan opened this issue 5 years ago • 7 comments

Specs Organized by Sat.

GETs Sat1: 160 sat 2: 15

gsxryan avatar Jul 19 '19 06:07 gsxryan

from robertstansfield:

` #!/bin/bash audits=$(mktemp) sats=$(mktemp)

docker logs storagenode 2>&1 | grep GET_AUDIT > $audits

cat $audits | cut -f5 | cut -f5 -d " " | cut -f2 -d """ > ${sats} known_sats=$(sort ${sats} | uniq)

for sat in $known_sats; do echo -e "Sat ID:\t\t\t\t$sat" echo -e "Unrecoverable Failed Audits:\t$(cat "$audits" | grep failed | grep open | grep -c "$sat")" echo -e "Recoverable Failed Audits:\t$(cat "$audits" | grep failed | grep -v open | grep -c "$sat")" echo -e "Successful Audits:\t\t$(cat "$audits" | grep downloaded | grep -c "$sat")" done

rm $sats rm $audits `

gsxryan avatar Jul 20 '19 01:07 gsxryan

cut -f2 -d """ > ${sats}

should read as

cut -f2 -d " " > ${sats}

juergschwarz avatar Jul 28 '19 09:07 juergschwarz

Idk where yall get these bash scripts from but they make anyone who knows how to bash cringe :) here, use this script instead:

#!/bin/bash
audits=$(mktemp)

docker logs storagenode 2>&1 | grep GET_AUDIT > $audits
known_sats=($(grep -oP '(?<=Satellite ID": ")\w+' $audits|sort -u))
for sat in "${known_sats[@]}";do
echo -e "Sat ID:\t\t\t\t$sat
Unrecoverable Failed Audits:\t$(grep -c "failed.*${sat}.*open" $audits)
Recoverable Failed Audits:\t$(grep -Pc "failed.*${sat}(?!.*open)" $audits)
Successful Audits:\t\t$(grep -c "downloaded.*${sat}" $audits)"
done

rm -f $audits

Sample output:

# bash audits.sh
Sat ID:				118UWpMCHzs6CvSgWd9BfFVjw5K9pZbJjkfZJexMtSkmKxvvAW
Unrecoverable Failed Audits:	0
Recoverable Failed Audits:	0
Successful Audits:		2

AndreiG6 avatar Nov 21 '19 12:11 AndreiG6

Haha. I don't work with bash much. I do migrate quite a bit of bash to powershell. I appreciate the input and will learn some from your pull.

gsxryan avatar Nov 21 '19 13:11 gsxryan

regex goes a long way :) now I just need to find that page on storj again where they suggested madness like grep GET|grep|stuff|awk.. I stumbled on it by accident when reviewing the log entries for that pull (#23)

AndreiG6 avatar Nov 21 '19 14:11 AndreiG6

It was sourced from Alexey on Storj's RocketChat. And we just built on it from here. My goal was a working dashboard. Glad that someone is looking into performance and optimization now. I usually only use Regex when absolutely required, because it doesn't come natural for me.

gsxryan avatar Nov 24 '19 01:11 gsxryan

Glad to help, optimizing is my thing :) I'll have to keep digging for Alexey's post and suggest some corrections

AndreiG6 avatar Nov 24 '19 03:11 AndreiG6