2009-01-23 10:13:31 +01:00
|
|
|
#!/bin/python
|
|
|
|
|
|
|
|
import os, sys, time
|
|
|
|
|
2009-05-02 08:52:57 +02:00
|
|
|
lines = open(sys.argv[1], 'rb').readlines()
|
|
|
|
|
|
|
|
# logfile format:
|
|
|
|
# <time(ms)> <key>: <value>
|
|
|
|
# example:
|
|
|
|
# 16434 read cache: 17
|
|
|
|
|
2009-06-01 00:38:49 +02:00
|
|
|
key_order = ['receive buffer', 'send buffer', 'released send buffer', 'posted send buffer',
|
|
|
|
'received send buffer', 'dispatched send buffer', 'queued send buffer',
|
|
|
|
'write cache', 'read cache', 'hash temp']
|
|
|
|
colors = ['30f030', '001070', '101080', '2040a0',
|
|
|
|
'4070d0', '80a0f0', 'f03030',
|
|
|
|
'80f080', 'f08080', '4040ff']
|
2009-05-24 23:39:45 +02:00
|
|
|
|
2009-05-02 08:52:57 +02:00
|
|
|
keys = []
|
|
|
|
fields = {}
|
|
|
|
maximum = {}
|
|
|
|
out = open('disk_buffer_log.dat', 'w+')
|
|
|
|
|
2009-05-25 08:50:44 +02:00
|
|
|
field_sum = {}
|
|
|
|
field_num_samples = {}
|
2009-05-25 09:42:55 +02:00
|
|
|
field_timestamp = {}
|
2009-05-25 08:50:44 +02:00
|
|
|
|
2009-05-24 23:39:45 +02:00
|
|
|
for c in key_order:
|
|
|
|
keys.append(c)
|
|
|
|
fields[c] = 0
|
|
|
|
maximum[c] = 0
|
2009-05-25 08:50:44 +02:00
|
|
|
field_sum[c] = 0
|
|
|
|
field_num_samples[c] = 0
|
2009-05-25 09:42:55 +02:00
|
|
|
field_timestamp[c] = 0
|
2009-05-24 23:39:45 +02:00
|
|
|
|
2009-05-02 08:52:57 +02:00
|
|
|
last_t = 0
|
|
|
|
for l in lines:
|
|
|
|
try:
|
|
|
|
t = int(l[0:l.find(' ')])
|
|
|
|
c = l[l.find(' ')+1:l.find(':')]
|
|
|
|
n = int(l[l.find(':')+1:-1])
|
|
|
|
except:
|
|
|
|
print l
|
|
|
|
continue
|
|
|
|
|
|
|
|
if last_t != t:
|
|
|
|
print >>out, '%d\t' % last_t,
|
|
|
|
for i in keys:
|
|
|
|
print >>out, '%d\t' % maximum[i],
|
|
|
|
print >>out, '\n',
|
|
|
|
|
2009-06-01 00:38:49 +02:00
|
|
|
if not c in keys: continue
|
2009-05-02 08:52:57 +02:00
|
|
|
|
2009-05-25 09:42:55 +02:00
|
|
|
field_sum[c] += fields[c] * float(t - field_timestamp[c])
|
|
|
|
field_timestamp[c] = t
|
2009-05-25 08:50:44 +02:00
|
|
|
|
2009-05-25 09:42:55 +02:00
|
|
|
fields[c] = n
|
2009-05-25 08:50:44 +02:00
|
|
|
|
2009-05-02 08:52:57 +02:00
|
|
|
if n > maximum[c]: maximum[c] = n
|
|
|
|
|
|
|
|
if last_t != t:
|
|
|
|
last_t = t
|
|
|
|
maximum = fields
|
|
|
|
|
|
|
|
for i in keys:
|
2009-05-25 09:42:55 +02:00
|
|
|
print '%s: avg: %f' % (i, field_sum[i] / last_t)
|
2009-05-02 08:52:57 +02:00
|
|
|
print
|
|
|
|
|
|
|
|
out.close()
|
2009-01-23 10:13:31 +01:00
|
|
|
|
|
|
|
out = open('disk_buffer.gnuplot', 'wb')
|
|
|
|
print >>out, "set term png size 1200,700"
|
|
|
|
print >>out, 'set output "disk_buffer.png"'
|
|
|
|
print >>out, 'set xrange [0:*]'
|
|
|
|
print >>out, 'set xlabel "time (ms)"'
|
|
|
|
print >>out, 'set ylabel "buffers"'
|
|
|
|
print >>out, "set style data lines"
|
|
|
|
print >>out, "set key box"
|
|
|
|
print >>out, 'plot',
|
|
|
|
count = 1 + len(keys)
|
|
|
|
keys.reverse()
|
|
|
|
for k in keys:
|
|
|
|
expr = "$%d" % count
|
|
|
|
for i in xrange(2, count): expr += "+$%d" % i
|
|
|
|
count -= 1
|
2009-05-24 23:39:45 +02:00
|
|
|
print >>out, ' "disk_buffer_log.dat" using 1:(%s) title "%s" with filledcurves x1 lt rgb "#%s",' % (expr, k, colors[count-1]),
|
2009-01-23 10:13:31 +01:00
|
|
|
print >>out, 'x=0'
|
|
|
|
out.close()
|
|
|
|
|
|
|
|
os.system('gnuplot disk_buffer.gnuplot')
|
|
|
|
|