forked from shihaam/starlink_status
speedtest to use json... FIX LATER: Convertion
This commit is contained in:
parent
42181e8cba
commit
73675b8532
33
bot.sh
33
bot.sh
@ -20,12 +20,27 @@ echo Image grabbed
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
echo Doing speedtest
|
echo Doing speedtest
|
||||||
# Run speedtest and output to a file
|
# Run speedtest and output to a file
|
||||||
speedtest > $speedtest_result
|
speedtest --json > $speedtest_result
|
||||||
# Extract information from the speedtest output
|
# Extract information from the speedtest output
|
||||||
isp_name=$(grep -oP 'Hosted by \K.*(?= \[)' $speedtest_result)
|
|
||||||
latency=$(grep -oP 'Hosted by.*\[.*\]: \K[0-9.]+(?= ms)' $speedtest_result)
|
# Parsing JSON data
|
||||||
download_speed=$(grep -oP 'Download: \K.*(?= Mbit/s)' $speedtest_result)
|
download=$(jq '.download' "$speedtest_result")
|
||||||
upload_speed=$(grep -oP 'Upload: \K.*(?= Mbit/s)' $speedtest_result)
|
upload=$(jq '.upload' "$speedtest_result")
|
||||||
|
ping=$(jq '.ping' "$speedtest_result")
|
||||||
|
bytes_received=$(jq '.bytes_received' "$speedtest_result")
|
||||||
|
bytes_sent=$(jq '.bytes_sent' "$speedtest_result")
|
||||||
|
isp=$(jq -r '.client.isp' "$speedtest_result")
|
||||||
|
country=$(jq -r '.client.country' "$speedtest_result")
|
||||||
|
cc=$(jq -r '.client.cc' "$speedtest_result")
|
||||||
|
|
||||||
|
# Converting download and upload speeds from bytes per second to Mbit/s
|
||||||
|
download_mbps=$(echo "scale=3; $download / 125000" | bc)
|
||||||
|
upload_mbps=$(echo "scale=3; $upload / 125000" | bc)
|
||||||
|
|
||||||
|
# Converting bytes to MB
|
||||||
|
bytes_received_mb=$(echo "scale=2; $bytes_received / 1048576" | bc)
|
||||||
|
bytes_sent_mb=$(echo "scale=2; $bytes_sent / 1048576" | bc)
|
||||||
|
|
||||||
echo Speedtest complete
|
echo Speedtest complete
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
@ -53,10 +68,10 @@ echo Weather checked
|
|||||||
caption="
|
caption="
|
||||||
$current_weather
|
$current_weather
|
||||||
|
|
||||||
🌐 *ISP*: $isp_name
|
🌐 *ISP*: $isp, $country, $cc
|
||||||
🏓 *Latency*: $latency ms
|
🏓 *Latency*: $ping ms
|
||||||
⬇️ *Download*: $download_speed Mbit/s
|
⬇️ *Download*: $download_mbps Mbit/s, Used: $bytes_received_mb MB
|
||||||
⬆️ *Upload*: $upload_speed Mbit/s
|
⬆️ *Upload*: Upload: $upload_mbps Mbit/s, Used: $bytes_sent_mb MB
|
||||||
"
|
"
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user