Commits

Richard Shea committed 1ba6bfb

Add analysis of network traffic.

  • Participants
  • Parent commits c47f765

Comments (0)

Files changed (1)

AnalyseIISLogs.py

                                                    "-ERRNot500",
                                                    base_file_name[1])
 
+    dic_paths['foutTrafficpath'] = build_path_inner(pathtooutputdir,
+                                                   base_file_name[0],
+                                                   "-Traffic",
+                                                   base_file_name[1])
+
     return dic_paths
 
 
     with open(dic_paths['foutDurationPath'], 'wb') as fout_duration:
         with open(dic_paths['foutNot500path'], 'wb') as fout_not_500:
             with open(dic_paths['fout500path'], 'wb') as fout_500:
-                with open(pathtoinputfile) as f_in:
-                    for line in f_in:
-                        lgen = LogEntry.fromlogline(line)
-                        if string.find(lgen.url.lower(), "tas") == -1:
-                            pass
-                        else:
-                            if string.find(lgen.url.lower(), "ts.asp") == -1:
+                with open(dic_paths['foutTrafficpath'], 'wb') as fout_traffic:
+                    with open(pathtoinputfile) as f_in:
+                        for line in f_in:
+                            lgen = LogEntry.fromlogline(line)
+                            if string.find(lgen.url.lower(), "tas") == -1:
                                 pass
                             else:
-                                fout_duration.write("%08d %s %s %s" %
-                                                    (lgen.timeTakenMs,
-                                                     lgen.date_time_as_iso(),
-                                                     lgen.clientIP,
-                                                     lgen.url.lower()))
-                                fout_duration.write('\n')
-                            #Add to IP analysis
-                            dic_ip_data = update_ip_analysis(lgen,
-                                                             dic_ip_data)
-                            #Add to caching analysis
-                            if lgen.serviceStatusCode in [304]:
-                                dic_cache_analysis = update_cache_analysis(lgen, dic_cache_analysis)
-                            #Start on error analysis
-                            cnt_total += 1
-                            if (cnt_total % 10000) == 0:
-                                print cnt_total
-                            if lgen.time > time(21, 0, 0):
-                                cnt_reject_for_time += 1
-                            elif lgen.time < time(7, 0, 0):
-                                cnt_reject_for_time += 1
-                            else:
-                                if lgen.serviceStatusCode == 500:
-                                    cnt_bad_500 += 1
-                                    fout_500.write(str(lgen))
-                                    fout_500.write('\n')
-                                elif lgen.serviceStatusCode != 200:
-                                    cnt_bad_not_500 += 1
-                                    fout_not_500.write(str(lgen))
-                                    fout_not_500.write('\n')
+                                if string.find(lgen.url.lower(), "ts.asp") == -1:
+                                    pass
                                 else:
-                                    cnt_good += 1
+                                    #Write duration info
+                                    fout_duration.write("%08d %s %s %s" %
+                                                        (lgen.timeTakenMs,
+                                                         lgen.date_time_as_iso(),
+                                                         lgen.clientIP,
+                                                         lgen.url.lower()))
+                                    fout_duration.write('\n')
+                                    #Write traffic info
+                                    fout_traffic.write("%08d %08d %s %s %s %s" %
+                                                        (lgen.serverBytes,
+                                                         lgen.clientBytes,
+                                                         lgen.requestTyp,
+                                                         lgen.date_time_as_iso(),
+                                                         lgen.clientIP,
+                                                         lgen.url.lower()))
+                                    fout_traffic.write('\n')
+                                    #Add to IP analysis
+                                    dic_ip_data = update_ip_analysis(lgen,
+                                                                     dic_ip_data)
+                                    #Add to caching analysis
+                                    if lgen.serviceStatusCode in [304]:
+                                        dic_cache_analysis = update_cache_analysis(lgen, dic_cache_analysis)
+                                    #Start on error analysis
+                                    cnt_total += 1
+                                    if (cnt_total % 10000) == 0:
+                                        print cnt_total
+                                    if lgen.time > time(21, 0, 0):
+                                        cnt_reject_for_time += 1
+                                    elif lgen.time < time(7, 0, 0):
+                                        cnt_reject_for_time += 1
+                                    else:
+                                        if lgen.serviceStatusCode == 500:
+                                            cnt_bad_500 += 1
+                                            fout_500.write(str(lgen))
+                                            fout_500.write('\n')
+                                        elif lgen.serviceStatusCode != 200:
+                                            cnt_bad_not_500 += 1
+                                            fout_not_500.write(str(lgen))
+                                            fout_not_500.write('\n')
+                                        else:
+                                            cnt_good += 1
     report_on_ip_address_data(dic_ip_data)
     with open(dic_paths['foutCachingAnalysispath'], "w") as fout_cache_analysis:
         pprint.pprint(dic_cache_analysis, fout_cache_analysis)