Last active
October 3, 2021 14:06
-
-
Save avaccari/c56adc6bd45d93b503a724868004dae2 to your computer and use it in GitHub Desktop.
A very short and simple ASCII smoke ping in Python
This file contains hidden or 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 re | |
import time | |
import subprocess as sbpr | |
import datetime as dt | |
HOST = 'google.com' | |
DELAY_MS = 1000 | |
while(True): | |
t = float(re.findall(r'time=(.*) ms',sbpr.check_output(['ping', '-c', '1', HOST]).decode('ascii'))[0]) | |
print(f"{dt.datetime.now().strftime('%H:%M:%S.%f')[:-3]} | {t:4.3f} | {int(t)*'*'}") | |
time.sleep(0.001 * DELAY_MS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment