1、線上zk訪問延遲特別高須要統計一段時間內的zk寫入路徑top10,實現以下:python
#!/usr/bin/env python # -*- coding:utf-8 -*- import re,traceback def gen_range_hosts(path,n): new_path= "" try: re_match = re.match(r'(.*)"path":"(.*)","version"', path, re.M | re.I) if re_match is not None: new_path = re_match.group(2) except: print "++++++++++++{n}++++++++++++{path}".format(n=n, path=path) traceback.print_exc() return new_path def main(): with open('./publisher.log', 'r') as f: n = 1 for line in f.readlines(): n +=1 new_line = line.strip() if new_line.find("path") != -1: print gen_range_hosts(new_line,n) if __name__ == '__main__': main() ''' <1>過濾日誌命令: cat newlog.log |egrep -v "^$"|sort |uniq -c|sort -rn >> okok.log '''
2、能夠根據指定時間過濾日誌路徑的功能須要實現。日誌