IOSTAT Plotter V3
I wrote iostat plotter to plot output from iostat when I ran some tests. I had several requests for improvements and this latest version, v3, incorporates these suggestions. I’ve made a few changes to the basic code since the article:
- Moved the lengend outside the plot to the top right
- Shrunk the size of the legend so you can plot more devices
- The command option “-c” was added so you could combine the devices onto a single plot (total of 11 plots)
- The code can read either sysstat v9.x or sysstat v10.x format for iostat (the output is slightly diffferent).
- The legend labels are auto-sized based on the string length (it’s a heuristic algorithm).
- A simple “-h” option as added that produces a small help output.
The changes were pretty simple and I hope they prove useful.
This tool, iostat_plotter_v3.py simply takes the output from iotstat, parsers the data to some degree, and creates plots and an HTML report. The intent is to allow plot the time history of the IO rather than have to stare at numbers flashing by on the command line.
This version is covered under the GPLv2 license.
With this version of the iostat plotting tool, you can either plot the iostat output from a single device or as many devices as you want. If you run iostat_plotter_v3.py without any options it will create a series of 11 plots for each device. If you have 5 devices it will create a total of 55 plots (11 * 5). If you run it with the “-c” option, if will “combine” the devices into the plots resulting in a total of 11 plots regardless of the number of the number of devices in the iostat output.
To begin, you need to get the iostat output using a command such as:
[laytonj@home8 IOSTAT]$ iostat -c -d -x -t -m /dev/sda 1 180 > iostat.out
which targets a single device. Or you can run,
[laytonj@home8 IOSTAT]$ iostat -c -d -x -t -m 1 180 > iostat.out
Both examples capture the output every second for a total of 180 seconds. Most importantly, the output is in MB/s via the “-m” option. If you change the output to something other than MB/s, you will need to change the plot labels (this isn’t hard to do but just remember that you have to do this).
After running iostat you then run iostat_plotter_v3.py to create the HTML document with the plots. The command is,
[laytonjb ~]$ iostat_plotter_v3.py iostat.out
where “iostat.out” is the output from iostat. The code is written in Python (obviously) and uses the shlex, time, os, and matplotlib modules. If you run it this way, a set of 11 plots for each device will be created. If you want to combined the devices into a single set of plots, then you use the following command:
[laytonjb ~]$ iostat_plotter_v3.py -c iostat.out
The “-c” option will “combine” the devices.
When iostat_plotter_v3 is done it will create a subdirectory “HTML_REPORT” that contains the plots and an html file “report.html”. Open that html file in a browser or word processor and you will see the plots and a small write-up about them. Feel free to modify the code but please send back changes since others might like to see what you have done.
If you want to get the help output just run the application as,
[laytonjb ~]$ iostat_plotter_v3.py -h
An example of the html output is here. It combines several devices together into one set of plots. You can download the file using this link (sorry – I have to use Dropbox because WordPress does not allow .py files).