Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. DATE_TAG="$(date -u +"%Y")-$(date -u +"%m")"
  4. CSV_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv"
  5. LOG_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv.log"
  6.  
  7. # ensure the path exists
  8. mkdir -p $(dirname "${CSV_PATH}")
  9.  
  10. # add the header row if the file does not exist
  11. if [ ! -f "${CSV_PATH}" ]; then
  12. printf '"date_time","ping (ms)","download (Mbit/s)","upload (Mbit/s)"\n' >> "${CSV_PATH}"
  13. fi
  14.  
  15. # run speedtest and record the results
  16. if result=$(/usr/bin/speedtest --simple | parse_speedtest_simple.py); then
  17. printf "${result}\n" >> "${CSV_PATH}"
  18. else
  19. printf "[$(date)] error\n" >> "${LOG_PATH}"
  20. exit 1
  21. fi
  22. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement