#!/usr/libexec/platform-python
# btt blkno plotting interface
# (C) Copyright 2008 Hewlett-Packard Development Company, L.P.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Utilizes gnuplot to generate a 3D plot of the block number output
from btt. If no <files> are specified, it will utilize all files
generated after btt was run with -B blknos (meaning: all files of the
The -K option forces bno_plot.py to put the keys below the graph,
typically all keys for input files are put in the upper right corner
of the graph. If the number of devices exceed 10, then bno_plot.py will
automatically push the keys under the graph.
To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
from __future__ import absolute_import
from __future__ import print_function
import getopt, glob, os, sys, tempfile
set title 'btt Generated Block Accesses'
set ylabel 'Block Number'
set zlabel '# Blocks per IO'
#-----------------------------------------------------------------------------
l_opts = [ 'help', 'keys-below', 'verbose' ]
(opts, args) = getopt.getopt(in_args, s_opts, l_opts)
except getopt.error as msg:
print(msg, file=sys.stderr)
print(__doc__, file=sys.stderr)
if o in ('-h', '--help'):
elif o in ('-v', '--verbose'):
elif o in ('-K', '--keys-below'):
if len(args) > 0: bnos = args
else: bnos = glob.glob('blknos*[rw].dat')
return (bnos, keys_below)
#-----------------------------------------------------------------------------
if __name__ == '__main__':
(bnos, keys_below) = parse_args(sys.argv[1:])
print('Using files:', end=' ')
for bno in bnos: print(bno, end=' ')
if keys_below: print('\nKeys are to be placed below graph')
tmpdir = tempfile.mktemp()
t = '%s/%s' % (tmpdir, f)
for line in open(f, 'r'):
print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
if plot_cmd == None: plot_cmd = "splot '%s'" % t
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
fo = open('%s/plot.cmds' % tmpdir, 'w')
if len(bnos) > 10 or keys_below: print('set key below', file=fo)
cmd = 'gnuplot %s/plot.cmds -' % tmpdir
if verbose: print('Executing %s' % cmd)
os.system('/bin/rm -rf ' + tmpdir)