Beispiel #1
0
def modelAEM(etrs):
    print("Modeling AEM ...")
    # Modeling traffic with AEM
    aem  = AEM(etrs, cut_gap)
    withUA = aem.sessionsWithUA()
    withoutUA = aem.sessionsWithoutUA()

    forest = {}
    for ua in withUA:
        ss = withUA[ua]
        for el in ss[1:]:
            trees = aem.model(el)
            if ua not in forest:
                forest[ua] = []
            forest[ua].extend(trees)

    for host in withoutUA:
        nss = withoutUA[host]
        for el in nss[1:]:
            trees = aem.model(el)
            if host not in forest:
                forest[host] = []
            forest[host].extend(trees)
    return forest
Beispiel #2
0
input_folder = sys.argv[1]
hl = os.path.join(input_folder, "http_logs")
if not os.path.exists(hl):
    raise Exception("Sry, I do not find *http_logs*.out in given folder.")

# read http logs
etrs = []
for entry in HTTPLogReader(hl):
    if entry is not None:
        etrs.append(entry)
etrs.sort(key=lambda x: x.rqtstart())
if len(etrs) == 0:
    print("No http logs")
    sys.exit(-1)

aem = AEM(etrs)
withUA = aem.sessionsWithUA()
withoutUA = aem.sessionsWithoutUA()

# output file
output = os.path.join(input_folder, "aem.out")
try:
    os.remove(output)
except OSError:
    pass

for ua in withUA:
    ss = withUA[ua]
    open(output, "ab").write("\n****************** %s\n" % ua)
    for el in ss[1:]:
        trees = aem.model(el)