## ## chewie.py ## chews browser http log. draws graph of connections ## Be sure there is only one pageload in the log. ## ## you'll want to ## sudo apt-get install python-matplotlib ## before running this ##
import sys, pylab
# can't just use a dict, because there can be dups class Queue: def __init__(self):
self.queue = []
while (True):
line = f.readline() if len(line) == 0: break
splitup = line.split()
# http only if splitup[0] != "V/http": continue
x = splitup[3:]
# filter to named lines if x[2] notin keys: continue
x[2] = extractMe[x[2]]
# normalize time if t0 == None: t0 = int(x[0])
x[0] = int(x[0]) - t0
thread, action = x[1], x[2] if action == "Q":
time, url = x[0], x[3]
queued.add(url, time) elif action == "O": # save opened time and server for this thread, so we can stuff it in l8r
time, thread, host = x[0], x[1], x[4]
opened[thread] = [time, host, connectionCount]
connectionCount += 1 elif action == "S":
time, thread, url = x[0], x[1], x[3]
opentime, host, connection = opened[thread]
qtime = queued.get(url)
record = [thread, qtime, opentime, time, None, None, None, url, host, connection]
active[thread].append(record) elif action == "T":
time, thread = x[0], x[1]
record = active[thread][-1]
record[4] = time elif action == "R":
print x if x[3] in ["sleep", "no", "wait"]: continue
time, thread, = x[0], x[1]
record = active[thread][0]
record[5] = time elif action == 'U':
thread = x[1]
record = active[thread][0]
killed[0].append(record[9])
killed[1].append(x[0])
queued.add(record[7], record[1]) del active[thread][0] elif action == "D":
time, thread = x[0], x[1]
record = active[thread][0]
record[6] = time
vals.append(record) del active[thread][0]
print record # print record[3] / 1000, record[6] / 1000, record[7] elif action == "B":
byteCount += int(x[3]) elif action == "HR":
byteCount += int(x[2])
f.close()
rng = range(connectionCount)
opened = []
drawn = [Falsefor x in rng] for val in vals:
y= val[9] ifnot drawn[y]:
drawn[y] = True
opened.append(val[2])
pylab.text(0, y - 0.25, "%s %s %s" % (val[9], val[0][4], val[8]), font)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.