Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ferric-sol/5d80a08b83779a0e27070843df2e5231 to your computer and use it in GitHub Desktop.
Save ferric-sol/5d80a08b83779a0e27070843df2e5231 to your computer and use it in GitHub Desktop.
Dishy stats
#!/bin/bash
RAW_STATUS=$(python3 ~/src/starlink-grpc-tools/dish_grpc_text.py -s 2 status)
STARLINK_CONNECTED=$(echo "$RAW_STATUS" | cut -f 5 -d',')
if [[ "${STARLINK_CONNECTED}" == "CONNECTED" ]]; then
STARLINK_CONNECTED='${color green}'"CONNECTED"'${color}'
elif [[ "${STARLINK_CONNECTED}" == "OFFLINE" ]]; then
STARLINK_CONNECTED='${color red}'"OFFLINE"'${color}'
else
STARLINK_CONNECTED='${color yellow}'"${STARLINK_CONNECTED}"'${color}'
fi
STARLINK_UPTIME=$(echo "$RAW_STATUS" | cut -f 6 -d',')
STARLINK_UPTIME_HUMAN_READABLE=$(printf '%02dh:%02dm:%02ds\n' $((STARLINK_UPTIME/3600)) $((STARLINK_UPTIME%3600/60)) $((STARLINK_UPTIME%60)))
STARLINK_PING_DROP_RATE=$(echo "$RAW_STATUS" | cut -f 9 -d',' | cut -f1 -d'.')
STARLINK_POP_PING_LATENCY_MS=$(printf "%.2f" "$(echo "$RAW_STATUS" | cut -f 12 -d',')")
STARLINK_CURRENTLY_OBSTRUCTED=$(echo "$RAW_STATUS" | cut -f 15 -d',')
STARLINK_SECONDS_OBSTRUCTED=$(printf "%.2f" "$(echo "$RAW_STATUS" | cut -f 16 -d',')")
STARLINK_OBSTRUCTION_DURATION=$(printf "%.2f" "$(echo "$RAW_STATUS" | cut -f 17 -d',')")
STARLINK_OBSTRUCTION_INTERVAL=$(printf "%i" "$(echo "$RAW_STATUS" | cut -f 18 -d',' | cut -f1 -d'.')")
STARLINK_OBSTRUCTION_INTERVAL_HUMAN_READABLE=$(printf '%02dh:%02dm:%02ds\n' $((STARLINK_OBSTRUCTION_INTERVAL/3600)) $((STARLINK_OBSTRUCTION_INTERVAL%3600/60)) $((STARLINK_OBSTRUCTION_INTERVAL%60)))
# Unused variables you might want.
#STARLINK_SNR=$(echo "$RAW_STATUS" | cut -f 7 -d',')
#STARLINK_SECONDS_TO_FIRST_NONEMPTY=$(echo "$RAW_STATUS" | cut -f 8 -d',')
#STARLINK_DOWNLINK_THROUGHPUT_BPS=$(echo "$RAW_STATUS" | cut -f 10 -d',')
#STARLINK_UPLINK_THROUGHPUT_BPS=$(echo "$RAW_STATUS" | cut -f 11 -d',')
#STARLINK_ALERTS=$(echo "$RAW_STATUS" | cut -f 13 -d',')
#STARLINK_FRACTION_OBSTRUCTED=$(echo "$RAW_STATUS" | cut -f 14 -d',')
#STARLINK_DIRECTION_AZIMUTH=$(printf "%.2f" "$(echo "$RAW_STATUS" | cut -f 19 -d',')")
#STARLINK_DIRECTION_ELEVATION=$(printf "%.2f" "$(echo "$RAW_STATUS" | cut -f 20 -d',')")
if [[ "${STARLINK_CURRENTLY_OBSTRUCTED}" == "True" ]]; then
STARLINK_OBSTRUCTION_STATUS='${color red}'"Obstructed"'${color}'" for ${STARLINK_SECONDS_OBSTRUCTED} seconds every ${STARLINK_OBSTRUCTION_INTERVAL_HUMAN_READABLE}"
elif [[ "${STARLINK_CURRENTLY_OBSTRUCTED}" == "False" ]]; then
STARLINK_OBSTRUCTION_STATUS='${color green}'"Unobstructed"'${color}'" for ${STARLINK_OBSTRUCTION_INTERVAL_HUMAN_READABLE}\n"'${alignr}'"Last obstruction lasted ${STARLINK_OBSTRUCTION_DURATION}s"
fi
STARLINK_PING_DROP_STATUS=""
if [ $STARLINK_PING_DROP_RATE -gt 0 ]; then
STARLINK_PING_DROP_STATUS=", drops every ${STARLINK_PING_DROP_RATE} seconds"
fi
# export -p | grep STARLINK_
echo -e '${alignr}'"$STARLINK_CONNECTED for ${STARLINK_UPTIME_HUMAN_READABLE}"
echo -e '${alignr}'"${STARLINK_POP_PING_LATENCY_MS}ms latency${STARLINK_PING_DROP_STATUS}"
#echo -e '${alignr}'"Azmth ${STARLINK_DIRECTION_AZIMUTH} @ ${STARLINK_DIRECTION_ELEVATION} metres elevation"
echo -e '${alignr}'"${STARLINK_OBSTRUCTION_STATUS}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment