made log parser generate throughput graph as well
This commit is contained in:
@@ -2,11 +2,12 @@ import os, sys, time
|
|||||||
|
|
||||||
lines = open(sys.argv[1], 'rb').readlines()
|
lines = open(sys.argv[1], 'rb').readlines()
|
||||||
|
|
||||||
time_limit = -1
|
if len(sys.argv) < 2:
|
||||||
if len(sys.argv) > 2:
|
print "usage: parse_disk_log.py logfile [seconds]"
|
||||||
time_limit = long(sys.argv[2])
|
sys.exit(1)
|
||||||
|
|
||||||
keys = ['write', 'read', 'hash', 'move', 'release', 'idle']
|
keys = ['write', 'read', 'hash', 'move', 'release', 'idle']
|
||||||
|
throughput_keys = ['write', 'read']
|
||||||
|
|
||||||
# logfile format:
|
# logfile format:
|
||||||
# <time(ms)> <state>
|
# <time(ms)> <state>
|
||||||
@@ -14,14 +15,20 @@ keys = ['write', 'read', 'hash', 'move', 'release', 'idle']
|
|||||||
# 34523 idle
|
# 34523 idle
|
||||||
# 34722 write
|
# 34722 write
|
||||||
|
|
||||||
quantization = 5000
|
if len(sys.argv) > 2:
|
||||||
|
quantization = long(sys.argv[2]) * 1000
|
||||||
|
else:
|
||||||
|
quantization = 5000
|
||||||
|
|
||||||
out = open('disk_io.dat', 'wb')
|
out = open('disk_io.dat', 'wb')
|
||||||
|
out2 = open('disk_throughput.dat', 'wb')
|
||||||
state = 'idle'
|
state = 'idle'
|
||||||
time = 0
|
time = 0
|
||||||
i = 0
|
i = 0
|
||||||
state_timer = {}
|
state_timer = {}
|
||||||
|
throughput = {}
|
||||||
for k in keys: state_timer[k] = 0
|
for k in keys: state_timer[k] = 0
|
||||||
|
for k in throughput_keys: throughput[k] = 0
|
||||||
for l in lines:
|
for l in lines:
|
||||||
l = l[:-1].split(' ')
|
l = l[:-1].split(' ')
|
||||||
if len(l) < 2:
|
if len(l) < 2:
|
||||||
@@ -35,21 +42,36 @@ for l in lines:
|
|||||||
time = i
|
time = i
|
||||||
for k in keys: print >>out, state_timer[k],
|
for k in keys: print >>out, state_timer[k],
|
||||||
print >>out
|
print >>out
|
||||||
|
for k in throughput_keys: print >>out2, throughput[k] / 1000.,
|
||||||
|
print >>out2
|
||||||
for k in keys: state_timer[k] = 0
|
for k in keys: state_timer[k] = 0
|
||||||
|
for k in throughput_keys: throughput[k] = 0
|
||||||
state_timer[state] += new_time - time
|
state_timer[state] += new_time - time
|
||||||
time = new_time
|
time = new_time
|
||||||
state = l[1]
|
state = l[1]
|
||||||
|
if state in throughput_keys:
|
||||||
|
throughput[state] += long(l[2])
|
||||||
except:
|
except:
|
||||||
print l
|
print l
|
||||||
out.close()
|
out.close()
|
||||||
|
out2.close()
|
||||||
|
|
||||||
out = open('disk_io.gnuplot', 'wb')
|
out = open('disk_io.gnuplot', 'wb')
|
||||||
print >>out, "set term png size 1200,700"
|
print >>out, "set term png size 1200,700"
|
||||||
|
|
||||||
|
print >>out, 'set output "disk_throughput.png"'
|
||||||
|
print >>out, 'set title "disk throughput per %s second(s)"' % (quantization / 1000)
|
||||||
|
print >>out, 'set ylabel "throughput (kB)"'
|
||||||
|
print >>out, 'plot',
|
||||||
|
i = 0
|
||||||
|
for k in throughput_keys:
|
||||||
|
print >>out, ' "disk_throughput.dat" using %d title "%s" with lines,' % (i + 1, throughput_keys[i]),
|
||||||
|
i = i + 1
|
||||||
|
print >>out, 'x=0'
|
||||||
|
|
||||||
print >>out, 'set output "disk_io.png"'
|
print >>out, 'set output "disk_io.png"'
|
||||||
print >>out, 'set xrange [0:*]'
|
|
||||||
print >>out, 'set ylabel "time (ms)"'
|
print >>out, 'set ylabel "time (ms)"'
|
||||||
print >>out, "set style data lines"
|
print >>out, 'set xrange [0:*]'
|
||||||
print >>out, 'set title "disk io utilization per %s second(s)"' % (quantization / 1000)
|
print >>out, 'set title "disk io utilization per %s second(s)"' % (quantization / 1000)
|
||||||
print >>out, "set key box"
|
print >>out, "set key box"
|
||||||
print >>out, "set style data histogram"
|
print >>out, "set style data histogram"
|
||||||
|
Reference in New Issue
Block a user