Created
February 19, 2013 14:15
-
-
Save nipunbatra/4986282 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,time | |
import shutil | |
import time | |
#Number of lines to tail | |
NUMLINES_TAIL="1000" | |
FILE_PATH="/home/nipun/Desktop/OZW_log.txt" | |
SLEEP_TIME=20 | |
while True: | |
#Calling the process and doing a GREP to get only the relevant rows from the output returned | |
p = subprocess.Popen('tail -'+NUMLINES_TAIL+" "+FILE_PATH, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
output= p.stdout.readlines() | |
for line in output: | |
if "Received Meter report" in line: | |
fields_in_line=line.split(" ") | |
print "Time:",fields_in_line[0]+" "+fields_in_line[1] | |
print "Node:",fields_in_line[2] | |
print "Power:",fields_in_line[9] | |
time.sleep(SLEEP_TIME) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment