Last active
February 11, 2018 12:06
-
-
Save fillest/61878186356341fa9391f52bd5d303ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import time | |
import sys | |
interval = 2.0 | |
while True: | |
t1 = time.time() | |
#http://manpages.ubuntu.com/manpages/trusty/en/man1/curl.1.html | |
#http://stackoverflow.com/questions/17638026/calculating-server-processing-time-with-curl/29650456#29650456 | |
#https://curl.haxx.se/mail/lib-2011-05/0026.html | |
subprocess.call("date -u --rfc-3339=seconds | tr -d '\\n'; echo -n ' '; curl --write-out 'st=%{http_code} sz=%{size_download} ip=%{remote_ip}" | |
" ns^%{time_namelookup} conn^%{time_connect} sent^%{time_pretransfer} firstbyte^%{time_starttransfer} tot=%{time_total}\\n'" | |
" --silent --show-error --compressed -o /dev/null https://localhost/", shell = True) | |
sys.stdout.flush() | |
lat = time.time() - t1 | |
time.sleep(max(0, interval - lat)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment