Last active
August 29, 2015 14:26
-
-
Save TechplexEngineer/7f84896089c96a6b5fe1 to your computer and use it in GitHub Desktop.
HammerDB Autopilot Log parser
This file contains hidden or 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
| #!/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 |
This file contains hidden or 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 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment