#! /bin/zsh # # this file: # https://dataswamp.org/~incal/scripts/speed # # original script: # https://dataswamp.org/~solene/2021-07-19-simple-scripts.html # # usage: # $ watch -n 1 -t speed # # example output: # _______________¯_________________________¯_________________________________ # __________________________________________________¯________________________ # _____________________________________________N___________________¯_________ # # screenshot: # https://dataswamp.org/~incal/figures/speed.png (592 bytes) data_dir=/tmp/speed-data mkdir -p $data_dir data=${data_dir}/speed bar=${data_dir}/bar dig srv.dataswamp.org @9.9.9.9 +timeout=1 > $data if [[ $? = 0 ]]; then echo -n $(awk '/Query time/{ if ( $4 < 60) { print "_"; } if ( 60 <= $4 && $4 <= 150) { print "-"; } if (150 < $4) { print "¯"; } }' $data) >> $bar else echo -n "N" >> $bar fi echo $(cat $bar)