python - Parse Microsoft DNS Debug logs -
I'm looking to parse Microsoft DNS debugging log responses. This idea is to parse the domain and print the number of each domain in the debug log. Typically i For the above data, ्เคจ Output will be something like great: This will indicate that the scripts or commands for domain.com Question entries were found. I am not concerned about the tertiary or more hosts involved in the calculation. A shell command or python will be fine. Hopefully there is some pseudo code to run the question at home. Maybe something like this? I am not an expert, but I should get a job as I understand the format. Open ('log', 'r') for the line as a file: match = re-search (R'Q \ [. + \]. + \ (\ D + \) ([^ \ () +) \ (\ D + \) ([^ \ () +) ', line.strip ()) match! = None: key = '' .join (match.groups ()) if key.keys () is not in: ret.keys () in ret retains k key for [key] = 1 else: ret [key] + = 1: Print '% s% d'% (k, ret [k]) grep -v "R" logs & gt; Tmp to first redirect all reactions to a file. Then manually grep such as
grep domain tmp for the domain. I think that's a better way.
20140416 01:38:52 588 packet 02030850 UDP RCV 192.168.0.10 2659 RQ [8281 Dr Serfel] A (11) tractor (3) sub (7) domain (3) com (0 ) 20140416 01:38:52 588 Packet 02396370 UDP RCV 192.168.0.5 B297 RQ [8281 DR Seraphel] A (3) PK (3) Sub (7) Domain (3) Com (0) 20140415 19:46:24 544 Packet 0261F580 UDP 19 2.168.0.2 795 Q [0000 noor] A (11) Tertiary (7) domain (3) com (0) 20140415 19:46:24 544 packet 01 A 47E60 UDP sand 1920.168.0.1 F4AQQ [0001D Noor] A (11) Quad (3) Sub (7) Domain (3) Net (0)
domain.com 3 domain.net 1
thefile = open ('log', 'r') FILE = theFile.readlines () theFile.close () printList = [] # Search for unique queries and place them in the FILE Count for: if (in the "Query" field for "Query"): #interview is counted to #interval value in printList.append (line) in printList: Print Item # Print Summary of Multiple Unique Domains < / Code>
Comments
Post a Comment