Advertisement
Guest User

iostat-plotter-v3.1

a guest
Jun 4th, 2015
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 110.54 KB | None | 0 0
  1. #!/usr/bin/python
  2. #
  3. # Enhanced data plotter for iostat output. Feb. 22 2014
  4. #
  5. # Copyright Jeffrey B. Layton
  6. #
  7. # License: GNU GPL v2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
  8. # Version 2, June 1991
  9. #
  10. # Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  11. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  12. #
  13. # Everyone is permitted to copy and distribute verbatim copies
  14. # of this license document, but changing it is not allowed.
  15. #
  16. #
  17. #
  18. # To run the application first gather the iostat information using:
  19. #
  20. # [laytonjb ~]$ iostat -c -d -x -t -m /dev/sda 1 100 > iostat.out
  21. #
  22. # where /dev/sda is the specific device you want to monitor which is
  23. # up to you. If you don't put a device there, iostat will monitor
  24. # all devices. For example:
  25. #
  26. # [laytonjb ~]$ iostat -c -d -x -t -m 1 100 > iostat.out
  27. #
  28. # "1 100" which tells iostat to use "1" second intervals  and "100"
  29. # means to gather data for 100 time (or 100 sceonds in this case).
  30. #
  31. # Then to run iostat_plotter, the command is,
  32. #
  33. # [laytonjb ~]$ iostat_plotter.py iostat.out
  34. #
  35. # where "iostat.out" is the output from iostat. The code is written
  36. # in Python (obviously) and uses the shlex, time, os, and matplotlib
  37. # modules. iostat_plotter is smart enough to gather the data for each
  38. # device and plot them separately.
  39. #
  40. # Alternatively, you can run iostat_plotter.py as,
  41. #
  42. # [laytonjb ~]$ iostat_plotter.py -c iostat.out
  43. #
  44. # where the option "-c" stands for "combined" plots which plots all
  45. # of the devices on the same plot.
  46. #
  47. # When iostat_plotter is done it will create a subdirectory "HTML_REPORT"
  48. # that contains the plots and an html file "report.html". Open that
  49. # html file in a browser or word processor and you will see the plots
  50. # and a small write-up about them. Feel free to modify the code but
  51. # please send back changes.
  52. #
  53.  
  54. import sys
  55. try:
  56.    import shlex                      # Needed for splitting input lines
  57. except ImportError:
  58.    print "Cannot import shlex module - this is needed for this application.";
  59.    print "Exiting..."
  60.    sys.exit();
  61.  
  62. try:
  63.    import time;                       # Needed for time conversion function
  64.    time_var = 1
  65. except:
  66.    time_var = 0;
  67.    print "Cannot find time module - this is needed for this application.";
  68.    print "Exiting..."
  69.    sys.exit();
  70.  
  71. try:
  72.    import matplotlib                  # imported for fix: http://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined
  73.    matplotlib.use('Agg')              # matplotlib only used once, plt on the other hand used alot
  74.    import matplotlib.pyplot as plt;   # Needed for plots
  75.    matplotlib_var = 1
  76. except:
  77.    matplotlib_var = 0;
  78.    print "Cannot find matplotlib - this is needed for this application.";
  79.    print "Exiting..."
  80.    sys.exit();
  81.  
  82. try:
  83.    import os                           # Needed for mkdir
  84. except ImportError:
  85.    print "Cannot import os module - this is needed for this application.";
  86.    print "Exiting..."
  87.    sys.exit();
  88.  
  89. try:
  90.    import pickle                      # Needed for pickle
  91.    pickle_success = 1;
  92. except ImportError:
  93.    print "Cannot import pickle module - this is not needed for this application.";
  94.    print "Continuing to process";
  95.    pickle_success = 0;
  96.  
  97.  
  98. # ------------------------------
  99.  
  100.  
  101. def help_out():
  102.    # prints out help information and stops
  103.    print " ";
  104.    print "This application creates a short HTML based report from iostat output";
  105.    print "(part of the sysstat tools). The report includes plots that help";
  106.    print "analyze the output. It can adapt to sysstat v9.x format or sysstat";
  107.    print "v10.x output (it is slightly different). Many distributions such as";
  108.    print "CentOS or Red Hat use sysstat version 9.x. However, it is recommended";
  109.    print "that you upgrad to sysstat 10.x because you get slightly more information.";
  110.    print "It is not a difficult task but be sure you install over the previous";
  111.    print "version.";
  112.    print " ";
  113.    print "To run the application first gather the iostat information using: ";
  114.    print "the following example.";
  115.    print " ";
  116.    print "[laytonjb ~]$ iostat -c -d -x -t -m /dev/sda 1 100 > iostat.out ";
  117.    print " ";
  118.    print "where the \"-c\" option displays the CPU utilization, the \"-d\" option";
  119.    print "displays the device utilization, the \"-x\" option displays extended";
  120.    print "statistics, and the \"-m\" option diplays the statistics in megabytes";
  121.    print "per second. The options \"1 100\" tell iostat to use \"1\" second ";
  122.    print "intervals and \"100\" means to gather data for 100 internvals (or 100";
  123.    print "seconds in this case). ";
  124.    print " ";
  125.    print "After the \"-m\" option is /dev/sda which is the specific device";
  126.    print "you want to monitor. This option is up to you. If you don't put a ";
  127.    print "device there, iostat will monitor all devices. For example:"
  128.    print " ";
  129.    print "[laytonjb ~]$ iostat -c -d -x -t -m 1 100 > iostat.out ";
  130.    print " ";
  131.    print "which captures the data from all devices.";
  132.    print " ";
  133.    print "In these two examples, the output from iostat is send to a file which is";
  134.    print "\"iostat.out\". You can name the file anything you want but be sure ";
  135.    print "note the name of the file.";
  136.    print " ";
  137.    print "Then to run iostat_plotter using the iostat output file, the command is, ";
  138.    print " ";
  139.    print "[laytonjb ~]$ iostat_plotter.py iostat.out ";
  140.    print " ";
  141.    print "where \"iostat.out\" is the output from iostat. The code is written ";
  142.    print "in Python (obviously) and uses the shlex, time, os, and matplotlib ";
  143.    print "modules. Be sure this libraries are installed on your system.";
  144.    print " ";
  145.    print "You can run iostat_plotter in one of two ways. The first way creates ";
  146.    print "the set of plots for each device on the node. In this version of ";
  147.    print "iostat_plotter, 11 plots are created per device, so if you have two";
  148.    print "devices on the node, then you will ahve a total of 22 plots.";
  149.    print " ";
  150.    print "The other way to run niostat_plotter is to combine the results for each";
  151.    print "device in the plots. This means you will have only 11 plots ";
  152.    print "in the HTML report even if you have more than one device. You run this ";
  153.    print "with the following command:";
  154.    print " ";
  155.    print "[laytonjb ~]$ iostat_plotter.py -c iostat.out ";
  156.    print " ";
  157.    print "The option \"-c\" tells iostat_plotter to \"combine\" the results from";
  158.    print "all of the devices into a single plot. Currently, you can analyze about";
  159.    print "8 devices. With more than 8 devices, the legend labels run into each other.";
  160.    print " ";
  161.    print "When iostat_plotter is done it will create a subdirectory \"HTML_REPORT\" ";
  162.    print "that contains the plots and an html file \"report.html\". Open that ";
  163.    print "html file in a browser or word processor and you will see the plots ";
  164.    print "and a small write-up about them. Feel free to modify the code but ";
  165.    print "please send back changes. ";
  166.    print " ";
  167.  
  168. # end def
  169.  
  170.  
  171.  
  172. def Three_Chart(x1, y1, x2, y2, x3, y3, xlabel, ylabel1, ylabel2, ylabel3,
  173.                 d1, d2, d3, fsize, flegsize, filename, box_expansion):
  174.    #
  175.    # Creates 3 vertical subplots with legends and 1 x-axis label at the
  176.    #   the bottom
  177.    #
  178.    # x1 = x-axis data for top plot
  179.    # x2 = x-axis data for middle plot
  180.    # x3 = x-axis data for bottom plot
  181.    # y1 = y-axis data for top plot
  182.    # y2 = y-axis data for middle plot
  183.    # y3 = y-axis data for bottom plot
  184.    # xlabel = x-axis label (only on bottom plot)
  185.    # ylabel1 = label for top y-axis
  186.    # ylabel2 = label for middle y-axis
  187.    # ylabel3 = label for bottom plot
  188.    # d1 = data label for top plot
  189.    # d2 = data label for middle plot
  190.    # d3 = data label for bottom plot
  191.    # fsize = font size for tick labels
  192.    # flegsize = font size for legend labels
  193.    # filename = name of file for plot output
  194.    # box_expansion = expansion factor on legend box
  195.    #
  196.  
  197.    # Top plot
  198.    ax1 = plt.subplot(311);                 # Define top plot using subplot function
  199.    plt.plot(x1,y1, "ro-", label=d1);       # Plot the first data set with a red line wiht "o" as a symbol
  200.    plt.grid();
  201.    plt.xlabel(" ");                        # Don't put an x-axis label since it's the top plot
  202.    plt.ylabel(ylabel1, fontsize=6);    # Use a 10 pt font for y-axis label
  203.    ax1.set_xticklabels([]);                # get x-axis tick label
  204.  
  205.    # Legend
  206.    box = ax1.get_position()
  207.    ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  208.    leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  209.                      borderpad=0.15, handletextpad=0.2);
  210.    frame1 = leg1.get_frame();
  211.    frame1.set_facecolor("0.80");           # Make legend box have a gray background
  212.    for t in leg1.get_texts():
  213.       t.set_fontsize(flegsize);               # Change the font size of the legend text to 10 pt.
  214.    # end for
  215.  
  216.    plt.xticks(fontsize=6);
  217.    plt.yticks(fontsize=6);
  218.  
  219.    # Middle plot
  220.    ax2 = plt.subplot(312);
  221.    plt.plot(x2,y2, "bo-", label=d2);
  222.    plt.grid();
  223.    plt.xlabel(" ");
  224.    plt.ylabel(ylabel2, fontsize=fsize);
  225.    ax2.set_xticklabels([]);
  226.  
  227.    # Legend
  228.    box = ax2.get_position();
  229.    ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height]);
  230.    leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  231.                      borderpad=0.15, handletextpad=0.2);
  232.    frame2 = leg2.get_frame();
  233.    frame2.set_facecolor("0.80");
  234.    for t in leg2.get_texts():
  235.       t.set_fontsize(flegsize);
  236.    # end for
  237.  
  238.    plt.xticks(fontsize=fsize);
  239.    plt.yticks(fontsize=fsize);
  240.  
  241.    # Bottom plot
  242.    ax3 = plt.subplot(313);
  243.    plt.plot(x3,y3, "go-", label=d3);
  244.    plt.grid();
  245.    plt.xlabel(xlabel);
  246.    plt.ylabel(ylabel3, fontsize=fsize);
  247.  
  248.    # Legend
  249.    box = ax3.get_position()
  250.    ax3.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  251.    leg3 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  252.                      borderpad=0.15, handletextpad=0.2);
  253.    frame3 = leg3.get_frame();
  254.    frame3.set_facecolor("0.80");
  255.    for t in leg3.get_texts():
  256.       t.set_fontsize(flegsize);
  257.    # end for
  258.  
  259.    plt.xticks(fontsize=fsize);
  260.    plt.yticks(fontsize=fsize);
  261.  
  262.    # Either save the plot to a file or display it to the screen
  263.    if (len(filename) == 0):
  264.       plt.show();
  265.    else:
  266.       plt.savefig(filename);
  267.       plt.close();
  268.    # end if
  269.  
  270. # end def
  271.  
  272.  
  273.  
  274. def Two_Chart(x1, y1, x2, y2, xlabel, ylabel1, ylabel2, d1, d2, fsize, flegsize,
  275.               filename, box_expansion):
  276.    #
  277.    # Creates 2 vertical subplots with legends and 1 x-axis label at the
  278.    #   the bottom
  279.    #
  280.    # x1 = x-axis data for top plot
  281.    # x2 = x-axis data for bottom plot
  282.    # y1 = y-axis data for top plot
  283.    # y2 = y-axis data for bottom plot
  284.    # xlabel = x-axis label (only on bottom plot)
  285.    # ylabel1 = label for top y-axis
  286.    # ylabel2 = label for bottom y-axis
  287.    # d1 = data label for top plot
  288.    # d2 = data label for bottom plot
  289.    # fsize = font size for tick labels
  290.    # flegsize = font size for legend labels
  291.    # filename = name of file for plot output
  292.    # box_expansion = expansion factor for legend
  293.    #
  294.  
  295.    # Top plot
  296.    ax1 = plt.subplot(211);
  297.    plt.plot(x1,y1, "ro-", label=d1);
  298.    plt.grid();
  299.    plt.xlabel(" ");
  300.    plt.ylabel(ylabel1, fontsize=fsize);
  301.    ax1.set_xticklabels([]);
  302.  
  303.    # Legend
  304.    box = ax1.get_position()
  305.    ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  306.    leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  307.                      borderpad=0.15, handletextpad=0.2);
  308.    frame1 = leg1.get_frame();
  309.    frame1.set_facecolor("0.80");
  310.    for t in leg1.get_texts():
  311.       t.set_fontsize(flegsize);
  312.    # end for
  313.  
  314.    # Bottom Plot
  315.    ax2 = plt.subplot(212);
  316.    plt.plot(x2,y2, "go-", label=d2);
  317.    plt.grid();
  318.    plt.xlabel(xlabel);
  319.    plt.ylabel(ylabel2, fontsize=fsize);
  320.  
  321.    # Legend
  322.    box = ax2.get_position()
  323.    ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  324.    leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  325.                      borderpad=0.15, handletextpad=0.2);
  326.    frame2 = leg2.get_frame();
  327.    frame2.set_facecolor("0.80");
  328.    for t in leg2.get_texts():
  329.       t.set_fontsize(fsize);
  330.    # end for
  331.  
  332.    if (len(filename) == 0):
  333.       plt.show();
  334.    else:
  335.       plt.savefig(filename);
  336.       plt.close();
  337.    # end if
  338.  
  339. # end def
  340.  
  341.  
  342.  
  343. def One_Chart(x, y, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion):
  344.    #
  345.    # Creates 1 chart with a legend and 1 x-axis label
  346.    #
  347.    # x = x-axis data
  348.    # y = y-axis data
  349.    # xlabel = x-axis label
  350.    # ylabel1 = label for y-axis
  351.    # d = data label
  352.    # fsize = Font size for tick marks and labels
  353.    # flegsize = Legend font size
  354.    # filename = name of file for plot output
  355.    # box_expansion = expansion factor for legend
  356.    #
  357.    ax1 = plt.subplot(111);
  358.    plt.plot(x,y, "go-", label=d);
  359.    plt.grid();
  360.    plt.xlabel(xlabel);
  361.    plt.ylabel(ylabel, fontsize=fsize);
  362.  
  363.    # Legend
  364.    box = ax1.get_position()
  365.    ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  366.    leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  367.                      borderpad=0.15, handletextpad=0.2);
  368.    frame = leg1.get_frame();
  369.    frame.set_facecolor("0.80");
  370.    for t in leg1.get_texts():
  371.       t.set_fontsize(flegsize);
  372.    # end for
  373.  
  374.    if (len(filename) == 0):
  375.       plt.show();
  376.    else:
  377.       plt.savefig(filename);
  378.       plt.close();
  379.    # end if
  380.  
  381. # end def
  382.  
  383.  
  384.  
  385.  
  386. def plot1(iloop, iplot, combined_plots, f, dirname, x_seconds, user_list, system_list,
  387.           nice_list, fsize, item):
  388.    #
  389.    # Figure 1: Various CPU percentages (user, system, nice) vs. time (3 subplots)
  390.    #
  391.    junk1 = "cpu_utilization" + str(iloop);
  392.    if (combined_plots == 0):
  393.       output_str = "<H4> \n";
  394.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Percentage CPU Time (CPU Utilization)</a>";
  395.       output_str = output_str + ". Device: " + item["device"] + " \n";
  396.       output_str = output_str + "</H4> \n";
  397.    elif (combined_plots == 1):
  398.       output_str = "<H3> \n";
  399.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Percentage CPU Time (CPU Utilization)</a>";
  400.       output_str = output_str + "</H3> \n";
  401.    #end if
  402.    output_str = output_str + " \n";
  403.    output_str = output_str + "<P> \n";
  404.    output_str = output_str + "This figure plots three types of CPU Utilization: (1) User, \n";
  405.    output_str = output_str + "(2) System, and (3) Nice. The User utilization is the  percentage \n";
  406.    output_str = output_str + "of CPU utilization that occurred while executing at the user level \n";
  407.    output_str = output_str + "(applications).The System utilization is the percentage of CPU \n";
  408.    output_str = output_str + "utilization that occurred while executing at the system level \n";
  409.    output_str = output_str + "(kernel). The third time is the Nice utilization which is the \n";
  410.    output_str = output_str + "percentage of CPU utilization that occurred while executing at \n";
  411.    output_str = output_str + "the  user  level with nice priority. \n";
  412.    f.write(output_str);
  413.  
  414.    # make the plot
  415.    ylabel1 = "% CPU Utilization \n by User tasks";
  416.    ylabel2 = "% CPU Utilization \n by System tasks";
  417.    ylabel3 = "% CPU Utilization \n by Nice tasks";
  418.    xlabel = "Time (seconds)";
  419.    d1 = "User";
  420.    d2 = "System";
  421.    d3 = "Nice";
  422.    filename = dirname + "/percentage_cpu_utilization" + str(iloop);
  423.    fsize = 8;
  424.    flegsize = 6;
  425.  
  426.    # Compute box_expansion factor:
  427.    box_expansion = 0.95;   # Default
  428.    ilongest = 0;
  429.    if (len(d1) > ilongest):
  430.       ilongest = len(d1);
  431.    # end if
  432.    if (len(d2) > ilongest):
  433.       ilongest = len(d2);
  434.    # end if
  435.    if (len(d3) > ilongest):
  436.       ilongest = len(d3);
  437.    # end if
  438.    junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  439.    expansion_box = round(junk1,2);
  440.  
  441.    Three_Chart(x_seconds, user_list, x_seconds, system_list, x_seconds, nice_list,
  442.                xlabel, ylabel1, ylabel2, ylabel3, d1, d2, d3, fsize, flegsize,
  443.                filename, box_expansion);
  444.  
  445.    # HTML Output: (Figure html)
  446.    output_str = "<center> \n";
  447.    junk1 = "percentage_cpu_utilization" + str(iloop) + ".png";
  448.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  449.    if (combined_plots == 0):
  450.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Utilization (User, System, and Nice) for device: " + item["device"] + "</strong></center><BR><BR> \n";
  451.    elif (combined_plots == 1):
  452.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Utilization (User, System, and Nice) for device </strong></center><BR><BR> \n";
  453.    #end if
  454.    output_str = output_str + "<BR><BR> \n";
  455.    output_str = output_str + "</P> \n \n";
  456.    f.write(output_str);
  457.  
  458. # end def
  459.  
  460.  
  461.  
  462. def plot2(iloop, iplot,  combined_plots, f, dirname, x_seconds, iowait_list,
  463.           fsize, item):
  464.    #
  465.    # Figure 2: iowait percentage time
  466.    #
  467.    junk1 = "iowait_cpu_utilization" + str(iloop);
  468.    if (combined_plots == 0):
  469.       output_str = "<H4> \n"
  470.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">IOWait Percentage Time</a>";
  471.       output_str = output_str + ". Device: " + item["device"] + " \n";
  472.       output_str = output_str + "</H4> \n";
  473.    elif(combined_plots == 1):
  474.       output_str = "<H3> \n"
  475.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">IOWait Percentage Time</a>";
  476.       output_str = output_str + "</H3> \n";
  477.    # end if
  478.    output_str = output_str + " \n";
  479.    output_str = output_str + "<P> \n";
  480.    output_str = output_str + "This is the percentage of time that the CPU or CPUs were idle \n";
  481.    output_str = output_str + "during which the system had an outstanding disk device I/O request. \n";
  482.    f.write(output_str);
  483.  
  484.    # make the plot
  485.    ylabel = "% IOwait CPU Percentage Time \n Waiting for IO requests";
  486.    xlabel = "Time (seconds)";
  487.    d = "IOwait";
  488.    filename = dirname + "/iowait_percentage_cpu_time" + str(iloop);
  489.    fsize = 8;
  490.    flegsize = 6;
  491.  
  492.    # Compute box_expansion factor:
  493.    box_expansion = 0.96;
  494.    ilongest = 0;
  495.    if (len(d) > ilongest):
  496.       ilongest = len(d);
  497.    # end if
  498.    junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  499.    expansion_box = round(junk1,2);
  500.  
  501.    One_Chart(x_seconds, iowait_list, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion);
  502.  
  503.    # HTML Output:
  504.    output_str = "<center> \n";
  505.    junk1 = "iowait_percentage_cpu_time" + str(iloop) + ".png";
  506.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  507.    if (combined_plots == 0):
  508.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time waiting to process disk requests for device: " + item["device"] + "</strong></center><BR><BR> \n";
  509.    elif (combined_plots == 1):
  510.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time waiting to process disk requests </strong></center><BR><BR> \n";
  511.    # end if
  512.    output_str = output_str + "<BR><BR> \n";
  513.    output_str = output_str + "</P> \n \n";
  514.    f.write(output_str);
  515.  
  516. # end def
  517.  
  518.  
  519.  
  520. def plot3(iloop, iplot, combined_plots, f, dirname, x_seconds, steal_list,
  521.           fsize, item):
  522.    #
  523.    # Figure 3: Steal Time
  524.    #
  525.    junk1 = "steal_cpu_utilization" + str(iloop);
  526.    if (combined_plots == 0):
  527.       output_str = "<H4> \n"
  528.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Steal Percentage Time</a>";
  529.       output_str = output_str + ". Device: " + item["device"] + " \n";
  530.       output_str = output_str + "</H4> \n";
  531.    elif (combined_plots == 1):
  532.       output_str = "<H3> \n"
  533.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Steal Percentage Time</a>";
  534.       output_str = output_str + "</H3> \n";
  535.    # end if
  536.    output_str = output_str + " \n";
  537.    output_str = output_str + "<P> \n";
  538.    output_str = output_str + "This is the percentage of time spent in involuntary \n";
  539.    output_str = output_str + "wait by the virtual CPU or CPUs while the hypervisor was \n";
  540.    output_str = output_str + "servicing another virtual processor. \n";
  541.    f.write(output_str);
  542.  
  543.    # make the plot
  544.    ylabel = "% Steal CPU Percentage Time \n Waiting for IO requests";
  545.    xlabel = "Time (seconds)";
  546.    d = "Steal";
  547.    filename = dirname + "/steal_percentage_cpu_time" + str(iloop);
  548.    fsize = 8;
  549.    flegsize = 6;
  550.  
  551.    # Compute box_expansion factor:
  552.    box_expansion = 0.96;
  553.    ilongest = 0;
  554.    if (len(d) > ilongest):
  555.       ilongest = len(d);
  556.    # end if
  557.    junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  558.    expansion_box = round(junk1,2);
  559.  
  560.    One_Chart(x_seconds, steal_list, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion);
  561.  
  562.    # HTML Output:
  563.    output_str = "<center> \n";
  564.    junk1 = "steal_percentage_cpu_time" + str(iloop) + ".png";
  565.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  566.    if (combined_plots == 0):
  567.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in involuntary waiting for device: " + item["device"] + "</strong></center><BR><BR> \n";
  568.    elif (combined_plots == 1):
  569.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in involuntary waiting </strong></center><BR><BR> \n";
  570.    # end if
  571.    output_str = output_str + "<BR><BR> \n";
  572.    output_str = output_str + "</P> \n \n";
  573.    f.write(output_str);
  574.  
  575. # end def
  576.  
  577.  
  578.  
  579. def plot4(iloop, iplot, combined_plots, f, dirname, x_seconds, idle_list,
  580.           fsize, item):
  581.    #
  582.    # Figure 4: Idle Time
  583.    #
  584.    junk1 = "idle_cpu_utilization" + str(iloop);
  585.    if (combined_plots == 0):
  586.       output_str = "<H4> \n"
  587.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Idle Percentage Time with no IO requests</a>";
  588.       output_str = output_str + ". Device: " + item["device"] + " \n";
  589.       output_str = output_str + "</H4> \n";
  590.    elif(combined_plots == 1):
  591.       output_str = "<H3> \n"
  592.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Idle Percentage Time with no IO requests</a>";
  593.       output_str = output_str + "</H3> \n";
  594.    # end if
  595.    output_str = output_str + " \n";
  596.    output_str = output_str + "<P> \n";
  597.    output_str = output_str + "This is the percentage of time that the CPU or CPUs were \n";
  598.    output_str = output_str + "idle and the system did not have an outstanding disk I/O request. \n";
  599.    f.write(output_str);
  600.  
  601.    # make the plot
  602.    ylabel = "% Idle CPU Percentage Time \n and no Waiting for IO requests";
  603.    xlabel = "Time (seconds)";
  604.    d = "Idle";
  605.    filename = dirname + "/idle_percentage_cpu_time" + str(iloop);
  606.    fsize = 8;
  607.    flegsize = 6;
  608.  
  609.    # Compute box_expansion factor:
  610.    box_expansion = 0.97;
  611.    ilongest = 0;
  612.    if (len(d) > ilongest):
  613.       ilongest = len(d);
  614.    # end if
  615.    junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  616.    expansion_box = round(junk1,2);
  617.  
  618.    One_Chart(x_seconds, idle_list, xlabel, ylabel, d, fsize, flegsize, filename, box_expansion);
  619.  
  620.    # HTML Output:
  621.    output_str = "<center> \n";
  622.    junk1 = "idle_percentage_cpu_time" + str(iloop) + ".png";
  623.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  624.    if (combined_plots == 0):
  625.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in idle activities with no IO requests for device: " + item["device"] + "</strong></center><BR><BR> \n";
  626.    elif (combined_plots == 1):
  627.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time in idle activities with no IO requests </strong></center><BR><BR> \n";
  628.    # end if
  629.    output_str = output_str + "<BR><BR> \n";
  630.    output_str = output_str + "</P> \n \n";
  631.    f.write(output_str);
  632. # end if
  633.  
  634.  
  635.  
  636.  
  637. def plot5(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  638.           fsize, item, device_data_list, line_list):
  639.    #
  640.    # Figure 5: Read Throughput and Total CPU Utilization
  641.    #
  642.    junk1 = "rmb_total_cpu" + str(iloop);
  643.    if (combined_plots == 0):
  644.       output_str = "<H4> \n"
  645.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Throughput and Total CPU Utilization</a>";
  646.       output_str = output_str + ". Device: " + item["device"] + " \n";
  647.       output_str = output_str + "</H4> \n";
  648.    elif (combined_plots == 1):
  649.       output_str = "<H3> \n"
  650.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Throughput and Total CPU Utilization</a>";
  651.       output_str = output_str + "</H3> \n";
  652.    # end if
  653.    output_str = output_str + " \n";
  654.    output_str = output_str + "<P> \n";
  655.    output_str = output_str + "This figure has two parts. The top graph plots the Read Rate \n";
  656.    output_str = output_str + "in MB/s versus time and the bottom graph plots the Total CPU \n";
  657.    output_str = output_str + "Utilization percentage (User Time + System Time). \n";
  658.    f.write(output_str);
  659.  
  660.    # make the plot
  661.    ylabel1 = "Read Throughput (MB/s)";
  662.    ylabel2 = "Total CPU Percentage Utilization";
  663.    xlabel = "Time (seconds)";
  664.    d1 = "Read Throughput";
  665.    d2 = "Total CPU Util";
  666.    filename = dirname + "/read_throughput" + str(iloop);
  667.    fsize = 8;
  668.    flegsize = 6;
  669.  
  670.    if (combined_plots == 0):
  671.  
  672.       # Compute box_expansion factor:
  673.       box_expansion = 0.88;   # default
  674.       ilongest = 0;
  675.       if (len(d1) > ilongest):
  676.          ilongest = len(d1);
  677.       # end if
  678.       if (len(d2) > ilongest):
  679.          ilongest = len(d2);
  680.       # end if
  681.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  682.       expansion_box = round(junk1,2);
  683.  
  684.       Two_Chart(x_seconds, item["rMB"], x_seconds, time_sum_list, xlabel, ylabel1,
  685.                 ylabel2, d1, d2, fsize, flegsize, filename, box_expansion);
  686.    elif (combined_plots == 1):
  687.       jloop = -1;
  688.  
  689.       # Compute expansion_box factor:
  690.       box_expansion = 0.88;   # default
  691.       ilongest = 0;
  692.       for item in device_data_list:
  693.          if (len(d1) > ilongest):
  694.             ilongest = len(d1);
  695.          # end if
  696.          d11 = item["device"] + " " + d1;
  697.          if (len(d11) > ilongest):
  698.             ilongest = len(d11);
  699.          # end if
  700.          if (len(d2) > ilongest):
  701.             ilongest = len(d2);
  702.          # end if
  703.          d22 = item["device"] + " " + d2;
  704.          if (len(d22) > ilongest):
  705.             ilongest = len(d22);
  706.          # end if
  707.       # end for
  708.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  709.       expansion_box = round(junk1,2);
  710.  
  711.       # Top plot
  712.       for item in device_data_list:
  713.          jloop = jloop + 1;
  714.  
  715.          marker = line_list[jloop];
  716.          ax1 = plt.subplot(211);
  717.          d11 = item["device"] + " " + d1;
  718.          plt.plot(x_seconds, item["rMB"], marker, label=d11);
  719.          plt.xlabel(" ");
  720.          plt.ylabel(ylabel1, fontsize=fsize);
  721.          ax1.set_xticklabels([]);
  722.       # end for
  723.       plt.grid();
  724.       # Legend
  725.       box = ax1.get_position();
  726.       ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height]);
  727.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  728.                         borderpad=0.15, handletextpad=0.2);
  729.       frame1 = leg1.get_frame();
  730.       frame1.set_facecolor("0.80");
  731.       for t in leg1.get_texts():
  732.          t.set_fontsize(flegsize);
  733.       # end for
  734.  
  735.       # Bottom Plot
  736.       fsize = 8;
  737.       flegsize = 6;
  738.       ax2 = plt.subplot(212);
  739.       plt.plot(x_seconds, time_sum_list, "go-", label=d2);
  740.       plt.grid();
  741.       plt.xlabel(xlabel);
  742.       plt.ylabel(ylabel2, fontsize=fsize);
  743.  
  744.       # Legend
  745.       box = ax2.get_position()
  746.       ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  747.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0.0, labelspacing=0,
  748.                         borderpad=0.15, handletextpad=0.2);
  749.       frame2 = leg2.get_frame();
  750.       frame2.set_facecolor("0.80");
  751.       for t in leg2.get_texts():
  752.          t.set_fontsize(flegsize);
  753.       # end for
  754.  
  755.       if (len(filename) == 0):
  756.          plt.show();
  757.       else:
  758.          plt.savefig(filename);
  759.          plt.close();
  760.       # end if
  761.    # end if
  762.  
  763.    # HTML Output:
  764.    output_str = "<center> \n";
  765.    junk1 = "read_throughput" + str(iloop) + ".png";
  766.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  767.    if (combined_plots == 0):
  768.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Throughput (MB/s) and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
  769.    if (combined_plots == 1):
  770.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Throughput (MB/s) and Total CPU Utilization Percentage </strong></center><BR><BR> \n";
  771.    # end if
  772.    output_str = output_str + "<BR><BR> \n";
  773.    output_str = output_str + "</P> \n \n";
  774.    f.write(output_str);
  775.  
  776. # end if
  777.  
  778.  
  779. def plot6(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  780.           fsize, item, device_data_list, line_list):
  781.    #
  782.    # Figure 6: Write Throughput and Total CPU Utilization
  783.    #
  784.    junk1 = "wmb_total_cpu" + str(iloop);
  785.    if (combined_plots == 0):
  786.       output_str = "<H4> \n"
  787.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Write Throughput and Total CPU Utilization</a>";
  788.       output_str = output_str + ". Device: " + item["device"] + " \n";
  789.       output_str = output_str + "</H4> \n";
  790.    elif (combined_plots == 1):
  791.       output_str = "<H3> \n"
  792.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Write Throughput and Total CPU Utilization</a>";
  793.       output_str = output_str + "</H3> \n";
  794.    # end if
  795.    output_str = output_str + " \n";
  796.    output_str = output_str + "<P> \n";
  797.    output_str = output_str + "This figure has two parts. The top graph plots the Write Rate \n";
  798.    output_str = output_str + "in MB/s versus time and the bottom graph plots the Total CPU \n";
  799.    output_str = output_str + "Utilization percentage (User Time + System Time). \n";
  800.    f.write(output_str);
  801.  
  802.    # make the plot
  803.    ylabel1 = "Write Throughput (MB/s)";
  804.    ylabel2 = "Total CPU Percentage Utilization";
  805.    xlabel = "Time (seconds)";
  806.    d1 = "Write Throughput";
  807.    d2 = "Total CPU Utilization";
  808.    filename = dirname + "/write_throughput" + str(iloop);
  809.    fsize = 8;
  810.    flegsize = 6;
  811.  
  812.    if (combined_plots == 0):
  813.  
  814.       # Compute box_expansion factor:
  815.       box_expansion = 0.82;   # default
  816.       ilongest = 0;
  817.       if (len(d1) > ilongest):
  818.          ilongest = len(d1);
  819.       # end if
  820.       if (len(d2) > ilongest):
  821.          ilongest = len(d2);
  822.       # end if
  823.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  824.       expansion_box = round(junk1,2);
  825.  
  826.       Two_Chart(x_seconds, item["wMB"], x_seconds, time_sum_list, xlabel, ylabel1,
  827.                 ylabel2, d1, d2, fsize, flegsize, filename, box_expansion);
  828.    elif (combined_plots == 1):
  829.       jloop = -1;
  830.  
  831.       # Compute box_expansion factor:
  832.       box_expansion = 0.88;   # Default
  833.       ilongest = 0;
  834.       for item in device_data_list:
  835.          if (len(d1) > ilongest):
  836.             ilongest = len(d1);
  837.          # end if
  838.          d11 = item["device"] + " " + d1;
  839.          if (len(d11) > ilongest):
  840.             ilongest = len(d11);
  841.          # end if
  842.          if (len(d2) > ilongest):
  843.             ilongest = len(d2);
  844.          # end if
  845.          d22 = item["device"] + " " + d2;
  846.          if (len(d22) > ilongest):
  847.             ilongest = len(d22);
  848.          # end if
  849.       # end for
  850.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  851.       expansion_box = round(junk1,2);
  852.  
  853.       # Top plot
  854.       for item in device_data_list:
  855.          jloop = jloop + 1;
  856.  
  857.          marker = line_list[jloop];
  858.          ax1 = plt.subplot(211);
  859.          d11 = item["device"] + " " + d1;
  860.          plt.plot(x_seconds, item["wMB"], marker, label=d11);
  861.          plt.xlabel(" ");
  862.          plt.ylabel(ylabel1, fontsize=fsize);
  863.          ax1.set_xticklabels([]);
  864.       # end for
  865.       plt.grid();
  866.       # Legend
  867.       box = ax1.get_position();
  868.       ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  869.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  870.                         borderpad=0.15, handletextpad=0.2);
  871.       frame1 = leg1.get_frame();
  872.       frame1.set_facecolor("0.80");
  873.       for t in leg1.get_texts():
  874.          t.set_fontsize(flegsize);
  875.       # end for
  876.  
  877.       # Bottom Plot
  878.       ax2 = plt.subplot(212);
  879.       plt.plot(x_seconds, time_sum_list, "go-", label=d2);
  880.       plt.grid();
  881.       plt.xlabel(xlabel);
  882.       plt.ylabel(ylabel2, fontsize=fsize);
  883.  
  884.       # Legend
  885.       box = ax2.get_position()
  886.       ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  887.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  888.                         borderpad=0.15, handletextpad=0.2);
  889.       frame2 = leg2.get_frame();
  890.       frame2.set_facecolor("0.80");
  891.       for t in leg2.get_texts():
  892.          t.set_fontsize(flegsize);
  893.       # end for
  894.  
  895.       if (len(filename) == 0):
  896.          plt.show();
  897.       else:
  898.          plt.savefig(filename);
  899.          plt.close();
  900.       # end if
  901.    # end if
  902.  
  903.    # HTML Output:
  904.    output_str = "<center> \n";
  905.    junk1 = "write_throughput" + str(iloop) + ".png";
  906.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  907.    if (combined_plots == 0):
  908.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Write Throughput (MB/s) and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
  909.    elif (combined_plots == 1):
  910.        output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Write Throughput (MB/s) and Total CPU Utilization Percentage </strong></center><BR><BR> \n";
  911.    # end if
  912.    output_str = output_str + "<BR><BR> \n";
  913.    output_str = output_str + "</P> \n \n";
  914.    f.write(output_str);
  915.  
  916. # end def
  917.  
  918.  
  919.  
  920. def plot7(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  921.           fsize, item, device_data_list, line_list):
  922.    #
  923.    # Figure 7: Read Request complete rate, Write Request complete rate, and Total CPU Utilization
  924.    #
  925.    if (combined_plots == 0):
  926.       output_str = "<H4> \n"
  927.       junk1 = "requests_complete_total_cpu" + str(iloop);
  928.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Requests Complete, Write Requests Complete, and Total CPU Utilization</a>";
  929.       output_str = output_str + ". Device: " + item["device"] + " \n";
  930.       output_str = output_str + "</H4> \n";
  931.    elif (combined_plots == 1):
  932.       output_str = "<H3> \n"
  933.       junk1 = "requests_complete_total_cpu" + str(iloop);
  934.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Requests Complete, Write Requests Complete, and Total CPU Utilization</a>";
  935.       output_str = output_str + "</H3> \n";
  936.    # end if
  937.  
  938.    output_str = output_str + " \n";
  939.    output_str = output_str + "<P> \n";
  940.    output_str = output_str + "This figure has three parts. The top graph plots the number (after \n";
  941.    output_str = output_str + "merges) of read requests completed per second for the device \n";
  942.    output_str = output_str + "versus time. The middle graph plots the number (after merges) \n";
  943.    output_str = output_str + "of write requests completed per second for the device versus time. \n";
  944.    output_str = output_str + "The bottom graph plots the Total CPU Utilization percentage \n";
  945.    output_str = output_str + "(User Time + System Time). \n";
  946.    f.write(output_str);
  947.  
  948.    # make the plot
  949.    ylabel1 = "Read requests \n complete rate \n (requests/s)";
  950.    ylabel2 = "Write requests \n complete rate \n (requests/s)";
  951.    ylabel3 = "Total CPU \n Percentage \n Utilization";
  952.    xlabel = "Time (seconds)";
  953.    d1 = "Read reqs complete";
  954.    d2 = "Write reqs complete";
  955.    d3 = "Total CPU Utilization";
  956.    filename = dirname + "/read_write_requests_complete_rate" + str(iloop);
  957.    fsize = 8;
  958.    flegsize = 6;
  959.  
  960.    if (combined_plots == 0):
  961.  
  962.       # Compute box_expansion factor:
  963.       box_expansion = 0.86;    # default
  964.       ilongest = 0;
  965.       if (len(d1) > ilongest):
  966.          ilongest = len(d1);
  967.       # end if
  968.       if (len(d2) > ilongest):
  969.          ilongest = len(d2);
  970.       # end if
  971.       if (len(d3) > ilongest):
  972.          ilongest = len(d3);
  973.       # end if
  974.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  975.       expansion_box = round(junk1,2);
  976.  
  977.       Three_Chart(x_seconds, item["r"], x_seconds, item["w"], x_seconds, time_sum_list, xlabel, ylabel1,
  978.                   ylabel2, ylabel3, d1, d2, d3, fsize, flegsize, filename, box_expansion);
  979.    elif (combined_plots == 1):
  980.       jloop = -1;
  981.  
  982.       # Compute box_expansion factor:
  983.       expansion_box = 0.86;   # default
  984.       ilongest = 0;
  985.       for item in device_data_list:
  986.          if (len(d1) > ilongest):
  987.             ilongest = len(d1);
  988.          # end if
  989.          d11 = item["device"] + " " + d1;
  990.          if (len(d11) > ilongest):
  991.             ilongest = len(d11);
  992.          # end if
  993.          if (len(d2) > ilongest):
  994.             ilongest = len(d2);
  995.          # end if
  996.          d22 = item["device"] + " " + d2;
  997.          if (len(d22) > ilongest):
  998.             ilongest = len(d22);
  999.          # end if
  1000.          if (len(d3) > ilongest):
  1001.             ilongest = len(d3);
  1002.          # end if
  1003.          d33 = item["device"] + " " + d3;
  1004.          if (len(d33) > ilongest):
  1005.             ilongest = len(d33);
  1006.       # end for
  1007.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1008.       expansion_box = round(junk1,2);
  1009.  
  1010.       # Top plot:
  1011.       for item in device_data_list:
  1012.          jloop = jloop + 1;
  1013.  
  1014.          marker = line_list[jloop];
  1015.          ax1 = plt.subplot(311);                 # Define top plot using subplot function
  1016.          d11 = item["device"] + " " + d1;
  1017.          plt.plot(x_seconds, item["r"], marker, label=d11);
  1018.          plt.xlabel(" ");                        # Don't put an x-axis label since it's the top plot
  1019.          plt.ylabel(ylabel1, fontsize=fsize);    # Use a 10 pt font for y-axis label
  1020.          ax1.set_xticklabels([]);                # get x-axis tick label
  1021.  
  1022.          plt.xticks(fontsize=fsize);
  1023.          plt.yticks(fontsize=fsize);
  1024.       # end for
  1025.       plt.grid();
  1026.       # Legend
  1027.       box = ax1.get_position()
  1028.       ax1.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1029.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1030.                         borderpad=0.15, handletextpad=0.2);
  1031.       frame1 = leg1.get_frame();
  1032.       frame1.set_facecolor("0.80");           # Make legend box have a gray background
  1033.       for t in leg1.get_texts():
  1034.          t.set_fontsize(flegsize);               # Change the font size of the legend text to 10 pt.
  1035.       # end if
  1036.  
  1037.       # Middle Plot:
  1038.       jloop = -1;
  1039.       for item in device_data_list:
  1040.          jloop = jloop + 1;
  1041.  
  1042.          marker = line_list[jloop];
  1043.          ax2 = plt.subplot(312);
  1044.          d22 = item["device"] + " " + d2;
  1045.          plt.plot(x_seconds, item["w"], marker, label=d22);
  1046.          plt.xlabel(" ");
  1047.          plt.ylabel(ylabel2, fontsize=fsize);
  1048.          ax2.set_xticklabels([]);
  1049.  
  1050.          plt.xticks(fontsize=fsize);
  1051.          plt.yticks(fontsize=fsize);
  1052.       # end for
  1053.       plt.grid();
  1054.       # Legend:
  1055.       box = ax2.get_position()
  1056.       ax2.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1057.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1058.                         borderpad=0.15, handletextpad=0.2);
  1059.       frame2 = leg2.get_frame();
  1060.       frame2.set_facecolor("0.80");
  1061.       for t in leg2.get_texts():
  1062.          t.set_fontsize(flegsize);
  1063.       # end for
  1064.  
  1065.       # Bottom plot
  1066.       ax3 = plt.subplot(313);
  1067.       plt.plot(x_seconds, time_sum_list, "go-", label=d3);
  1068.       plt.grid();
  1069.       plt.xlabel(xlabel);
  1070.       plt.ylabel(ylabel3, fontsize=fsize);
  1071.  
  1072.       # Legend
  1073.       box = ax3.get_position()
  1074.       ax3.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1075.       leg3 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1076.                         borderpad=0.15, handletextpad=0.2);
  1077.       frame3 = leg3.get_frame();
  1078.       frame3.set_facecolor("0.80");
  1079.       for t in leg3.get_texts():
  1080.          t.set_fontsize(flegsize);
  1081.       # end for
  1082.  
  1083.       plt.xticks(fontsize=fsize);
  1084.       plt.yticks(fontsize=fsize);
  1085.  
  1086.       # Either save the plot to a file or display it to the screen
  1087.       if (len(filename) == 0):
  1088.          plt.show();
  1089.       else:
  1090.          plt.savefig(filename);
  1091.          plt.close();
  1092.       # end if
  1093.    # end if
  1094.  
  1095.    # HTML Output:
  1096.    output_str = "<center> \n";
  1097.    junk1 = "read_write_requests_complete_rate" + str(iloop) + ".png";
  1098.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  1099.    if (combined_plots == 0):
  1100.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Requests Completed Rate (requests/s), Write Requests Completed Rate (requests/s), and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
  1101.    elif (combined_plots == 1):
  1102.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Requests Completed Rate (requests/s), Write Requests Completed Rate (requests/s), and Total CPU Utilization Percentage for device </strong></center><BR><BR> \n";
  1103.    # end if
  1104.    output_str = output_str + "<BR><BR> \n";
  1105.    output_str = output_str + "</P> \n \n";
  1106.    f.write(output_str);
  1107. # end def
  1108.  
  1109.  
  1110.  
  1111. def plot8(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  1112.           fsize, item, device_data_list, line_list):
  1113.    #
  1114.    # Figure 8: Read Request merge rate, Write Request merge rate, and Total CPU Utilization
  1115.    #
  1116.    junk1 = "requests_merged_total_cpu" + str(iloop);
  1117.    if (combined_plots == 0):
  1118.       output_str = "<H4> \n"
  1119.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Requests Merged rate, Write Requests Merged rate, and Total CPU Utilization</a>";
  1120.       output_str = output_str + ". Device: " + item["device"] + " \n";
  1121.       output_str = output_str + "</H4> \n";
  1122.    elif (combined_plots == 1):
  1123.       output_str = "<H3> \n"
  1124.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Read Requests Merged rate, Write Requests Merged rate, and Total CPU Utilization</a>";
  1125.       output_str = output_str + "</H3> \n";
  1126.    # end if
  1127.    output_str = output_str + " \n";
  1128.    output_str = output_str + "<P> \n";
  1129.    output_str = output_str + "This figure has three parts. The top graph plots the number \n";
  1130.    output_str = output_str + "of read requests merged per second that were queued to the device. \n";
  1131.    output_str = output_str + "The middle graph plots the number of write requests merged per \n";
  1132.    output_str = output_str + "second that were queued to the device. The bottom graph plots \n";
  1133.    output_str = output_str + "the Total CPU Utilization percentage (User Time + System Time). \n";
  1134.    f.write(output_str);
  1135.  
  1136.    # make the plot
  1137.    ylabel1 = "Read request \n merged rate \n (requests/s)";
  1138.    ylabel2 = "Write request \n merged rate \n (requests/s)";
  1139.    ylabel3 = "Total CPU \n Percentage \n Utilization";
  1140.    xlabel = "Time (seconds)";
  1141.    d1 = "Read reqs merged";
  1142.    d2 = "Write reqs merged";
  1143.    d3 = "Total CPU Utilization";
  1144.    filename = dirname + "/read_write_requests_merged_rate" + str(iloop);
  1145.    fsize = 8;
  1146.    flegsize = 6;
  1147.  
  1148.    if (combined_plots == 0):
  1149.  
  1150.       # Compute box_expansion factor:
  1151.       box_expansion = 0.86;   # default
  1152.       ilongest = 0;
  1153.       if (len(d1) > ilongest):
  1154.          ilongest = len(d1);
  1155.       # end if
  1156.       if (len(d2) > ilongest):
  1157.          ilongest = len(d2);
  1158.       # end if
  1159.       if (len(d3) > ilongest):
  1160.          ilongest = len(d3);
  1161.       # end if
  1162.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1163.       expansion_box = round(junk1,2);
  1164.  
  1165.       Three_Chart(x_seconds, item["rrqm"], x_seconds, item["wrqm"], x_seconds, time_sum_list,
  1166.                   xlabel, ylabel1, ylabel2, ylabel3, d1, d2, d3, fsize, flegsize,
  1167.                   filename, box_expansion);
  1168.    elif (combined_plots == 1):
  1169.       jloop = -1;
  1170.  
  1171.       # Compute box_expansion factor:
  1172.       expansion_box = 0.87;   # default
  1173.       ilongest = 0;
  1174.       for item in device_data_list:
  1175.          if (len(d1) > ilongest):
  1176.             ilongest = len(d1);
  1177.          # end if
  1178.          d11 = item["device"] + " " + d1;
  1179.          if (len(d11) > ilongest):
  1180.             ilongest = len(d11);
  1181.          # end if
  1182.          if (len(d2) > ilongest):
  1183.             ilongest = len(d2);
  1184.          # end if
  1185.          d22 = item["device"] + " " + d2;
  1186.          if (len(d22) > ilongest):
  1187.             ilongest = len(d22);
  1188.          # end if
  1189.          if (len(d3) > ilongest):
  1190.             ilongest = len(d3);
  1191.          # end if
  1192.          d33 = item["device"] + " " + d3;
  1193.          if (len(d33) > ilongest):
  1194.             ilongest = len(d33);
  1195.          # end if
  1196.       # end for
  1197.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1198.       expansion_box = round(junk1,2);
  1199.  
  1200.       # Top Plot
  1201.       for item in device_data_list:
  1202.          jloop = jloop + 1;
  1203.  
  1204.          marker = line_list[jloop];
  1205.          ax1 = plt.subplot(311);                 # Define top plot using subplot function
  1206.          d11 = item["device"] + " " + d1;
  1207.          plt.plot(x_seconds, item["rrqm"], marker, label=d11);
  1208.          plt.xlabel(" ");                        # Don't put an x-axis label since it's the top plot
  1209.          plt.ylabel(ylabel1, fontsize=fsize);    # Use a 10 pt font for y-axis label
  1210.          ax1.set_xticklabels([]);                # get x-axis tick label
  1211.       # end if
  1212.       plt.grid();
  1213.       # Legend
  1214.       box = ax1.get_position()
  1215.       ax1.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1216.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1217.                         borderpad=0.15, handletextpad=0.2);
  1218.       frame1 = leg1.get_frame();
  1219.       frame1.set_facecolor("0.80");           # Make legend box have a gray background
  1220.       for t in leg1.get_texts():
  1221.          t.set_fontsize(flegsize);            # Change the font size of the legend text to 10 pt.
  1222.       # end for
  1223.       plt.xticks(fontsize=fsize);
  1224.       plt.yticks(fontsize=fsize);
  1225.  
  1226.       # Middle plot
  1227.       jloop = -1;
  1228.  
  1229.       for item in device_data_list:
  1230.          jloop = jloop + 1;
  1231.  
  1232.          marker = line_list[jloop];
  1233.          ax2 = plt.subplot(312);
  1234.          d22 = item["device"] + " " + d2;
  1235.          plt.plot(x_seconds, item["wrqm"], marker, label=d22);
  1236.          plt.xlabel(" ");
  1237.          plt.ylabel(ylabel2, fontsize=fsize);
  1238.          ax2.set_xticklabels([]);
  1239.       # end for
  1240.       plt.grid();
  1241.       # Legend:
  1242.       box = ax2.get_position()
  1243.       ax2.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1244.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1245.                         borderpad=0.15, handletextpad=0.2);
  1246.       frame2 = leg2.get_frame();
  1247.       frame2.set_facecolor("0.80");
  1248.       for t in leg2.get_texts():
  1249.          t.set_fontsize(flegsize);
  1250.       # end for
  1251.       plt.xticks(fontsize=fsize);
  1252.       plt.yticks(fontsize=fsize);
  1253.  
  1254.       # Bottom plot
  1255.       ax3 = plt.subplot(313);
  1256.       plt.plot(x_seconds, time_sum_list, "go-", label=d3);
  1257.       plt.grid();
  1258.       plt.xlabel(xlabel);
  1259.       plt.ylabel(ylabel3, fontsize=fsize);
  1260.  
  1261.       # Legend
  1262.       box = ax3.get_position()
  1263.       ax3.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1264.       leg3 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1265.                         borderpad=0.15, handletextpad=0.2);
  1266.       frame3 = leg3.get_frame();
  1267.       frame3.set_facecolor("0.80");
  1268.       for t in leg3.get_texts():
  1269.          t.set_fontsize(flegsize);
  1270.       # end for
  1271.  
  1272.       plt.xticks(fontsize=fsize);
  1273.       plt.yticks(fontsize=fsize);
  1274.  
  1275.       # Either save the plot to a file or display it to the screen
  1276.       if (len(filename) == 0):
  1277.          plt.show();
  1278.       else:
  1279.          plt.savefig(filename);
  1280.          plt.close();
  1281.       # end if
  1282.    # end if
  1283.  
  1284.    # HTML Output:
  1285.    output_str = "<center> \n";
  1286.    junk1 = "read_write_requests_merged_rate" + str(iloop) + ".png";
  1287.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  1288.    if (combined_plots == 0):
  1289.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Requests Merged Rate (requests/s), Write Requests Merged Rate (requests/s), and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
  1290.    elif (combined_plots == 1):
  1291.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Read Requests Merged Rate (requests/s), Write Requests Merged Rate (requests/s), and Total CPU Utilization Percentage </strong></center><BR><BR> \n";
  1292.    # end if
  1293.    output_str = output_str + "<BR><BR> \n";
  1294.    output_str = output_str + "</P> \n \n";
  1295.    f.write(output_str);
  1296.  
  1297. # end def
  1298.  
  1299.  
  1300. def plot9(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  1301.           fsize, item, device_data_list, line_list):
  1302.    #
  1303.    # Figure 9: Avg. Request Size, Avg. Queue Length, and Total CPU Utilization
  1304.    #
  1305.    junk1 = "requests_queue_total_cpu" + str(iloop);
  1306.    if (combined_plots == 0):
  1307.       output_str = "<H4> \n"
  1308.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Average Request Size, Average Queue Length, and Total CPU Utilization</a>";
  1309.       output_str = output_str + ". Device: " + item["device"] + " \n";
  1310.       output_str = output_str + "</H4> \n";
  1311.    elif (combined_plots == 1):
  1312.       output_str = "<H3> \n"
  1313.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Average Request Size, Average Queue Length, and Total CPU Utilization</a>";
  1314.       output_str = output_str + "</H3> \n";
  1315.    # end if
  1316.    output_str = output_str + " \n";
  1317.    output_str = output_str + "<P> \n";
  1318.    output_str = output_str + "This figure has three parts. The top graph plots the average \n";
  1319.    output_str = output_str + "size (in sectors) of the requests that were issued to the \n";
  1320.    output_str = output_str + "device. The middle graph plots the average queue length of \n";
  1321.    output_str = output_str + "the requests that were issued to the device. The bottom graph \n";
  1322.    output_str = output_str + "plots the Total CPU Utilization percentage (User Time + System \n";
  1323.    output_str = output_str + "Time). \n";
  1324.    f.write(output_str);
  1325.  
  1326.    # make the plot
  1327.    ylabel1 = "Average Size of \n IO requests \n (sectors)";
  1328.    ylabel2 = "Average Queue length \n of requests ";
  1329.    ylabel3 = "Total CPU \n Percentage \n Utilization";
  1330.    xlabel = "Time (seconds)";
  1331.    d1 = "Avg. Req. Size";
  1332.    d2 = "Avg. Queue length";
  1333.    d3 = "Total CPU Utilization";
  1334.    filename = dirname + "/requests_queue_total_cpu" + str(iloop);
  1335.    fsize = 8;
  1336.    flegsize = 6;
  1337.  
  1338.    if (combined_plots == 0):
  1339.  
  1340.       # Compute box_expansion factor:
  1341.       box_expansion = 0.86;   # default
  1342.       ilongest = 0;
  1343.       if (len(d1) > ilongest):
  1344.          ilongest = len(d1);
  1345.       # end if
  1346.       if (len(d2) > ilongest):
  1347.          ilongest = len(d2);
  1348.       # end if
  1349.       if (len(d3) > ilongest):
  1350.          ilongest = len(d3);
  1351.       # end if
  1352.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1353.       expansion_box = round(junk1,2);
  1354.  
  1355.       Three_Chart(x_seconds, item["avgrqsz"], x_seconds, item["avgqusz"], x_seconds, time_sum_list,
  1356.                   xlabel, ylabel1, ylabel2, ylabel3, d1, d2, d3, fsize, flegsize,
  1357.                   filename, box_expansion);
  1358.    elif (combined_plots == 1):
  1359.       jloop = -1;
  1360.  
  1361.       # Compute box_expansion factor:
  1362.       box_expansion = 0.87;   # default
  1363.       ilongest = 0;
  1364.       for item in device_data_list:
  1365.          if (len(d1) > ilongest):
  1366.             ilongest = len(d1);
  1367.          # end if
  1368.          d11 = item["device"] + " " + d1;
  1369.          if (len(d11) > ilongest):
  1370.             ilongest = len(d11);
  1371.          # end if
  1372.          if (len(d2) > ilongest):
  1373.             ilongest = len(d2);
  1374.          # end if
  1375.          d22 = item["device"] + " " + d2;
  1376.          if (len(d22) > ilongest):
  1377.             ilongest = len(d22);
  1378.          # end if
  1379.          if (len(d3) > ilongest):
  1380.             ilongest = len(d3);
  1381.          # end if
  1382.          d33 = item["device"] + " " + d3;
  1383.          if (len(d33) > ilongest):
  1384.             ilongest = len(d33);
  1385.          # end if
  1386.       # end for
  1387.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1388.       expansion_box = round(junk1,2);
  1389.  
  1390.       # Top plot
  1391.       for item in device_data_list:
  1392.          jloop = jloop + 1;
  1393.  
  1394.          marker = line_list[jloop];
  1395.          ax1 = plt.subplot(311);                 # Define top plot using subplot function
  1396.          d11 = item["device"] + " " + d1;
  1397.          plt.plot(x_seconds, item["avgrqsz"], marker, label=d11);
  1398.          plt.xlabel(" ");                        # Don't put an x-axis label since it's the top plot
  1399.          plt.ylabel(ylabel1, fontsize=fsize);    # Use a 10 pt font for y-axis label
  1400.          ax1.set_xticklabels([]);                # get x-axis tick label
  1401.       # end if
  1402.       plt.grid();
  1403.       # Legend
  1404.       box = ax1.get_position()
  1405.       ax1.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1406.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1407.                         borderpad=0.15, handletextpad=0.2);
  1408.       frame1 = leg1.get_frame();
  1409.       frame1.set_facecolor("0.80");           # Make legend box have a gray background
  1410.       for t in leg1.get_texts():
  1411.          t.set_fontsize(flegsize);            # Change the font size of the legend text to 10 pt.
  1412.       # end for
  1413.       plt.xticks(fontsize=fsize);
  1414.       plt.yticks(fontsize=fsize);
  1415.  
  1416.       # Middle plot
  1417.       jloop = -1;
  1418.       for item in device_data_list:
  1419.          jloop = jloop + 1;
  1420.  
  1421.          marker = line_list[jloop];
  1422.          ax2 = plt.subplot(312);
  1423.          d22 = item["device"] + " " + d2;
  1424.          plt.plot(x_seconds, item["avgqusz"], marker, label=d22);
  1425.  
  1426.          plt.xlabel(" ");
  1427.          plt.ylabel(ylabel2, fontsize=fsize);
  1428.          ax2.set_xticklabels([]);
  1429.       # end for
  1430.       plt.grid();
  1431.       # Legend:
  1432.       box = ax2.get_position()
  1433.       ax2.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1434.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1435.                         borderpad=0.15, handletextpad=0.2);
  1436.       frame2 = leg2.get_frame();
  1437.       frame2.set_facecolor("0.80");
  1438.       for t in leg2.get_texts():
  1439.          t.set_fontsize(flegsize);
  1440.       # end for
  1441.       plt.xticks(fontsize=fsize);
  1442.       plt.yticks(fontsize=fsize);
  1443.  
  1444.       # Bottom plot
  1445.       ax3 = plt.subplot(313);
  1446.       plt.plot(x_seconds, time_sum_list, "go-", label=d3);
  1447.       plt.grid();
  1448.       plt.xlabel(xlabel);
  1449.       plt.ylabel(ylabel3, fontsize=fsize);
  1450.  
  1451.       # Legend
  1452.       box = ax3.get_position()
  1453.       ax3.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1454.       leg3 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1455.                         borderpad=0.15, handletextpad=0.2);
  1456.       frame3 = leg3.get_frame();
  1457.       frame3.set_facecolor("0.80");
  1458.       for t in leg3.get_texts():
  1459.          t.set_fontsize(flegsize);
  1460.       # end for
  1461.       plt.xticks(fontsize=fsize);
  1462.       plt.yticks(fontsize=fsize);
  1463.  
  1464.       # Either save the plot to a file or display it to the screen
  1465.       if (len(filename) == 0):
  1466.          plt.show();
  1467.       else:
  1468.          plt.savefig(filename);
  1469.          plt.close();
  1470.       # end if
  1471.    # end if
  1472.  
  1473.    # HTML Output:
  1474.    output_str = "<center> \n";
  1475.    junk1 = "requests_queue_total_cpu" + str(iloop) + ".png";
  1476.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  1477.    if (combined_plots == 0):
  1478.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Average Request Size (sectors), Average Queue Length, and Total CPU Utilization Percentage for device: " + item["device"] + "</strong></center><BR><BR> \n";
  1479.    elif (combined_plots == 1):
  1480.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Average Request Size (sectors), Average Queue Length, and Total CPU Utilization Percentage </strong></center><BR><BR> \n";
  1481.    #end if
  1482.    output_str = output_str + "<BR><BR> \n";
  1483.    output_str = output_str + "</P> \n \n";
  1484.    f.write(output_str);
  1485.  
  1486. # end def
  1487.  
  1488.  
  1489. def plot10v10(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  1490.            fsize, item, device_data_list, line_list):
  1491.    #
  1492.    # Figure 10: Average Wait Times for read, write requests
  1493.    # (for V10 format of sysstat)
  1494.    #
  1495.    junk1 = "avg_wait_time_total_cpu" + str(iloop);
  1496.    if (combined_plots == 0):
  1497.       output_str = "<H4> \n"
  1498.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Average Read Request Time (ms), Average Write Request Time (ms), and Total CPU Utilization</a>";
  1499.       output_str = output_str + ". Device: " + item["device"] + " \n";
  1500.       output_str = output_str + "</H4> \n";
  1501.    elif (combined_plots == 1):
  1502.       output_str = "<H3> \n"
  1503.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Average Read Request Time (ms), Average Write Request Time (ms), and Total CPU Utilization</a>";
  1504.       output_str = output_str + "</H3> \n";
  1505.    #end if
  1506.  
  1507.    output_str = output_str + " \n";
  1508.    output_str = output_str + "<P> \n";
  1509.    output_str = output_str + "This figure has three parts. The top graph plots the average \n";
  1510.    output_str = output_str + "time (in milliseconds) for read requests issued to \n";
  1511.    output_str = output_str + "the device to be served. This includes the time spent by the \n";
  1512.    output_str = output_str + "requests in queue and the time spent servicing them. The middle \n";
  1513.    output_str = output_str + "graph plots the average time (in milliseconds) for write \n";
  1514.    output_str = output_str + "requests issued to the device to be  served. This includes \n";
  1515.    output_str = output_str + "the time spent by the requests in queue and the time spent \n";
  1516.    output_str = output_str + "servicing them. The bottom graph plots the Total CPU Utilization \n";
  1517.    output_str = output_str + "percentage (User Time + System Time). \n";
  1518.    f.write(output_str);
  1519.  
  1520.    # make the plot
  1521.    ylabel1 = "Average Read Request \n Time (ms)";
  1522.    ylabel2 = "Average Write Request \n Time (ms)";
  1523.    ylabel3 = "Total CPU \n Percentage \n Utilization";
  1524.    xlabel = "Time (seconds)";
  1525.    d1 = "Avg. Read Req Time";
  1526.    d2 = "Avg. Write Req Time";
  1527.    d3 = "Total CPU Utilization";
  1528.    filename = dirname + "/avg_request_time_total_cpu" + str(iloop);
  1529.    fsize = 8;
  1530.    flegsize = 6;
  1531.  
  1532.    if (combined_plots == 0):
  1533.  
  1534.       # Compute box_expansion factor:
  1535.       box_expansion = 0.86;   # default
  1536.       ilongest = 0;
  1537.       if (len(d1) > ilongest):
  1538.          ilongest = len(d1);
  1539.       # end if
  1540.       if (len(d2) > ilongest):
  1541.          ilongest = len(d2);
  1542.       # end if
  1543.       if (len(d3) > ilongest):
  1544.          ilongest = len(d3);
  1545.       # end if
  1546.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1547.       expansion_box = round(junk1,2);
  1548.  
  1549.       Three_Chart(x_seconds, item["r_await"], x_seconds, item["w_await"], x_seconds, time_sum_list,
  1550.                   xlabel, ylabel1, ylabel2, ylabel3, d1, d2, d3, fsize, flegsize, filename,
  1551.                   box_expansion);
  1552.    elif (combined_plots == 1):
  1553.       jloop = -1;
  1554.  
  1555.        # Compute box_expansion factor:
  1556.       box_expansion = 0.86;   # default
  1557.       ilongest = 0;
  1558.       for item in device_data_list:
  1559.          if (len(d1) > ilongest):
  1560.             ilongest = len(d1);
  1561.          # end if
  1562.          d11 = item["device"] + " " + d1;
  1563.          if (len(d11) > ilongest):
  1564.             ilongest = len(d11);
  1565.          # end if
  1566.          if (len(d2) > ilongest):
  1567.             ilongest = len(d2);
  1568.          # end if
  1569.          d22 = item["device"] + " " + d2;
  1570.          if (len(d22) > ilongest):
  1571.             ilongest = len(d22);
  1572.          # end if
  1573.          if (len(d3) > ilongest):
  1574.             ilongest = len(d3);
  1575.          # end if
  1576.          d33 = item["device"] + " " + d3;
  1577.          if (len(d33) > ilongest):
  1578.             ilongest = len(d33);
  1579.          # end if
  1580.       # end for
  1581.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1582.       expansion_box = round(junk1,2);
  1583.  
  1584.       # Top Plot
  1585.       for item in device_data_list:
  1586.          jloop = jloop + 1;
  1587.  
  1588.          marker = line_list[jloop];
  1589.          ax1 = plt.subplot(311);                 # Define top plot using subplot function
  1590.          d11 = item["device"] + " " + d1;
  1591.          plt.plot(x_seconds, item["r_await"], marker, label=d11);
  1592.          plt.xlabel(" ");                        # Don't put an x-axis label since it's the top plot
  1593.          plt.ylabel(ylabel1, fontsize=fsize);    # Use a 10 pt font for y-axis label
  1594.          ax1.set_xticklabels([]);                # get x-axis tick label
  1595.       # end if
  1596.       plt.grid();
  1597.       # Legend
  1598.       box = ax1.get_position()
  1599.       ax1.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1600.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1601.                         borderpad=0.15, handletextpad=0.2);
  1602.       frame1 = leg1.get_frame();
  1603.       frame1.set_facecolor("0.80");           # Make legend box have a gray background
  1604.       for t in leg1.get_texts():
  1605.          t.set_fontsize(flegsize);            # Change the font size of the legend text to 10 pt.
  1606.       # end for
  1607.       plt.xticks(fontsize=fsize);
  1608.       plt.yticks(fontsize=fsize);
  1609.  
  1610.       # Middle plot
  1611.       jloop = -1;
  1612.       for item in device_data_list:
  1613.          jloop = jloop + 1;
  1614.  
  1615.          marker = line_list[jloop];
  1616.          ax2 = plt.subplot(312);
  1617.          d22 = item["device"] + " " + d2;
  1618.          plt.plot(x_seconds, item["w_await"], marker, label=d22);
  1619.          plt.xlabel(" ");
  1620.          plt.ylabel(ylabel2, fontsize=fsize);
  1621.          ax2.set_xticklabels([]);
  1622.       # end for
  1623.       plt.grid();
  1624.       # Legend:
  1625.       box = ax2.get_position()
  1626.       ax2.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1627.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1628.                         borderpad=0.15, handletextpad=0.2);
  1629.       frame2 = leg2.get_frame();
  1630.       frame2.set_facecolor("0.80");
  1631.       for t in leg2.get_texts():
  1632.          t.set_fontsize(flegsize);
  1633.       # end for
  1634.       plt.xticks(fontsize=fsize);
  1635.       plt.yticks(fontsize=fsize);
  1636.  
  1637.       # Bottom plot
  1638.       ax3 = plt.subplot(313);
  1639.       plt.plot(x_seconds, time_sum_list, "go-", label=d3);
  1640.       plt.grid();
  1641.       plt.xlabel(xlabel);
  1642.       plt.ylabel(ylabel3, fontsize=fsize);
  1643.  
  1644.       # Legend
  1645.       box = ax3.get_position()
  1646.       ax3.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1647.       leg3 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1648.                         borderpad=0.15, handletextpad=0.2);
  1649.       frame3 = leg3.get_frame();
  1650.       frame3.set_facecolor("0.80");
  1651.       for t in leg3.get_texts():
  1652.          t.set_fontsize(flegsize);
  1653.       # end for
  1654.  
  1655.       plt.xticks(fontsize=fsize);
  1656.       plt.yticks(fontsize=fsize);
  1657.  
  1658.       # Either save the plot to a file or display it to the screen
  1659.       if (len(filename) == 0):
  1660.          plt.show();
  1661.       else:
  1662.          plt.savefig(filename);
  1663.          plt.close();
  1664.       # end if
  1665.    #end if
  1666.  
  1667.    # HTML Output:
  1668.    output_str = "<center> \n";
  1669.    junk1 = "avg_request_time_total_cpu" + str(iloop) + ".png";
  1670.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  1671.    if (combined_plots == 0):
  1672.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Average Read Request Time (ms), Average Write Request Time (ms), and Total CPU Utilization for device: " + item["device"] + "</strong></center><BR><BR> \n";
  1673.    elif (combined_plots == 1):
  1674.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Average Read Request Time (ms), Average Write Request Time (ms), and Total CPU Utilization </strong></center><BR><BR> \n";
  1675.    # end if
  1676.    output_str = output_str + "<BR><BR> \n";
  1677.    output_str = output_str + "</P> \n \n";
  1678.    f.write(output_str);
  1679.  
  1680. # end def
  1681.  
  1682.  
  1683.  
  1684. def plot10v9(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  1685.            fsize, item, device_data_list, line_list):
  1686.    #
  1687.    # Figure 10: Average Wait Times for requests and total CPU time
  1688.    # (for V10 format of sysstat)
  1689.    #
  1690.    junk1 = "avg_wait_time_total_cpu" + str(iloop);
  1691.    if (combined_plots == 0):
  1692.       output_str = "<H4> \n"
  1693.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Average Request Time (ms) and Total CPU Utilization</a>";
  1694.       output_str = output_str + ". Device: " + item["device"] + " \n";
  1695.       output_str = output_str + "</H4> \n";
  1696.    elif (combined_plots == 1):
  1697.       output_str = "<H3> \n"
  1698.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Average Request Time (ms) and Total CPU Utilization</a>";
  1699.       output_str = output_str + "</H3> \n";
  1700.    #end if
  1701.  
  1702.    output_str = output_str + " \n";
  1703.    output_str = output_str + "<P> \n";
  1704.    output_str = output_str + "This figure has two parts. The top graph plots the average \n";
  1705.    output_str = output_str + "time (in milliseconds) for requests issued to the device to\n";
  1706.    output_str = output_str + "be served. This includes the time spent by the requests in queue \n";
  1707.    output_str = output_str + "and the time spent servicing them. The bottom graph plots \n";
  1708.    output_str = output_str + "the Total CPU Utilization percentage (User Time + System Time). \n";
  1709.    f.write(output_str);
  1710.  
  1711.    # make the plot
  1712.    ylabel1 = "Average Request \n Time (ms)";
  1713.    ylabel2 = "Total CPU \n Percentage \n Utilization";
  1714.    xlabel = "Time (seconds)";
  1715.    d1 = "Avg. Req Time";
  1716.    d2 = "Total CPU Utilization";
  1717.    filename = dirname + "/avg_request_time_total_cpu" + str(iloop);
  1718.    fsize = 8;
  1719.    flegsize = 6;
  1720.  
  1721.    if (combined_plots == 0):
  1722.  
  1723.       # Compute box_expansion factor:
  1724.       box_expansion = 0.86;   # default
  1725.       ilongest = 0;
  1726.       if (len(d1) > ilongest):
  1727.          ilongest = len(d1);
  1728.       # end if
  1729.       if (len(d2) > ilongest):
  1730.          ilongest = len(d2);
  1731.       # end if
  1732.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1733.       expansion_box = round(junk1,2);
  1734.  
  1735.       Two_Chart(x_seconds, item["await"], x_seconds, time_sum_list, xlabel, ylabel1,
  1736.                 ylabel2, d1, d2, fsize, flegsize, filename, box_expansion);
  1737.    elif (combined_plots == 1):
  1738.       jloop = -1;
  1739.  
  1740.       # Compute box_expansion factor:
  1741.       box_expansion = 0.86;   # default
  1742.       ilongest = 0;
  1743.       for item in device_data_list:
  1744.          if (len(d1) > ilongest):
  1745.             ilongest = len(d1);
  1746.          # end if
  1747.          d11 = item["device"] + " " + d1;
  1748.          if (len(d11) > ilongest):
  1749.             ilongest = len(d11);
  1750.          # end if
  1751.          if (len(d2) > ilongest):
  1752.             ilongest = len(d2);
  1753.          # end if
  1754.          d22 = item["device"] + " " + d2;
  1755.          if (len(d22) > ilongest):
  1756.             ilongest = len(d22);
  1757.          # end if
  1758.       # end for
  1759.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1760.       expansion_box = round(junk1,2);
  1761.  
  1762.       # Top Plot
  1763.       for item in device_data_list:
  1764.          jloop = jloop + 1;
  1765.  
  1766.          marker = line_list[jloop];
  1767.          ax1 = plt.subplot(211);                 # Define top plot using subplot function
  1768.          d11 = item["device"] + " " + d1;
  1769.          plt.plot(x_seconds, item["await"], marker, label=d11);
  1770.          plt.xlabel(" ");                        # Don't put an x-axis label since it's the top plot
  1771.          plt.ylabel(ylabel1, fontsize=fsize);    # Use a 10 pt font for y-axis label
  1772.          ax1.set_xticklabels([]);                # get x-axis tick label
  1773.       # end if
  1774.       plt.grid();
  1775.       # Legend
  1776.       box = ax1.get_position()
  1777.       ax1.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1778.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1779.                         borderpad=0.15, handletextpad=0.2);
  1780.       frame1 = leg1.get_frame();
  1781.       frame1.set_facecolor("0.80");           # Make legend box have a gray background
  1782.       for t in leg1.get_texts():
  1783.          t.set_fontsize(flegsize);            # Change the font size of the legend text to 10 pt.
  1784.       # end for
  1785.       plt.xticks(fontsize=fsize);
  1786.       plt.yticks(fontsize=fsize);
  1787.  
  1788.       # Bottom plot
  1789.       ax2 = plt.subplot(212);
  1790.       plt.plot(x_seconds, time_sum_list, "go-", label=d2);
  1791.       plt.grid();
  1792.       plt.xlabel(xlabel);
  1793.       plt.ylabel(ylabel2, fontsize=fsize);
  1794.  
  1795.       # Legend
  1796.       box = ax2.get_position()
  1797.       ax2.set_position([box.x0, box.y0, box.width * expansion_box, box.height])
  1798.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1799.                         borderpad=0.15, handletextpad=0.2);
  1800.       frame2 = leg2.get_frame();
  1801.       frame2.set_facecolor("0.80");
  1802.       for t in leg2.get_texts():
  1803.          t.set_fontsize(flegsize);
  1804.       # end for
  1805.  
  1806.       plt.xticks(fontsize=fsize);
  1807.       plt.yticks(fontsize=fsize);
  1808.  
  1809.       # Either save the plot to a file or display it to the screen
  1810.       if (len(filename) == 0):
  1811.          plt.show();
  1812.       else:
  1813.          plt.savefig(filename);
  1814.          plt.close();
  1815.       # end if
  1816.    #end if
  1817.  
  1818.    # HTML Output:
  1819.    output_str = "<center> \n";
  1820.    junk1 = "avg_request_time_total_cpu" + str(iloop) + ".png";
  1821.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  1822.    if (combined_plots == 0):
  1823.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Average Request Time (ms) and Total CPU Utilization for device: " + item["device"] + "</strong></center><BR><BR> \n";
  1824.    elif (combined_plots == 1):
  1825.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Average Request Time (ms) and Total CPU Utilization </strong></center><BR><BR> \n";
  1826.    # end if
  1827.    output_str = output_str + "<BR><BR> \n";
  1828.    output_str = output_str + "</P> \n \n";
  1829.    f.write(output_str);
  1830.  
  1831. # end def
  1832.  
  1833.  
  1834.  
  1835. def plot11(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  1836.           fsize, item, device_data_list, line_list):
  1837.    #
  1838.    # Figure 11: Percentage CPU Util
  1839.    #
  1840.    junk1 = "util_cpu_total_cpu" + str(iloop);
  1841.    if (combined_plots == 0):
  1842.       output_str = "<H4> \n"
  1843.       junk1 = "util_cpu_total_cpu" + str(iloop);
  1844.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Percentage CPU Time for IO Requests and Total CPU Utilization</a>";
  1845.       output_str = output_str + ". Device: " + item["device"] + " \n";
  1846.       output_str = output_str + "</H4> \n";
  1847.    elif (combined_plots == 1):
  1848.       output_str = "<H3> \n"
  1849.       junk1 = "util_cpu_total_cpu" + str(iloop);
  1850.       output_str = output_str + str(iplot) + ". <a id=\"" + junk1 + "\">Percentage CPU Time for IO Requests and Total CPU Utilization</a>";
  1851.       output_str = output_str + "</H3> \n";
  1852.    # end if
  1853.    output_str = output_str + " \n";
  1854.    output_str = output_str + "<P> \n";
  1855.    output_str = output_str + "This figure has two parts. The top graph plots the \n";
  1856.    output_str = output_str + "percentage of CPU time during which I/O requests were issued \n";
  1857.    output_str = output_str + "to the device (bandwidth utilization for the device). \n";
  1858.    output_str = output_str + "Device saturation occurs when this value is close to 100%. \n";
  1859.    output_str = output_str + "The bottom graph plots the Total CPU Utilization percentage \n";
  1860.    output_str = output_str + "(User Time + System Time). \n";
  1861.    f.write(output_str);
  1862.  
  1863.    # make the plot
  1864.    ylabel1 = "% CPU time for IO \n Requests";
  1865.    ylabel2 = "Total CPU \n Percentage \n Utilization";
  1866.    xlabel = "Time (seconds)";
  1867.    d1 = "Util";
  1868.    d2 = "Total CPU Utilization";
  1869.    filename = dirname + "/util_cpu_total_cp" + str(iloop);
  1870.    fsize = 8;
  1871.    flegsize = 6;
  1872.  
  1873.    if (combined_plots == 0):
  1874.  
  1875.       # Compute box_expansion factor:
  1876.       box_expansion = 0.82;   # default
  1877.       ilongest = 0;
  1878.       if (len(d1) > ilongest):
  1879.          ilongest = len(d1);
  1880.       # end if
  1881.       if (len(d2) > ilongest):
  1882.          ilongest = len(d2);
  1883.       # end if
  1884.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1885.       expansion_box = round(junk1,2);
  1886.  
  1887.       Two_Chart(x_seconds, item["util"], x_seconds, time_sum_list, xlabel, ylabel1,
  1888.                 ylabel2, d1, d2, fsize, flegsize, filename, box_expansion);
  1889.    elif (combined_plots == 1):
  1890.       jloop = -1;
  1891.  
  1892.       # Compute box_expansion factor:
  1893.       box_expansion = 0.90;   # default
  1894.       ilongest = 0;
  1895.       for item in device_data_list:
  1896.          if (len(d1) > ilongest):
  1897.             ilongest = len(d1);
  1898.          # end if
  1899.          d11 = item["device"] + " " + d1;
  1900.          if (len(d11) > ilongest):
  1901.             ilongest = len(d11);
  1902.          # end if
  1903.          if (len(d2) > ilongest):
  1904.             ilongest = len(d2);
  1905.          # end if
  1906.          d22 = item["device"] + " " + d2;
  1907.          if (len(d22) > ilongest):
  1908.             ilongest = len(d22);
  1909.          # end if
  1910.       # end for
  1911.       junk1 = -0.0082702674*ilongest + 1.0538027948;   # Curve fit of # chars vs. expansion box
  1912.       expansion_box = round(junk1,2);
  1913.  
  1914.       # Top plot
  1915.       for item in device_data_list:
  1916.          jloop = jloop + 1;
  1917.  
  1918.          marker = line_list[jloop];
  1919.          ax1 = plt.subplot(211);
  1920.          d11 = item["device"] + " " + d1;
  1921.          plt.plot(x_seconds, item["util"], marker, label=d11);
  1922.          plt.xlabel(" ");
  1923.          plt.ylabel(ylabel1, fontsize=fsize);
  1924.          ax1.set_xticklabels([]);
  1925.       # end for
  1926.       plt.grid();
  1927.       # Legend
  1928.       box = ax1.get_position();
  1929.       ax1.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  1930.       leg1 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1931.                         borderpad=0.15, handletextpad=0.2);
  1932.       frame1 = leg1.get_frame();
  1933.       frame1.set_facecolor("0.80");
  1934.       for t in leg1.get_texts():
  1935.          t.set_fontsize(flegsize);
  1936.       # end for
  1937.  
  1938.       # Bottom Plot
  1939.       ax2 = plt.subplot(212);
  1940.       plt.plot(x_seconds, time_sum_list, "go-", label=d2);
  1941.       plt.grid();
  1942.       plt.xlabel(xlabel);
  1943.       plt.ylabel(ylabel2, fontsize=fsize);
  1944.  
  1945.       # Legend
  1946.       box = ax2.get_position()
  1947.       ax2.set_position([box.x0, box.y0, box.width * box_expansion, box.height])
  1948.       leg2 = plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., labelspacing=0,
  1949.                         borderpad=0.15, handletextpad=0.2);
  1950.       frame2 = leg2.get_frame();
  1951.       frame2.set_facecolor("0.80");
  1952.       for t in leg2.get_texts():
  1953.          t.set_fontsize(flegsize);
  1954.       # end for
  1955.  
  1956.       if (len(filename) == 0):
  1957.          plt.show();
  1958.       else:
  1959.          plt.savefig(filename);
  1960.          plt.close();
  1961.       # end if
  1962.    #end if
  1963.  
  1964.    # HTML Output:
  1965.    output_str = "<center> \n";
  1966.    junk1 = "util_cpu_total_cp" + str(iloop) + ".png";
  1967.    output_str = output_str + "<img src=\"" + junk1 + "\"> \n";
  1968.    if (combined_plots == 0):
  1969.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time for IO Requests and Total CPU Utilization for device: " + item["device"] + "</strong></center><BR><BR> \n";
  1970.    elif (combined_plots == 1):
  1971.       output_str = output_str + "<BR><BR><strong>Figure " + str(iplot) + " - Percentage CPU Time for IO Requests and Total CPU Utilization </strong></center><BR><BR> \n";
  1972.    # end if
  1973.    output_str = output_str + "<BR><BR> \n";
  1974.    output_str = output_str + "</P> \n \n";
  1975.    f.write(output_str);
  1976.  
  1977. # end if
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985. # ===================
  1986. # Main Python section
  1987. # ===================
  1988.  
  1989. if __name__ == '__main__':
  1990.  
  1991.    # Get the command line inputs
  1992.    input_options = sys.argv;
  1993.    combined_plots = 0;
  1994.    help_flag = 0;
  1995.    for item in input_options:
  1996.       if (item == "-c"):
  1997.          combined_plots = 1;
  1998.       elif (item == "-h"):
  1999.          help_flag = 1;
  2000.       # end if
  2001.    # end for
  2002.    input_filename = input_options[-1];
  2003.  
  2004.    if (help_flag == 1):
  2005.       help_out();
  2006.       sys.exit();
  2007.    # end if
  2008.    print "combined_plots = ",combined_plots;
  2009.  
  2010.    print "iostat plotting script";
  2011.    print " ";
  2012.    print "input filename: ",input_filename;
  2013.  
  2014.    # Initialize lists that will store data
  2015.    user_list = [];
  2016.    nice_list = [];
  2017.    system_list = [];
  2018.    iowait_list = [];
  2019.    steal_list = [];
  2020.    idle_list = [];
  2021.    date_list = [];
  2022.    time_list = [];
  2023.    meridian_list = [];
  2024.  
  2025.    # Initialize variables
  2026.    fsize = 8;
  2027.    vflag = 0;
  2028.    first_flag = 0;
  2029.  
  2030.    # Master dictionary of device data
  2031.    device_data_list = [];
  2032.    # Systat V 10 List element is dictionary:
  2033.    #   local_dict{"device"} = "device name"
  2034.    #   local_dict{"rrqm"} = [];
  2035.    #   local_dict{"wrqm"} = [];
  2036.    #   local_dict{"r"} = [];
  2037.    #   local_dict{"w"} = [];
  2038.    #   local_dict{"rMB"} = [];
  2039.    #   local_dict{"wMB"} = [];
  2040.    #   local_dict{"avgrqsz"} = [];
  2041.    #   local_dict{"avgqusz"} = [];
  2042.    #   local_dict{"await"} = [];
  2043.    #   local_dict{"r_await"} = [];
  2044.    #   local_dict{"w_await"} = [];
  2045.    #   local_dict{"svctm"} = [];
  2046.    #   local_dict{"util"} = [];
  2047.    # Systat V 9 List element is dictionary:
  2048.    #   local_dict{"device"} = "device name"
  2049.    #   local_dict{"rrqm"} = [];
  2050.    #   local_dict{"wrqm"} = [];
  2051.    #   local_dict{"r"} = [];
  2052.    #   local_dict{"w"} = [];
  2053.    #   local_dict{"rMB"} = [];
  2054.    #   local_dict{"wMB"} = [];
  2055.    #   local_dict{"avgrqsz"} = [];
  2056.    #   local_dict{"avgqusz"} = [];
  2057.    #   local_dict{"await"} = [];
  2058.    #   local_dict{"svctm"} = [];
  2059.    #   local_dict{"util"} = [];
  2060.  
  2061.    # flags for controlling flow
  2062.    info_flag = 1;       # 0 = don't gather system data, 1 = gather system data
  2063.    cpu_flag = -1;       # -1 = don't do anything, 0 = store CPU header info (only done once), 1 = Store CPU info
  2064.    device_flag = -1;    # -1 = store Device header info (only done once), 1 = store values, 2 = done
  2065.    data_flag = 0;       # -1 = cpu, 1 = device (which set of data is being gathered)
  2066.    time_flag = -1;      # -1 = don't read start time information, 1 = read start time information
  2067.  
  2068.    # loop over lines in input file
  2069.    print " ";
  2070.    print "reading iostat output file ... ";
  2071.    icount = 0;
  2072.    for line in open(input_filename,'r').readlines():
  2073.       currentline = shlex.split(line);
  2074.  
  2075.       if (len(currentline) > 0):
  2076.          if (device_flag == 0):
  2077.             #print "   Read device header";
  2078.             device_labels = [];
  2079.             device_labels = currentline;
  2080.             device_flag = 1;
  2081.          elif (device_flag == 1):
  2082.             #print "   Read device data";
  2083.             local_device = currentline[0];
  2084.             #print "      local_device = ",local_device
  2085.             if (len(device_data_list) > 0):
  2086.                ifind = 0;
  2087.                for iloop in range(0, len(device_data_list) ):
  2088.                   item = device_data_list[iloop];
  2089.                   #for item in device_data_list:
  2090.                   if (item["device"] == local_device):
  2091.                      #print "         adding data to existing device: ";
  2092.                      if (vflag == 9):
  2093.                         device_data_list[iloop]["rrqm"].append(float(currentline[1]));
  2094.                         device_data_list[iloop]["wrqm"].append(float(currentline[2]));
  2095.                         device_data_list[iloop]["r"].append(float(currentline[3]));
  2096.                         device_data_list[iloop]["w"].append(float(currentline[4]));
  2097.                         device_data_list[iloop]["rMB"].append(float(currentline[5]));
  2098.                         device_data_list[iloop]["wMB"].append(float(currentline[6]));
  2099.                         device_data_list[iloop]["avgrqsz"].append(float(currentline[7]));
  2100.                         device_data_list[iloop]["avgqusz"].append(float(currentline[8]));
  2101.                         device_data_list[iloop]["await"].append(float(currentline[9]));
  2102.                         device_data_list[iloop]["svctm"].append(float(currentline[10]));
  2103.                         device_data_list[iloop]["util"].append(float(currentline[11]));
  2104.                      elif (vflag == 10):
  2105.                         device_data_list[iloop]["rrqm"].append(float(currentline[1]));
  2106.                         device_data_list[iloop]["wrqm"].append(float(currentline[2]));
  2107.                         device_data_list[iloop]["r"].append(float(currentline[3]));
  2108.                         device_data_list[iloop]["w"].append(float(currentline[4]));
  2109.                         device_data_list[iloop]["rMB"].append(float(currentline[5]));
  2110.                         device_data_list[iloop]["wMB"].append(float(currentline[6]));
  2111.                         device_data_list[iloop]["avgrqsz"].append(float(currentline[7]));
  2112.                         device_data_list[iloop]["avgqusz"].append(float(currentline[8]));
  2113.                         device_data_list[iloop]["await"].append(float(currentline[9]));
  2114.                         device_data_list[iloop]["r_await"].append(float(currentline[10]));
  2115.                         device_data_list[iloop]["w_await"].append(float(currentline[11]));
  2116.                         device_data_list[iloop]["svctm"].append(float(currentline[12]));
  2117.                         device_data_list[iloop]["util"].append(float(currentline[13]));
  2118.                      #end if
  2119.                      ifind = 1;
  2120.                   # end if
  2121.                # end for
  2122.                if (ifind == 0):
  2123.                   #print "         creating new device ifind == 0";
  2124.                   if (first_flag == 0):
  2125.                      if (len(currentline) == 12):
  2126.                         vflag = 9;
  2127.                         print "Using Version 9 format of sysstat tools";
  2128.                      elif (len(currentline) == 14):
  2129.                         vflag = 10;
  2130.                         print "Using Version 10 format of sysstat tools";
  2131.                      else:
  2132.                         print "Error: each line has ",len(currentline)," elements"
  2133.                         print "This code is designed for 12 elemenets for sysstat V9";
  2134.                         print "or 14 elements for sysstat V10";
  2135.                         print "Stopping";
  2136.                         sys.exit();
  2137.                      # end if
  2138.                      first_flag = 1;
  2139.                   # end if
  2140.                   local_dict = {};
  2141.                   if (vflag == 9):
  2142.                      local_dict["device"] = local_device;
  2143.                      local_dict["rrqm"]=[float(currentline[1])];
  2144.                      local_dict["wrqm"]=[float(currentline[2])];
  2145.                      local_dict["r"]=[float(currentline[3])];
  2146.                      local_dict["w"]=[float(currentline[4])];
  2147.                      local_dict["rMB"]=[float(currentline[5])];
  2148.                      local_dict["wMB"]=[float(currentline[6])];
  2149.                      local_dict["avgrqsz"]=[float(currentline[7])];
  2150.                      local_dict["avgqusz"]=[float(currentline[8])];
  2151.                      local_dict["await"]=[float(currentline[9])];
  2152.                      local_dict["svctm"]=[float(currentline[10])];
  2153.                      local_dict["util"]=[float(currentline[11])];
  2154.                      #print "      local_dict = ",local_dict
  2155.                      device_data_list.append(local_dict);
  2156.                   elif (vflag == 10):
  2157.                      local_dict["device"] = local_device;
  2158.                      local_dict["rrqm"]=[float(currentline[1])];
  2159.                      local_dict["wrqm"]=[float(currentline[2])];
  2160.                      local_dict["r"]=[float(currentline[3])];
  2161.                      local_dict["w"]=[float(currentline[4])];
  2162.                      local_dict["rMB"]=[float(currentline[5])];
  2163.                      local_dict["wMB"]=[float(currentline[6])];
  2164.                      local_dict["avgrqsz"]=[float(currentline[7])];
  2165.                      local_dict["avgqusz"]=[float(currentline[8])];
  2166.                      local_dict["await"]=[float(currentline[9])];
  2167.                      local_dict["r_await"]=[float(currentline[10])];
  2168.                      local_dict["w_await"]=[float(currentline[11])];
  2169.                      local_dict["svctm"]=[float(currentline[12])];
  2170.                      local_dict["util"]=[float(currentline[13])];
  2171.                      #print "      local_dict = ",local_dict
  2172.                      device_data_list.append(local_dict);
  2173.                   # end if
  2174.                # end if
  2175.             else:
  2176.                #print "         creating new device else";
  2177.                if (first_flag == 0):
  2178.                   if (len(currentline) == 12):
  2179.                      vflag = 9;
  2180.                      print "Using Version 9 format of sysstat tools";
  2181.                   elif (len(currentline) == 14):
  2182.                      vflag = 10;
  2183.                      print "Using Version 10 format of sysstat tools";
  2184.                   else:
  2185.                      print "Error: each line has ",len(currentline)," elements"
  2186.                      print "This code is designed for 12 elemenets for sysstat V9";
  2187.                      print "or 14 elements for sysstat V10";
  2188.                      print "Stopping";
  2189.                      sys.exit();
  2190.                   # end if
  2191.                   first_flag = 1;
  2192.                # end if
  2193.                local_dict = {};
  2194.                if (vflag == 9):
  2195.                   local_dict["device"] = local_device;
  2196.                   local_dict["rrqm"]=[float(currentline[1])];
  2197.                   local_dict["wrqm"]=[float(currentline[2])];
  2198.                   local_dict["r"]=[float(currentline[3])];
  2199.                   local_dict["w"]=[float(currentline[4])];
  2200.                   local_dict["rMB"]=[float(currentline[5])];
  2201.                   local_dict["wMB"]=[float(currentline[6])];
  2202.                   local_dict["avgrqsz"]=[float(currentline[7])];
  2203.                   local_dict["avgqusz"]=[float(currentline[8])];
  2204.                   local_dict["await"]=[float(currentline[9])];
  2205.                   local_dict["svctm"]=[float(currentline[10])];
  2206.                   local_dict["util"]=[float(currentline[11])];
  2207.                   device_data_list.append(local_dict);
  2208.                elif (vflag == 10):
  2209.                   local_dict["device"] = local_device;
  2210.                   local_dict["rrqm"]=[float(currentline[1])];
  2211.                   local_dict["wrqm"]=[float(currentline[2])];
  2212.                   local_dict["r"]=[float(currentline[3])];
  2213.                   local_dict["w"]=[float(currentline[4])];
  2214.                   local_dict["rMB"]=[float(currentline[5])];
  2215.                   local_dict["wMB"]=[float(currentline[6])];
  2216.                   local_dict["avgrqsz"]=[float(currentline[7])];
  2217.                   local_dict["avgqusz"]=[float(currentline[8])];
  2218.                   local_dict["await"]=[float(currentline[9])];
  2219.                   local_dict["r_await"]=[float(currentline[10])];
  2220.                   local_dict["w_await"]=[float(currentline[11])];
  2221.                   local_dict["svctm"]=[float(currentline[12])];
  2222.                   local_dict["util"]=[float(currentline[13])];
  2223.                   device_data_list.append(local_dict);
  2224.                # end if
  2225.                #print "      local_dict = ",local_dict
  2226.             # end if
  2227.  
  2228.          elif (cpu_flag == 1):
  2229.             #print "   Reading and Storing CPU values";
  2230.             user_list.append(float(currentline[0]));
  2231.             nice_list.append(float(currentline[1]));
  2232.             system_list.append(float(currentline[2]));
  2233.             iowait_list.append(float(currentline[3]));
  2234.             steal_list.append(float(currentline[4]));
  2235.             idle_list.append(float(currentline[5]));
  2236.             #print "      user_list = ",user_list
  2237.             #print "      nice_list = ",nice_list
  2238.             #print "      system_list = ",system_list
  2239.             #print "      iowait_list = ",iowait_list
  2240.             #print "      steal_list = ",steal_list
  2241.             #print "      idle_list = ",idle_list
  2242.             cpu_flag = -1;
  2243.             device_flag = 0;
  2244.          elif (cpu_flag == 0):
  2245.             #print "      Reading and storing CPU headers";
  2246.             cpu_labels = [];
  2247.             cpu_labels = currentline;
  2248.         cpu_flag = 1;
  2249.             #print "      cpu_labels = ",cpu_labels
  2250.          elif (time_flag == 1):
  2251.             #print "   Read time information";
  2252.             date_list.append(currentline[0].replace("/"," "));
  2253.             # if meridian is PM then need to add 12 hours to time_list
  2254.             if (currentline[2] == "PM"):
  2255.                junk1 = currentline[1].replace(":"," ");
  2256.                junk2 = shlex.split(junk1);
  2257.                if ( int(junk2[0]) < 12):
  2258.                   junk3 = int(junk2[0]) + 12;
  2259.                elif (int(junk2[0]) == 12):
  2260.                   junk3 = int(junk2[0]);
  2261.                # end if
  2262.                junk4 = str(junk3) + ":" + junk2[1] + ":" + junk2[2];
  2263.                time_list.append(junk4);
  2264.             else:
  2265.                time_list.append(currentline[1]);
  2266.             # end if
  2267.             #print "      date_list = ",date_list
  2268.             #print "      time_list = ",time_list
  2269.             meridian_list.append(currentline[2]);
  2270.             time_flag = -1;
  2271.             cpu_flag = 0;
  2272.             icount = icount + 1;
  2273.          elif (info_flag == 1):
  2274.             #print "   Read system information";
  2275.             system_info = {};
  2276.             system_info["OS"] = currentline[0];
  2277.             system_info["kernel"] = currentline[1];
  2278.             system_info["system_name"] = currentline[2][1:len(currentline[2])-1];
  2279.             system_info["date"] = currentline[3];
  2280.             system_info["CPU"] = currentline[4];
  2281.             system_info["cores"] = currentline[5][1:];
  2282.             info_flag = 0;
  2283.             time_flag = 1;
  2284.             #print "   system_info:",system_info
  2285.          # end if
  2286.       else:
  2287.          #print "Finished reading section - get ready for next section";
  2288.          if (device_flag == 1):
  2289.             device_flag = -1;
  2290.             time_flag = 1;
  2291.             cpu_flag = -1;
  2292.             info_flag = 0;
  2293.          # end if
  2294.       # end if
  2295.    # end for
  2296.    print "Finished reading ",icount," data points for ",len(device_data_list)," devices.";
  2297.    print "Creating plots and HTML report";
  2298.  
  2299.    # Create time list for x-axis data (need to convert to regular time format)
  2300.    x_seconds = [];
  2301.    for i in range(0,len(date_list)):
  2302.       test2 = shlex.split(date_list[i]);
  2303.       test3 = test2[2] + "-" + test2[0] + "-" + test2[1];
  2304.  
  2305.       junk1 = test3 + " " + time_list[i];
  2306.       ts = time.mktime(time.strptime(junk1, '%Y-%m-%d %H:%M:%S'));
  2307.       if (i == 0):
  2308.          BeginTime = ts;
  2309.          x_seconds.append(0.0);
  2310.       else:
  2311.          x_seconds.append( (ts - BeginTime) );
  2312.       # end if
  2313.    # end of
  2314.  
  2315.    # "Total" CPU utilziation (user + system)
  2316.    time_sum_list = [];
  2317.    for i in range(0,len(user_list)):
  2318.        time_sum_list.append( (user_list[i] + system_list[i]) );
  2319.    # end for
  2320.  
  2321.    #
  2322.    # HTML Report initialization
  2323.    #    Write all data files to subdirectory called HTML_REPORT
  2324.    #    File is report.html
  2325.    dirname ="./HTML_REPORT";
  2326.    if not os.path.exists(dirname):
  2327.       os.makedirs(dirname);
  2328.    # end if
  2329.    html_filename = dirname + '/report.html';
  2330.    f = open(html_filename, 'w')
  2331.  
  2332.    # Print HTML Report header
  2333.    output_str = "<H2>\n";
  2334.    output_str = output_str + "IOSTAT Report for file: " + input_filename + " \n";
  2335.    output_str = output_str + "</H2>\n";
  2336.    output_str = output_str + " \n";
  2337.  
  2338.    # HTML Introduction
  2339.    output_str = "<H3>\n";
  2340.    output_str = output_str + "Introduction \n";
  2341.    output_str = output_str + "</H3> \n \n";
  2342.    output_str = output_str + "<P>\n";
  2343.    output_str = output_str + "This report plots the iostat output contained in file: \n";
  2344.    output_str = output_str + input_filename + ". The devices analyzed are: \n";
  2345.    output_str = output_str + "<UL> \n";
  2346.    for item in device_data_list:
  2347.       output_str = output_str + "   <LI>" + item["device"] + " \n";
  2348.    # end if
  2349.    if (combined_plots == 0):
  2350.       output_str = output_str + "</UL> \n";
  2351.       output_str = output_str + "For each devices there are a series of plots of the output \n";
  2352.       output_str = output_str + "from iostat that was captured. The report is contained in a\n";
  2353.       output_str = output_str + "subdirectory HTML_REPORT. In that directory you will find a \n";
  2354.       output_str = output_str + "file name report.html. Just open that file in a browser \n";
  2355.       output_str = output_str + "and you will see the plots. Please note that all plots are \n";
  2356.       output_str = output_str + "referenced to the beginning time of the iostat run. \n";
  2357.       output_str = output_str + "</P>\n";
  2358.       output_str = output_str + " \n";
  2359.       f.write(output_str);
  2360.    elif(combined_plots == 1):
  2361.       output_str = output_str + "</UL> \n";
  2362.       output_str = output_str + "There are a series of plots from the captured iostat output \n";
  2363.       output_str = output_str + "where all devices are plotted together where possible. \n";
  2364.       output_str = output_str + "The report is contained in a\n";
  2365.       output_str = output_str + "subdirectory HTML_REPORT. In that directory you will find a \n";
  2366.       output_str = output_str + "file name report.html. Just open that file in a browser \n";
  2367.       output_str = output_str + "and you will see the plots. Please note that all plots are \n";
  2368.       output_str = output_str + "referenced to the beginning time of the iostat run. \n";
  2369.       output_str = output_str + "</P>\n";
  2370.       output_str = output_str + " \n";
  2371.       f.write(output_str);
  2372.    # end if
  2373.  
  2374.    # HTML System Output (from iostat):
  2375.    output_str = "<P> \n";
  2376.    output_str = output_str + "IOstat outputs a number of basic system parameters when it \n";
  2377.    output_str = output_str + "creates the output. These parameters are listed below. \n";
  2378.    output_str = output_str + "<UL> \n";
  2379.    output_str = output_str + "   <LI>System Name: " + system_info["system_name"] + " \n";
  2380.    output_str = output_str + "   <LI>OS: " + system_info["OS"] + " \n";
  2381.    output_str = output_str + "   <LI>Kernel: " + system_info["kernel"] + " \n";
  2382.    output_str = output_str + "   <LI>Number of Cores " + system_info["cores"] + " \n";
  2383.    output_str = output_str + "   <LI>Core Type " + system_info["CPU"] + " \n";
  2384.    output_str = output_str + "</UL> \n";
  2385.    output_str = output_str + "The iostat run was started on " + system_info["date"] + " at \n";
  2386.    output_str = output_str + time_list[0] + " " + meridian_list[0] + ". \n";
  2387.    output_str = output_str + "</P> \n";
  2388.    f.write(output_str);
  2389.  
  2390.    # HTML hyperlinks
  2391.    if (combined_plots == 0):
  2392.       output_str = "<P> \n";
  2393.       output_str = output_str + "Below are hyperlinks to various plots within the report \n";
  2394.       output_str = output_str + "for each device. \n";
  2395.       output_str = output_str + "<BR><BR> \n";
  2396.       f.write(output_str);
  2397.    elif (combined_plots == 1):
  2398.       output_str = "<P> \n";
  2399.       output_str = output_str + "Below are hyperlinks to various plots within the report \n";
  2400.       output_str = output_str + "where all of the devices are plotted together on each chart. \n";
  2401.       output_str = output_str + "<BR><BR> \n";
  2402.       f.write(output_str);
  2403.    # end if
  2404.    iloop = -1;
  2405.    plots_per_device = 11;
  2406.    if (combined_plots == 0):
  2407.       max_plots = plots_per_device * len(device_data_list);
  2408.    elif (combined_plots == 1):
  2409.       max_plots = plots_per_device;
  2410.    #end if
  2411.    if (combined_plots == 0):
  2412.       for item in device_data_list:
  2413.          iloop = iloop + 1;
  2414.          output_str = "<strong>" + item["device"] + "</strong>: \n";
  2415.          junk1 = (iloop)*plots_per_device+1;
  2416.          output_str = output_str + "<OL start=" + str(junk1) + "> \n";
  2417.          junk1 = "cpu_utilization" + str(iloop);
  2418.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">CPU Utilization</a> \n";
  2419.          junk1 = "iowait_cpu_utilization" + str(iloop);
  2420.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">IOwait Percentage Time</a> \n";
  2421.          junk1 = "steal_cpu_utilization" + str(iloop);
  2422.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Steal Percentage Time</a> \n";
  2423.          junk1 = "idle_cpu_utilization" + str(iloop);
  2424.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Idle Percentage Time</a> \n";
  2425.          junk1 = "rmb_total_cpu" + str(iloop);
  2426.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Read Throughput and Total CPU Utilization</a> \n";
  2427.          junk1 = "wmb_total_cpu" + str(iloop);
  2428.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Write Throughput and Total CPU Utilization</a> \n";
  2429.          junk1 = "requests_complete_total_cpu" + str(iloop);
  2430.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Read Requests Complete Rate, Write Requests Complete Rate, and Total CPU Utilization</a> \n";
  2431.          junk1 = "requests_merged_total_cpu" + str(iloop);
  2432.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Read Requests Merged Rate, Write Requests Merged Rate, and Total CPU Utilization</a> \n";
  2433.          junk1 = "requests_queue_total_cpu" + str(iloop);
  2434.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Average Request Size, Average Queue Length, and Total CPU Utilization Percentage</a> \n";
  2435.          junk1 = "avg_wait_time_total_cpu" + str(iloop);
  2436.          if (vflag == 10):
  2437.             output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Average Read Request Time, Average Write Request Time, and Total CPU Utilization</a> \n";
  2438.          elif (vflag == 9):
  2439.             output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Average Request Time and Total CPU Utilization</a> \n";
  2440.          # end if
  2441.          junk1 = "util_cpu_total_cpu" + str(iloop);
  2442.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Percentage CPU Time for IO Requests and Total CPU Utilization</a> \n";
  2443.          output_str = output_str + "</OL> \n";
  2444.          output_str = output_str + "</P> \n";
  2445.          output_str = output_str + " \n";
  2446.          f.write(output_str);
  2447.       # end if
  2448.    elif (combined_plots == 1):
  2449.       iloop = 0;
  2450.       iloop = iloop + 1;
  2451.       output_str = "<OL start=" + str(iloop) + "> \n";
  2452.       junk1 = "cpu_utilization" + str(iloop);
  2453.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">CPU Utilization</a> \n";
  2454.       junk1 = "iowait_cpu_utilization" + str(iloop);
  2455.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">IOwait Percentage Time</a> \n";
  2456.       junk1 = "steal_cpu_utilization" + str(iloop);
  2457.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Steal Percentage Time</a> \n";
  2458.       junk1 = "idle_cpu_utilization" + str(iloop);
  2459.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Idle Percentage Time</a> \n";
  2460.       junk1 = "rmb_total_cpu" + str(iloop);
  2461.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Read Throughput and Total CPU Utilization</a> \n";
  2462.       junk1 = "wmb_total_cpu" + str(iloop);
  2463.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Write Throughput and Total CPU Utilization</a> \n";
  2464.       junk1 = "requests_complete_total_cpu" + str(iloop);
  2465.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Read Requests Complete Rate, Write Requests Complete Rate, and Total CPU Utilization</a> \n";
  2466.       junk1 = "requests_merged_total_cpu" + str(iloop);
  2467.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Read Requests Merged Rate, Write Requests Merged Rate, and Total CPU Utilization</a> \n";
  2468.       junk1 = "requests_queue_total_cpu" + str(iloop);
  2469.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Average Request Size, Average Queue Length, and Total CPU Utilization Percentage</a> \n";
  2470.       junk1 = "avg_wait_time_total_cpu" + str(iloop);
  2471.       if (vflag == 10):
  2472.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Average Read Request Time, Average Write Request Time, and Total CPU Utilization</a> \n";
  2473.       elif (vflag == 9):
  2474.          output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Average Request Time and Total CPU Utilization</a> \n";
  2475.       # end if
  2476.       junk1 = "util_cpu_total_cpu" + str(iloop);
  2477.       output_str = output_str + "   <LI><a href=\"#" + junk1 + "\">Percentage CPU Time for IO Requests and Total CPU Utilization</a> \n";
  2478.       output_str = output_str + "</OL> \n";
  2479.       output_str = output_str + "</P> \n";
  2480.       output_str = output_str + " \n";
  2481.       f.write(output_str);
  2482.    #endif
  2483.  
  2484.    # Create array of line colors/styles:
  2485.    # http://matplotlib.org/api/artist_api.html#matplotlib.lines.Line2D.lineStyles
  2486.    # line_style = ['-', '--', '-.'];
  2487.    # line_marker  = ['o', '^', 's', '*', '+', '<', '>', 'v'];
  2488.    color_list = ['b', 'g', 'r', 'c', 'm', 'y', 'k'];
  2489.    line_style = ['o-', '^--', 's-.', '*-', '<--', '>-.', 'v-', 'o--'];
  2490.    line_list = [];
  2491.    for line_type in line_style:
  2492.       for color in color_list:
  2493.          junk2 = color + line_type;
  2494.          line_list.append(junk2);
  2495.       # end for
  2496.    # end for
  2497.  
  2498.    #
  2499.    # Actually create the plots!!
  2500.    #
  2501.    if (combined_plots == 0):
  2502.       # Loop over each device and create plots and HTML:
  2503.       iloop = -1;
  2504.       iplot = 0;
  2505.       for item in device_data_list:
  2506.          iloop = iloop + 1;
  2507.  
  2508.          print "Device: ",item["device"];
  2509.          output_str = "<HR> \n";
  2510.          f.write(output_str);
  2511.  
  2512.          output_str = "<H3>Device: " + item["device"] + "</H3> \n";
  2513.          f.write(output_str);
  2514.  
  2515.          # Figure 1: Various CPU percentages (user, system, nice) vs. time (3 subplots)
  2516.          iplot = iplot + 1;
  2517.          plot1(iloop, iplot, combined_plots, f, dirname, x_seconds, user_list, system_list,
  2518.                nice_list, fsize, item);
  2519.          print "   Finished Plot ",iplot," of ",max_plots;
  2520.  
  2521.          # Figure 2: iowait percentage time
  2522.          iplot = iplot + 1;
  2523.          fsize = 6;
  2524.          plot2(iloop, iplot, combined_plots, f, dirname, x_seconds, iowait_list,
  2525.                fsize, item);
  2526.          print "   Finished Plot ",iplot," of ",max_plots;
  2527.  
  2528.          # Figure 3: Steal Time
  2529.          iplot = iplot + 1;
  2530.          plot3(iloop, iplot, combined_plots, f, dirname, x_seconds, steal_list,
  2531.                fsize, item);
  2532.          print "   Finished Plot ",iplot," of ",max_plots;
  2533.  
  2534.          # Figure 4: Idle Time
  2535.          iplot = iplot + 1;
  2536.          plot4(iloop, iplot, combined_plots, f, dirname, x_seconds, idle_list,
  2537.                fsize, item);
  2538.          print "   Finished Plot ",iplot," of ",max_plots;
  2539.  
  2540.          # Figure 5: Read Throughput and Total CPU Utilization
  2541.          iplot = iplot + 1;
  2542.          fsize = 6;
  2543.          plot5(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2544.                fsize, item, device_data_list, line_list);
  2545.          print "   Finished Plot ",iplot," of ",max_plots;
  2546.  
  2547.          # Figure 6: Write Throughput and Total CPU Utilization
  2548.          iplot = iplot + 1;
  2549.          plot6(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2550.                fsize, item, device_data_list, line_list);
  2551.          print "   Finished Plot ",iplot," of ",max_plots;
  2552.  
  2553.          # Figure 7: Read Request complete rate, Write Request complete rate, and Total CPU Utilization
  2554.          # HTML report output (opt of section)
  2555.          iplot = iplot + 1;
  2556.          fsize = 6
  2557.          plot7(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2558.                fsize, item, device_data_list, line_list);
  2559.          print "   Finished Plot ",iplot," of ",max_plots;
  2560.  
  2561.          # Figure 8: Read Request merge rate, Write Request merge rate, and Total CPU Utilization
  2562.          iplot = iplot + 1;
  2563.          plot8(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2564.                fsize, item, device_data_list, line_list);
  2565.          print "   Finished Plot ",iplot," of ",max_plots;
  2566.  
  2567.          # Figure 9: Avg. Request Size, Avg. Queue Length, and Total CPU Utilization
  2568.          iplot = iplot + 1;
  2569.          plot9(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2570.                fsize, item, device_data_list, line_list);
  2571.          print "   Finished Plot ",iplot," of ",max_plots;
  2572.  
  2573.          # Figure 10: Average Wait Times for read, write requests
  2574.          iplot = iplot + 1;
  2575.          if (vflag == 9):
  2576.             plot10v9(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2577.                      fsize, item, device_data_list, line_list);
  2578.          elif (vflag == 10):
  2579.             plot10v10(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2580.                       fsize, item, device_data_list, line_list);
  2581.          # end if
  2582.          print "   Finished Plot ",iplot," of ",max_plots;
  2583.  
  2584.          # Figure 11: Percentage CPU Util
  2585.          iplot = iplot + 1;
  2586.          plot11(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2587.                 fsize, item, device_data_list, line_list);
  2588.          print "   Finished Plot ",iplot," of ",max_plots;
  2589.       # end for
  2590.  
  2591.    elif (combined_plots == 1):
  2592.       # For each plot, Loop over each device and create plot and HTML:
  2593.       iloop = 1;
  2594.       iplot = 0;
  2595.  
  2596.       output_str = "<HR> \n";
  2597.       f.write(output_str);
  2598.  
  2599.       # Figure 1: Various CPU percentages (user, system, nice) vs. time (3 subplots)
  2600.       iplot = iplot + 1;
  2601.       plot1(iloop, iplot, combined_plots, f, dirname, x_seconds, user_list, system_list,
  2602.             nice_list, fsize, item);
  2603.       print "   Finished Plot ",iplot," of ",max_plots;
  2604.  
  2605.       # Figure 2: iowait percentage time
  2606.       iplot = iplot + 1;
  2607.       plot2(iloop, iplot, combined_plots, f, dirname, x_seconds, iowait_list,
  2608.             fsize, item);
  2609.       print "   Finished Plot ",iplot," of ",max_plots;
  2610.  
  2611.       # Figure 3: Steal Time
  2612.       iplot = iplot + 1;
  2613.       plot3(iloop, iplot, combined_plots, f, dirname, x_seconds, steal_list,
  2614.             fsize, item);
  2615.       print "   Finished Plot ",iplot," of ",max_plots;
  2616.  
  2617.       # Figure 4: Idle Time
  2618.       iplot = iplot + 1;
  2619.       plot4(iloop, iplot, combined_plots, f, dirname, x_seconds, idle_list,
  2620.             fsize, item);
  2621.       print "   Finished Plot ",iplot," of ",max_plots;
  2622.  
  2623.       # Figure 5: Read Throughput and Total CPU Utilization
  2624.       iplot = iplot + 1;
  2625.       fsize = 6;
  2626.       plot5(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2627.            fsize, item, device_data_list, line_list);
  2628.       print "   Finished Plot ",iplot," of ",max_plots;
  2629.  
  2630.       # Figure 6: Write Throughput and Total CPU Utilization
  2631.       iplot = iplot + 1;
  2632.       plot6(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2633.             fsize, item, device_data_list, line_list);
  2634.       print "   Finished Plot ",iplot," of ",max_plots;
  2635.  
  2636.       # Figure 7: Read Request complete rate, Write Request complete rate, and Total CPU Utilization
  2637.       iplot = iplot + 1;
  2638.       plot7(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2639.           fsize, item, device_data_list, line_list);
  2640.       print "   Finished Plot ",iplot," of ",max_plots;
  2641.  
  2642.       # Figure 8: Read Request merge rate, Write Request merge rate, and Total CPU Utilization
  2643.       iplot = iplot + 1;
  2644.       plot8(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2645.             fsize, item, device_data_list, line_list);
  2646.       print "   Finished Plot ",iplot," of ",max_plots;
  2647.  
  2648.       # Figure 9: Avg. Request Size, Avg. Queue Length, and Total CPU Utilization
  2649.       iplot = iplot + 1;
  2650.       plot9(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2651.             fsize, item, device_data_list, line_list);
  2652.       print "   Finished Plot ",iplot," of ",max_plots;
  2653.  
  2654.       # Figure 10: Average Wait Times for read, write requests
  2655.       iplot = iplot + 1;
  2656.       if (vflag == 9):
  2657.          plot10v9(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2658.                   fsize, item, device_data_list, line_list);
  2659.       elif (vflag == 10):
  2660.          plot10v10(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2661.                   fsize, item, device_data_list, line_list);
  2662.       # end if
  2663.       print "   Finished Plot ",iplot," of ",max_plots;
  2664.  
  2665.       # Figure 11: Percentage CPU Util
  2666.       iplot = iplot + 1;
  2667.       plot11(iloop, iplot, combined_plots, f, dirname, x_seconds, time_sum_list,
  2668.              fsize, item, device_data_list, line_list);
  2669.       print "   Finished Plot ",iplot," of ",max_plots;
  2670.    # end of
  2671.    print "Finished. Please open the document HTML/report.html in a browser.";
  2672.  
  2673.    # Start of Pickling
  2674.    # =================
  2675.    if (pickle_success > 0):
  2676.       # Open file for pickling
  2677.       pickle_file = open('iostat_file.pickle', 'w')
  2678.  
  2679.       # Big dictionary:
  2680.       iostat_dict = {};
  2681.  
  2682.       # Create CPU dictionary for pickling:
  2683.       cpu_data = {};
  2684.       cpu_data["user_list"] = user_list;
  2685.       cpu_data["nice_list"] = nice_list;
  2686.       cpu_data["system_list"] = system_list;
  2687.       cpu_data["iowait_list"] = iowait_list;
  2688.       cpu_data["steal_list"] = steal_list;
  2689.       cpu_data["idle_list"] = idle_list;
  2690.       cpu_data["cpu_labels"] = cpu_labels;
  2691.       cpu_data["time_sum_list"] = time_sum_list;
  2692.       cpu_data["version"] = vflag;
  2693.  
  2694.       # Time dictionary for pickling:
  2695.       time_data = {};
  2696.       time_data["date_list"] = date_list;
  2697.       time_data["time_list"] = time_list;
  2698.       time_data["meridian_list"] = meridian_list;
  2699.  
  2700.       # Device data
  2701.       #device_data = {};
  2702.       #device_data["rrqm"] = device_data_list["rrqm"];
  2703.       #device_data["wrqm"] = device_data_list["wrqm"];
  2704.       #device_data["r"] = device_data_list["r"];
  2705.       #device_data["w"] = device_data_list["w"];
  2706.       #device_data["rMB"] = device_data_list["rMB"];
  2707.       #device_data["wMB"] = device_data_list["wMB"];
  2708.       #device_data["avgrqsz"] = device_data_list["avgrqsz"];
  2709.       #device_data["avgqusz"] = device_data_list["avgqusz"];
  2710.       #device_data["await"] = device_data_list["await"];
  2711.       #device_data["r_await"] = device_data_list["r_await"];
  2712.       #device_data["w_await"] = device_data_list["w_await"];
  2713.       #device_data["svctm"] = device_data_list["svctm"];
  2714.       #device_data["util"] = device_data_list["util"];
  2715.  
  2716.       # Assemble the big pickle;
  2717.       iostat_dict["device_data_list"] = device_data_list;
  2718.       iostat_dict["cpu_data"] = cpu_data;
  2719.       iostat_dict["system_info"] = system_info;
  2720.       iostat_dict["time_data"] = time_data;
  2721.       iostat_dict["x_seconds"] = x_seconds;
  2722.  
  2723.       # Write list to pickle file
  2724.       pickle.dump(iostat_dict, pickle_file);
  2725.  
  2726.       # Close pickle file
  2727.       pickle_file.close();
  2728.    # end if
  2729. # end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement