Updated speedtest script to include Discord webhook function.
This commit is contained in:
parent
fec307843b
commit
cba7fd60e4
13
speedtest.sh
13
speedtest.sh
@ -1,8 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Set the path to the log file
|
# Set the path to the log file
|
||||||
LOG_FILE="/LINK/TO/File/speedtest.csv"
|
LOG_FILE="./speedtest.csv"
|
||||||
|
|
||||||
|
# Set your Discord webhook URL
|
||||||
|
WEBHOOK_URL="DISCORD_WEBHOOK_URL"
|
||||||
|
|
||||||
|
# Set WAN Number
|
||||||
|
WAN="NUMBER"
|
||||||
# Run the speedtest and parse the output
|
# Run the speedtest and parse the output
|
||||||
SPEEDTEST=$(speedtest-cli --csv)
|
SPEEDTEST=$(speedtest-cli --csv)
|
||||||
|
|
||||||
@ -29,6 +34,8 @@ UPLOAD_Mbps=$(awk "BEGIN { printf \"%.1f\", $UPLOAD / (1024*1024) }")
|
|||||||
# Append the result to the log file
|
# Append the result to the log file
|
||||||
echo "$(date +"%Y-%m-%d %H:%M:%S"),$PING,$DOWNLOAD_Mbps Mbps,$UPLOAD_Mbps Mbps" >> "$LOG_FILE"
|
echo "$(date +"%Y-%m-%d %H:%M:%S"),$PING,$DOWNLOAD_Mbps Mbps,$UPLOAD_Mbps Mbps" >> "$LOG_FILE"
|
||||||
|
|
||||||
# Import the log file into Gnumeric to create a graph
|
# Prepare the payload for the Discord webhook
|
||||||
# ssconvert "$LOG_FILE" /tmp/log.ods
|
PAYLOAD='{"content": "Speedtest Result:\nPing: '"$PING"'\nDownload: '"$DOWNLOAD_Mbps"' Mbps\nUpload: '"$UPLOAD_Mbps"' Mbps"}'
|
||||||
|
|
||||||
|
# Send the payload to the Discord webhook - If you dont want this, comment out this command
|
||||||
|
curl -H "Content-Type: application/json" -X POST --data "{\"content\": null, \"embeds\": [{\"title\": \"Speedtest Result - WAN $WAN\", \"description\": \"Time: $(date +"%Y-%m-%d %H:%M:%S")\nPing: $PING ms\nDownload: $DOWNLOAD_Mbps mbps\nUpload: $UPLOAD_Mbps mbps\", \"color\": 5814783}], \"attachments\": []}" $WEBHOOK_URL
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user