forked from shihaam/starlink_status
refactor speedtest, added support for fast
This commit is contained in:
parent
73675b8532
commit
73c61a98d6
@ -1,7 +1,8 @@
|
|||||||
FROM archlinux
|
FROM archlinux
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
RUN pacman -Sy --noconfirm mpv jq curl speedtest-cli
|
RUN pacman -Sy --noconfirm mpv jq curl speedtest-cli bc npm \
|
||||||
|
&& npm install --global fast-cli
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
59
bot.sh
59
bot.sh
@ -6,7 +6,8 @@ while true; do
|
|||||||
|
|
||||||
date=$(date "+%Y%m%d_%H%M%S")
|
date=$(date "+%Y%m%d_%H%M%S")
|
||||||
image=data/image_$date.png
|
image=data/image_$date.png
|
||||||
speedtest_result=data/speedtest_$date.txt
|
speedtest_ookla=data/speedtest_ookla_$date.json
|
||||||
|
speedtest_fast=data/speedtest_fast_$date.json
|
||||||
weather_file=data/weather_$date.json
|
weather_file=data/weather_$date.json
|
||||||
edited_image=data/edited_image_$date.png
|
edited_image=data/edited_image_$date.png
|
||||||
|
|
||||||
@ -18,28 +19,36 @@ echo Image grabbed
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
#################################################################################
|
#################################################################################
|
||||||
echo Doing speedtest
|
echo Doing speedtest by Ookla
|
||||||
# Run speedtest and output to a file
|
# Run speedtest and output to a file
|
||||||
speedtest --json > $speedtest_result
|
speedtest --json > $speedtest_ookla
|
||||||
# Extract information from the speedtest output
|
# Extract information from the speedtest output
|
||||||
|
|
||||||
# Parsing JSON data
|
# Parsing JSON data
|
||||||
download=$(jq '.download' "$speedtest_result")
|
ookla_server=$(jq -r '.server.sponsor' "$speedtest_ookla")
|
||||||
upload=$(jq '.upload' "$speedtest_result")
|
ookla_city=$(jq -r '.server.name' "$speedtest_ookla")
|
||||||
ping=$(jq '.ping' "$speedtest_result")
|
ookla_country=$(jq -r '.server.country' "$speedtest_ookla")
|
||||||
bytes_received=$(jq '.bytes_received' "$speedtest_result")
|
ookla_ping=$(jq '.ping' "$speedtest_ookla")
|
||||||
bytes_sent=$(jq '.bytes_sent' "$speedtest_result")
|
ookla_download=$(jq '.download' "$speedtest_ookla")
|
||||||
isp=$(jq -r '.client.isp' "$speedtest_result")
|
ookla_upload=$(jq '.upload' "$speedtest_ookla")
|
||||||
country=$(jq -r '.client.country' "$speedtest_result")
|
ooka_bytes_received=$(jq '.bytes_received' "$speedtest_ookla")
|
||||||
cc=$(jq -r '.client.cc' "$speedtest_result")
|
ooka_bytes_sent=$(jq '.bytes_sent' "$speedtest_ookla")
|
||||||
|
|
||||||
# Converting download and upload speeds from bytes per second to Mbit/s
|
# Converting download and upload speeds from bytes per second to Mbit/s
|
||||||
download_mbps=$(echo "scale=3; $download / 125000" | bc)
|
ookla_download_mbps=$(echo "scale=4; $download / 1000000" | bc)
|
||||||
upload_mbps=$(echo "scale=3; $upload / 125000" | bc)
|
ookla_upload_mbps=$(echo "scale=4; $upload / 1000000" | bc)
|
||||||
|
|
||||||
# Converting bytes to MB
|
# Converting bytes to MB
|
||||||
bytes_received_mb=$(echo "scale=2; $bytes_received / 1048576" | bc)
|
ookla_bytes_received_mb=$(echo "scale=2; $bytes_received / 1048576" | bc)
|
||||||
bytes_sent_mb=$(echo "scale=2; $bytes_sent / 1048576" | bc)
|
ookla_bytes_sent_mb=$(echo "scale=2; $bytes_sent / 1048576" | bc)
|
||||||
|
|
||||||
|
|
||||||
|
fast --upload --json > $speedtest_fast
|
||||||
|
fast_download_speed=$(jq '.downloadSpeed' "$speedtest_fast")
|
||||||
|
fast_upload_speed=$(jq '.uploadSpeed' "$speedtest_fast")
|
||||||
|
fast_latency=$(jq '.latency' "$speedtest_fast")
|
||||||
|
fast_downloaded=$(jq '.downloaded' "$speedtest_fast")
|
||||||
|
fast_uploaded=$(jq '.uploaded' "$speedtest_fast")
|
||||||
|
|
||||||
echo Speedtest complete
|
echo Speedtest complete
|
||||||
#################################################################################
|
#################################################################################
|
||||||
@ -68,10 +77,22 @@ echo Weather checked
|
|||||||
caption="
|
caption="
|
||||||
$current_weather
|
$current_weather
|
||||||
|
|
||||||
🌐 *ISP*: $isp, $country, $cc
|
Speedtest by Ookla:
|
||||||
🏓 *Latency*: $ping ms
|
🌐 *Server*: $ookla_server, $ookla_city, $ookla_country
|
||||||
⬇️ *Download*: $download_mbps Mbit/s, Used: $bytes_received_mb MB
|
🏓 *Latency*: $ookla_ping ms
|
||||||
⬆️ *Upload*: Upload: $upload_mbps Mbit/s, Used: $bytes_sent_mb MB
|
⬇️ *Download*: $ookla_download_mbps Mbit/s, Used: $ookla_bytes_received_mb MB
|
||||||
|
⬆️ *Upload*: Upload: $ookla_upload_mbps Mbit/s, Used: $ookla_bytes_sent_mb MB
|
||||||
|
|
||||||
|
LibreSpeed:
|
||||||
|
🌐 *Server*:
|
||||||
|
🏓 *Latency*: ms
|
||||||
|
⬇️ *Download*: Mbit/s, Used: MB
|
||||||
|
⬆️ *Upload*: Upload: Mbit/s, Used MB
|
||||||
|
|
||||||
|
Fast Powered by Netflix:
|
||||||
|
🏓 *Latency*: $fast_latency ms
|
||||||
|
⬇️ *Download*: $fast_download_speed Mbit/s, Used: $fast_downloaded MB
|
||||||
|
⬆️ *Upload*: Upload: $fast_upload_speed Mbit/s, Used: $fast_uploaded MB
|
||||||
"
|
"
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user