-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
progress tracked in docs/progress/10-31.md
- Loading branch information
Showing
9 changed files
with
61 additions
and
60 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import json | ||
import time | ||
|
||
|
||
field_names = ('file_size', 'reclen', 'write', 'rewrite', 'read', 'reread', 'random_read', | ||
'random_write', 'bkwd_read', 'record_rewrite', 'stride_read', 'fwrite', 'frewrite', | ||
'fread', 'freread') | ||
|
||
|
||
def read_stdin(): | ||
while True: | ||
yield sys.stdin.readline().strip() | ||
|
||
|
||
def parse_line(l): | ||
res = {field_names[i]: int(f) for i, f in enumerate(l.split())} | ||
sys.stdout.write(json.dumps(res) + '\n') | ||
sys.stdout.flush() | ||
return res | ||
|
||
|
||
def filter_input(): | ||
def parse_output(): | ||
start = False | ||
output = [] | ||
for l in read_stdin(): | ||
if 'reclen' in l: | ||
start = True | ||
continue | ||
if not start: continue | ||
if len(l.split()) < 14: break | ||
output += [parse_line(l)] | ||
return output | ||
|
||
|
||
def write(output): | ||
fn = '/data/stats-%s.json'%os.environ['CLIENT_ID'] | ||
with open(fn, 'w') as f: | ||
json.dump(output, f, indent=2) | ||
output_fn = '/data/stats-%s.txt'%os.environ['CLIENT_ID'] | ||
with open(output_fn) as f: | ||
for l in f.readlines(): | ||
if 'reclen' in l: | ||
start = True | ||
continue | ||
if not start: continue | ||
if len(l.split()) < 14: break | ||
output += [{field_names[i]: int(f) for i, f in enumerate(l.split())}] | ||
if len(output) > 0: | ||
json.dump(output, open('/data/stats-%s.json' % os.environ['CLIENT_ID'], 'w'), indent=2) | ||
os.remove(output_fn) | ||
|
||
|
||
if __name__ == '__main__': | ||
write(filter_input()) | ||
parse_output() | ||
|