Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../bin
File: bno_plot.py
#!/usr/libexec/platform-python
[0] Fix | Delete
#
[1] Fix | Delete
# btt blkno plotting interface
[2] Fix | Delete
#
[3] Fix | Delete
# (C) Copyright 2008 Hewlett-Packard Development Company, L.P.
[4] Fix | Delete
#
[5] Fix | Delete
# This program is free software; you can redistribute it and/or modify
[6] Fix | Delete
# it under the terms of the GNU General Public License as published by
[7] Fix | Delete
# the Free Software Foundation; either version 2 of the License, or
[8] Fix | Delete
# (at your option) any later version.
[9] Fix | Delete
#
[10] Fix | Delete
# This program is distributed in the hope that it will be useful,
[11] Fix | Delete
# but WITHOUT ANY WARRANTY; without even the implied warranty of
[12] Fix | Delete
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[13] Fix | Delete
# GNU General Public License for more details.
[14] Fix | Delete
#
[15] Fix | Delete
# You should have received a copy of the GNU General Public License
[16] Fix | Delete
# along with this program; if not, write to the Free Software
[17] Fix | Delete
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[18] Fix | Delete
#
[19] Fix | Delete
"""
[20] Fix | Delete
bno_plot.py
[21] Fix | Delete
[ -h | --help ]
[22] Fix | Delete
[ -K | --keys-below ]
[23] Fix | Delete
[ -v | --verbose ]
[24] Fix | Delete
[ <file...> ]
[25] Fix | Delete
[26] Fix | Delete
Utilizes gnuplot to generate a 3D plot of the block number output
[27] Fix | Delete
from btt. If no <files> are specified, it will utilize all files
[28] Fix | Delete
generated after btt was run with -B blknos (meaning: all files of the
[29] Fix | Delete
form blknos*[rw].dat).
[30] Fix | Delete
[31] Fix | Delete
The -K option forces bno_plot.py to put the keys below the graph,
[32] Fix | Delete
typically all keys for input files are put in the upper right corner
[33] Fix | Delete
of the graph. If the number of devices exceed 10, then bno_plot.py will
[34] Fix | Delete
automatically push the keys under the graph.
[35] Fix | Delete
[36] Fix | Delete
To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
[37] Fix | Delete
"""
[38] Fix | Delete
[39] Fix | Delete
from __future__ import absolute_import
[40] Fix | Delete
from __future__ import print_function
[41] Fix | Delete
import getopt, glob, os, sys, tempfile
[42] Fix | Delete
[43] Fix | Delete
verbose = 0
[44] Fix | Delete
cmds = """
[45] Fix | Delete
set title 'btt Generated Block Accesses'
[46] Fix | Delete
set xlabel 'Time (secs)'
[47] Fix | Delete
set ylabel 'Block Number'
[48] Fix | Delete
set zlabel '# Blocks per IO'
[49] Fix | Delete
set grid
[50] Fix | Delete
"""
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
#-----------------------------------------------------------------------------
[54] Fix | Delete
def parse_args(in_args):
[55] Fix | Delete
global verbose
[56] Fix | Delete
[57] Fix | Delete
keys_below = False
[58] Fix | Delete
s_opts = 'hKv'
[59] Fix | Delete
l_opts = [ 'help', 'keys-below', 'verbose' ]
[60] Fix | Delete
[61] Fix | Delete
try:
[62] Fix | Delete
(opts, args) = getopt.getopt(in_args, s_opts, l_opts)
[63] Fix | Delete
except getopt.error as msg:
[64] Fix | Delete
print(msg, file=sys.stderr)
[65] Fix | Delete
print(__doc__, file=sys.stderr)
[66] Fix | Delete
sys.exit(1)
[67] Fix | Delete
[68] Fix | Delete
for (o, a) in opts:
[69] Fix | Delete
if o in ('-h', '--help'):
[70] Fix | Delete
print(__doc__)
[71] Fix | Delete
sys.exit(0)
[72] Fix | Delete
elif o in ('-v', '--verbose'):
[73] Fix | Delete
verbose += 1
[74] Fix | Delete
elif o in ('-K', '--keys-below'):
[75] Fix | Delete
keys_below = True
[76] Fix | Delete
[77] Fix | Delete
if len(args) > 0: bnos = args
[78] Fix | Delete
else: bnos = glob.glob('blknos*[rw].dat')
[79] Fix | Delete
[80] Fix | Delete
return (bnos, keys_below)
[81] Fix | Delete
[82] Fix | Delete
#-----------------------------------------------------------------------------
[83] Fix | Delete
if __name__ == '__main__':
[84] Fix | Delete
(bnos, keys_below) = parse_args(sys.argv[1:])
[85] Fix | Delete
[86] Fix | Delete
if verbose:
[87] Fix | Delete
print('Using files:', end=' ')
[88] Fix | Delete
for bno in bnos: print(bno, end=' ')
[89] Fix | Delete
if keys_below: print('\nKeys are to be placed below graph')
[90] Fix | Delete
else: print('')
[91] Fix | Delete
[92] Fix | Delete
tmpdir = tempfile.mktemp()
[93] Fix | Delete
os.mkdir(tmpdir)
[94] Fix | Delete
[95] Fix | Delete
plot_cmd = None
[96] Fix | Delete
for f in bnos:
[97] Fix | Delete
t = '%s/%s' % (tmpdir, f)
[98] Fix | Delete
[99] Fix | Delete
fo = open(t, 'w')
[100] Fix | Delete
for line in open(f, 'r'):
[101] Fix | Delete
fld = line.split(None)
[102] Fix | Delete
print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
[103] Fix | Delete
fo.close()
[104] Fix | Delete
[105] Fix | Delete
t = t[t.rfind('/')+1:]
[106] Fix | Delete
if plot_cmd == None: plot_cmd = "splot '%s'" % t
[107] Fix | Delete
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
[108] Fix | Delete
[109] Fix | Delete
fo = open('%s/plot.cmds' % tmpdir, 'w')
[110] Fix | Delete
print(cmds, file=fo)
[111] Fix | Delete
if len(bnos) > 10 or keys_below: print('set key below', file=fo)
[112] Fix | Delete
print(plot_cmd, file=fo)
[113] Fix | Delete
fo.close()
[114] Fix | Delete
[115] Fix | Delete
pid = os.fork()
[116] Fix | Delete
if pid == 0:
[117] Fix | Delete
cmd = 'gnuplot %s/plot.cmds -' % tmpdir
[118] Fix | Delete
[119] Fix | Delete
if verbose: print('Executing %s' % cmd)
[120] Fix | Delete
[121] Fix | Delete
os.chdir(tmpdir)
[122] Fix | Delete
os.system(cmd)
[123] Fix | Delete
sys.exit(1)
[124] Fix | Delete
[125] Fix | Delete
os.waitpid(pid, 0)
[126] Fix | Delete
os.system('/bin/rm -rf ' + tmpdir)
[127] Fix | Delete
[128] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function