Skip to content

Instantly share code, notes, and snippets.

@avaccari
Last active October 3, 2021 14:06
Show Gist options
  • Save avaccari/c56adc6bd45d93b503a724868004dae2 to your computer and use it in GitHub Desktop.
Save avaccari/c56adc6bd45d93b503a724868004dae2 to your computer and use it in GitHub Desktop.
A very short and simple ASCII smoke ping in Python
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