Skip to content

Instantly share code, notes, and snippets.

@nicksherron
Last active January 25, 2019 15:57
Show Gist options
  • Select an option

  • Save nicksherron/c12d554ab136a19e3d42de5c3578c6f2 to your computer and use it in GitHub Desktop.

Select an option

Save nicksherron/c12d554ab136a19e3d42de5c3578c6f2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import time
import subprocess
import select
filename = '/home/ubuntu/log/rel_stash.log'
f = subprocess.Popen(['tail','-n 20',filename],\
stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p = select.poll()
p.register(f.stdout)
counts = []
for i in range(0,21):
if p.poll(1):
if ":" in f.stdout.readline():
counts.append(f.stdout.readline())
time.sleep(1)
begin = int((counts[0]).split(" ")[-1])
begin_line = counts[0]
end = int((counts[-1]).split(" ")[-1])
end_line = counts[-1]
diff = end - begin
result = """
start {},
end {},
diff {}
""".format(begin_line, end_line, diff)
file = open("/home/ubuntu/log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment