2015-07-11 07:51:30 +02:00
|
|
|
#!/usr/bin/env python
|
2018-06-16 16:12:18 +02:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
|
|
|
|
2008-12-23 19:38:48 +01:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
gnuplot_scripts = []
|
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
|
2008-12-23 19:38:48 +01:00
|
|
|
def gen_stats_gnuplot(name, y, lines):
|
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
global gnuplot_scripts
|
2008-12-23 19:38:48 +01:00
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
stat = open(sys.argv[1])
|
|
|
|
line = stat.readline()
|
|
|
|
while 'minute:' not in line:
|
|
|
|
line = stat.readline()
|
2008-12-23 19:38:48 +01:00
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
names = line.strip().split(':')
|
|
|
|
counter = 1
|
|
|
|
for i in names:
|
|
|
|
print('%d: %s' % (counter, i))
|
|
|
|
counter += 1
|
2008-12-23 19:38:48 +01:00
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
out = open('%s.gnuplot' % name, 'w+')
|
|
|
|
out.write('''
|
2008-12-23 19:38:48 +01:00
|
|
|
set term png size 1200,700 small
|
|
|
|
set output "%s.png"
|
|
|
|
set title "%s"
|
|
|
|
set ylabel "%s"
|
|
|
|
set xlabel "time (minutes)"
|
|
|
|
plot ''' % (name, name.strip('_'), y))
|
2018-06-12 11:43:13 +02:00
|
|
|
first = True
|
|
|
|
for i in lines:
|
|
|
|
if not first:
|
|
|
|
out.write(', \\\n')
|
|
|
|
first = False
|
|
|
|
out.write('"%s" using 1:%d title "%s" with lines' % (sys.argv[1], names.index(i) + 1, i))
|
|
|
|
out.write('\n')
|
|
|
|
|
|
|
|
out.write('''set terminal postscript
|
2008-12-23 19:38:48 +01:00
|
|
|
set output "%s.ps"
|
|
|
|
replot
|
|
|
|
''' % (name))
|
2018-06-12 11:43:13 +02:00
|
|
|
out.close()
|
|
|
|
gnuplot_scripts += [name]
|
|
|
|
|
2008-12-23 19:38:48 +01:00
|
|
|
|
2018-06-12 11:43:13 +02:00
|
|
|
gen_stats_gnuplot('dht_routing_table_size', 'nodes', ['active nodes', 'passive nodes', 'confirmed nodes'])
|
2008-12-23 21:04:12 +01:00
|
|
|
gen_stats_gnuplot('dht_tracker_table_size', '', ['num torrents', 'num peers'])
|
|
|
|
gen_stats_gnuplot('dht_announces', 'messages per minute', ['announces per min', 'failed announces per min'])
|
2018-06-12 11:43:13 +02:00
|
|
|
gen_stats_gnuplot('dht_clients',
|
|
|
|
'messages per minute',
|
|
|
|
['total msgs per min',
|
|
|
|
'az msgs per min',
|
|
|
|
'ut msgs per min',
|
|
|
|
'lt msgs per min',
|
|
|
|
'mp msgs per min',
|
|
|
|
'gr msgs per min'])
|
|
|
|
gen_stats_gnuplot('dht_rate', 'bytes per second', ['bytes in per sec', 'bytes out per sec'])
|
|
|
|
gen_stats_gnuplot('dht_errors', 'messages per minute', ['error replies sent', 'error queries recvd'])
|
2008-12-23 19:38:48 +01:00
|
|
|
|
|
|
|
for i in gnuplot_scripts:
|
2018-06-12 11:43:13 +02:00
|
|
|
os.system('gnuplot %s.gnuplot' % i)
|