Skip to content

Instantly share code, notes, and snippets.

@gardner
Created July 5, 2016 01:48
Show Gist options
  • Save gardner/7c9b8aa0bd03ccbd4f03ac3122e60f6c to your computer and use it in GitHub Desktop.
Save gardner/7c9b8aa0bd03ccbd4f03ac3122e60f6c to your computer and use it in GitHub Desktop.
monitor url with curl
#!/bin/bash
# This creates a CSV file that can be uploaded to Google Docs where you can insert a chart to graph the values
LOG_FILE=/var/log/url_monitor.log
if [ ! -f $LOG_FILE ]; then # add CSV column headers
echo Date,Total Time,Redirect Time,DNS Lookup,Connect,App Connect,Pretransfer,starttransfer,Status Code > $LOG_FILE
fi
/usr/bin/curl -L -w "$(date),%{time_total},%{time_redirect},%{time_namelookup},%{time_connect},%{time_appconnect},%{time_pretransfer},%{time_starttransfer},%{http_code}\n" -o /dev/null -s "https://example.com/monitor" >> $LOG_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment