Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- DATE_TAG="$(date -u +"%Y")-$(date -u +"%m")"
- CSV_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv"
- LOG_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv.log"
- # ensure the path exists
- mkdir -p $(dirname "${CSV_PATH}")
- # add the header row if the file does not exist
- if [ ! -f "${CSV_PATH}" ]; then
- printf '"date_time","ping (ms)","download (Mbit/s)","upload (Mbit/s)"\n' >> "${CSV_PATH}"
- fi
- # run speedtest and record the results
- if result=$(/usr/bin/speedtest --simple | parse_speedtest_simple.py); then
- printf "${result}\n" >> "${CSV_PATH}"
- else
- printf "[$(date)] error\n" >> "${LOG_PATH}"
- exit 1
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement