Skip to content

Instantly share code, notes, and snippets.

@eigenhombre
Created May 5, 2012 15:00
Show Gist options
  • Save eigenhombre/2603105 to your computer and use it in GitHub Desktop.
Save eigenhombre/2603105 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from datetime import datetime
import subprocess
cmd = 'vmstat 10'
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
close_fds=True, shell=True)
proc.stdin.close()
for line in iter(proc.stdout.readline, ''):
line = line.rstrip()
print "%s: %s" % (datetime.now(), line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment