forked from Neeky/mysqltools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_parser.py
executable file
·37 lines (33 loc) · 1.04 KB
/
data_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3.5
import sys
import os
import argparse
import json
if __name__=="__main__":
parser=argparse.ArgumentParser()
parser.add_argument('--file-path',default='/tmp/datas/',help='the inspection file path ...')
args=parser.parse_args()
file_list=[args.file_path+file_name for file_name in os.listdir(args.file_path)]
file_list=sorted(file_list)
filter=[
'Up for',
'Data in InnoDB tables',
'Reads / Writes',
'Slow queries',
'Highest usage of available connections',
'nnoDB log waits',
'InnoDB Read buffer efficiency',
'Read Key buffer hit rate',
'Thread cache hit rate',
'Table cache hit rate',
'Temporary tables created on disk'
]
def line_in_filter(line):
for item in filter:
if item in line: return True
return False
data={}
for file in file_list:
data[file]=[line for line in open(file) if line_in_filter(line) ]
print(json.dumps(data,indent=4))
#print(len(data.keys()))