2010-03-05 19:12:23 +01:00
|
|
|
#! /usr/bin/env python
|
2008-05-08 19:40:32 +02:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
2008-12-23 19:38:48 +01:00
|
|
|
up_time_quanta = 2000
|
2008-05-10 07:51:58 +02:00
|
|
|
|
2008-05-08 19:40:32 +02:00
|
|
|
f = open(sys.argv[1])
|
|
|
|
|
2008-05-10 07:51:58 +02:00
|
|
|
announce_histogram = {}
|
|
|
|
node_uptime_histogram = {}
|
2008-05-08 19:40:32 +02:00
|
|
|
|
2008-05-09 18:21:09 +02:00
|
|
|
counter = 0;
|
|
|
|
|
|
|
|
for line in f:
|
|
|
|
counter += 1
|
2008-12-23 19:38:48 +01:00
|
|
|
# if counter % 1000 == 0:
|
|
|
|
# print '\r%d' % counter,
|
2008-05-08 19:40:32 +02:00
|
|
|
try:
|
2008-05-10 07:51:58 +02:00
|
|
|
if 'distance:' in line:
|
|
|
|
l = line.split(' ')
|
2008-12-23 19:38:48 +01:00
|
|
|
idx = l.index('distance:')
|
2008-05-08 19:40:32 +02:00
|
|
|
|
2008-12-23 19:38:48 +01:00
|
|
|
d = int(l[idx+1].strip())
|
|
|
|
if not d in announce_histogram: announce_histogram[d] = 0
|
2008-05-10 07:51:58 +02:00
|
|
|
announce_histogram[d] += 1
|
|
|
|
if 'NODE FAILED' in line:
|
|
|
|
l = line.split(' ')
|
2008-12-23 19:38:48 +01:00
|
|
|
idx = l.index('fails:')
|
|
|
|
if int(l[idx+1].strip()) != 1: continue;
|
|
|
|
idx = l.index('up-time:')
|
|
|
|
d = int(l[idx+1].strip())
|
|
|
|
# quantize
|
|
|
|
d = d - (d % up_time_quanta)
|
|
|
|
if not d in node_uptime_histogram: node_uptime_histogram[d] = 0
|
|
|
|
node_uptime_histogram[d] += 1
|
|
|
|
except Exception, e:
|
2008-05-08 19:40:32 +02:00
|
|
|
print line.split(' ')
|
|
|
|
|
|
|
|
out = open('dht_announce_distribution.dat', 'w+')
|
2010-11-05 20:06:50 +01:00
|
|
|
print 'announce distribution items: %d' % len(announce_histogram)
|
2008-05-10 07:51:58 +02:00
|
|
|
for k,v in announce_histogram.items():
|
2008-05-08 19:40:32 +02:00
|
|
|
print >>out, '%d %d' % (k, v)
|
2010-11-05 20:06:50 +01:00
|
|
|
print '%d %d' % (k, v)
|
2008-05-08 19:40:32 +02:00
|
|
|
out.close()
|
|
|
|
|
2008-05-10 07:51:58 +02:00
|
|
|
out = open('dht_node_uptime_distribution.dat', 'w+')
|
2010-11-05 20:06:50 +01:00
|
|
|
print 'node uptimes: %d' % len(node_uptime_histogram)
|
2008-05-10 07:51:58 +02:00
|
|
|
for k,v in node_uptime_histogram.items():
|
|
|
|
print >>out, '%d %d' % (k + up_time_quanta/2, v)
|
|
|
|
out.close()
|
|
|
|
|
|
|
|
out = open('dht.gnuplot', 'w+')
|
2008-05-08 21:09:55 +02:00
|
|
|
out.write('''
|
2008-05-09 02:53:59 +02:00
|
|
|
set term png size 1200,700 small
|
2008-05-08 19:40:32 +02:00
|
|
|
set output "dht_announce_distribution.png"
|
|
|
|
set title "bucket # announces are made against relative to target node-id"
|
|
|
|
set ylabel "# of announces"
|
2008-05-08 21:09:55 +02:00
|
|
|
set style fill solid border -1 pattern 2
|
|
|
|
plot "dht_announce_distribution.dat" using 1:2 title "announces" with boxes
|
2008-05-09 02:53:59 +02:00
|
|
|
|
|
|
|
set terminal postscript
|
|
|
|
set output "dht_announce_distribution.ps"
|
|
|
|
replot
|
2008-05-10 07:51:58 +02:00
|
|
|
|
|
|
|
set term png size 1200,700 small
|
|
|
|
set output "dht_node_uptime_distribution.png"
|
|
|
|
set title "node up time"
|
|
|
|
set ylabel "# of nodes"
|
|
|
|
set xlabel "uptime (seconds)"
|
|
|
|
set boxwidth %f
|
|
|
|
set style fill solid border -1 pattern 2
|
|
|
|
plot "dht_node_uptime_distribution.dat" using 1:2 title "nodes" with boxes
|
|
|
|
''' % up_time_quanta)
|
2008-05-08 19:40:32 +02:00
|
|
|
out.close()
|
|
|
|
|
2008-05-10 07:51:58 +02:00
|
|
|
os.system('gnuplot dht.gnuplot');
|
2008-05-08 19:40:32 +02:00
|
|
|
|
2008-12-23 19:38:48 +01:00
|
|
|
|