#!/usr/bin/env python
import re
###
# This program is good for parsing the direct output from the Autopilot window.
###
# Settings
infile = 'in.log'
outfile = 'out.data.txt'
# /Settings
r1 = re.compile(r'(\d+) Virtual Users configured')
r2 = re.compile(r'TEST RESULT : System achieved (\d+) SQL Server TPM at (\d+) NOPM')
with open(infile, 'r') as inf:
with open(outfile, 'w') as outf:
vusers = None
for line in inf:
if not vusers:
match = re.match(r1, line)
if match:
vusers = match.group(1)
else:
match = re.match(r2, line)
if match:
data = "{0}\t{1}\t{2}".format(vusers, match.group(1), match.group(2))
outf.write(data+'\n')
print data
vusers = None
import glob, re, os
###
# This program is good for parsing the raw log files if one is unable to get the direct output from the Autopilot window.
###
# Settings
indir = '119'
outfile = 'out.data.txt'
# /Settings
r1 = re.compile(r'Vuser \d+:(\d+) Virtual Users configured')
r2 = re.compile(r'Vuser \d+:TEST RESULT : System achieved (\d+) SQL Server TPM at (\d+) NOPM')
os.chdir(indir)
files = glob.glob('hammerdb*')
with open(outfile, 'w') as outf:
for f in files:
with open(f, 'r') as inf:
vusers = None
for line in inf:
if not vusers:
match = re.match(r1, line)
if match:
vusers = match.group(1)
else:
match = re.match(r2, line)
if match:
data = "{0}\t{1}\t{2}".format(vusers, match.group(1), match.group(2))
outf.write(data+'\n')
print data
vusers = None