forked from shihaam/starlink_status
converstion and var fixes
This commit is contained in:
parent
36c44e5304
commit
edbc12d14c
1
fil.json
1
fil.json
@ -1 +0,0 @@
|
||||
{"download": 38823491.68750661, "upload": 35415911.54118075, "ping": 107.185, "server": {"url": "http://co2dsvr03.speedtest.starhub.com:8080/speedtest/upload.php", "lat": "1.3000", "lon": "103.8000", "name": "Singapore", "country": "Singapore", "cc": "SG", "sponsor": "StarHub Ltd", "id": "4235", "host": "co2dsvr03.speedtest.starhub.com:8080", "d": 13.168430515716555, "latency": 107.185}, "timestamp": "2023-11-12T07:49:46.615855Z", "bytes_sent": 45031424, "bytes_received": 49206836, "share": null, "client": {"ip": "178.128.25.69", "lat": "1.3078", "lon": "103.6818", "isp": "Digital Ocean", "isprating": "3.7", "rating": "0", "ispdlavg": "0", "ispulavg": "0", "loggedin": "0", "country": "SG"}}
|
36
speed.sh
36
speed.sh
@ -1,36 +0,0 @@
|
||||
speedtest_ookla=fil.json
|
||||
# Run speedtest and output to a file
|
||||
speedtest --json > $speedtest_ookla
|
||||
# Extract information from the speedtest output
|
||||
|
||||
# Parsing JSON data
|
||||
ookla_server=$(jq -r '.server.sponsor' "$speedtest_ookla")
|
||||
ookla_city=$(jq -r '.server.name' "$speedtest_ookla")
|
||||
ookla_country=$(jq -r '.server.country' "$speedtest_ookla")
|
||||
ookla_ping=$(jq '.ping' "$speedtest_ookla")
|
||||
ookla_download=$(jq '.download' "$speedtest_ookla")
|
||||
ookla_upload=$(jq '.upload' "$speedtest_ookla")
|
||||
ooka_bytes_received=$(jq '.bytes_received' "$speedtest_ookla")
|
||||
ooka_bytes_sent=$(jq '.bytes_sent' "$speedtest_ookla")
|
||||
|
||||
# Converting to human readable units
|
||||
ookla_download_mbps=$(echo "scale=4; $download / 1000000" | bc)
|
||||
ookla_upload_mbps=$(echo "scale=4; $upload / 1000000" | bc)
|
||||
ookla_bytes_received_mb=$(echo "scale=2; $bytes_received / 1048576" | bc)
|
||||
ookla_bytes_sent_mb=$(echo "scale=2; $bytes_sent / 1048576" | bc)
|
||||
|
||||
# Converting to human-readable units
|
||||
ookla_download_mbps=$(echo "scale=4; $ookla_download / 1000000" | bc)
|
||||
ookla_upload_mbps=$(echo "scale=4; $ookla_upload / 1000000" | bc)
|
||||
ookla_bytes_received_mb=$(echo "scale=2; $ookla_bytes_received / 1048576" | bc)
|
||||
ookla_bytes_sent_mb=$(echo "scale=2; $ookla_bytes_sent / 1048576" | bc)
|
||||
|
||||
# Display the results
|
||||
echo "Server: $ookla_server"
|
||||
echo "City: $ookla_city"
|
||||
echo "Country: $ookla_country"
|
||||
echo "Ping: $ookla_ping ms"
|
||||
echo "Download Speed: $ookla_download_mbps Mbps"
|
||||
echo "Upload Speed: $ookla_upload_mbps Mbps"
|
||||
echo "Bytes Received: $ookla_bytes_received_mb MB"
|
||||
echo "Bytes Sent: $ookla_bytes_sent_mb MB"
|
Loading…
x
Reference in New Issue
Block a user