How to show performance statistics in a chart

Working on performance tests and tuning is an interesting and challenging job. One has to prepare tests, execute and also evaluate them. The preparation and execution is not always easy, but it is manageable. The evaluation of the tests comes with an interesting problem. The problem is called data visualization.

I was testing a system spread across several servers and there were several technologies involved (Microsoft perfmon, Apache jMeter) in the testing and monitoring. Therefore, the visualization was a challenge.

It is not a problem to put all the statistics into one spreadsheet and try to create a chart. BUT there is usually a lot of tests and the preparation of each chart takes ages. Secondly, the traditional spreadsheets are good to show sales for four regions, but they have problems with hundreds or thousands of data samples. The chart looks like a saw (in MS Excel) or is very CPU intensive (OpenOffice.org). So, automation and a good visualization technique is needed.

I selected gnuplot for the visualization. It is fast, it creates loads of different charts and it is managed from a script console… so, automation is possible. In my approach, the preparation of data files and generation of the gnuplot script is done using ruby scripting language. The resulting chart is nice and its generation took me just a few seconds, including deciding what should be displayed.

Chart

For those with no patience, the script is available for download here.

For the others, here is a short summary of what the script is doing for you. It …

  • Takes several CSV input files as parameters. Thus you can have a chart with data from different servers.
  • Lists all the columns that are in the given CSV file.
  • Gives you the possibility to select the columns of interest.
  • Allows you to specify time format of the timestamp in the file. Default is set to the perfmon format.
  • Scales the data to show all of the data sets in the same chart.
  • Generates a gnuplot script for you. You can then customize the script to your needs.

How it works

0. Create a “temp” directory in the directory where you run the script.
1. Run

ruby process.rb  SERVER3.csv

2. The script then lists all the columns from the CSV file

Select fields (time first, separated by space) from file SERVER3.csv
0 : "(PDH-CSV 4.0) (Central Europe Standard Time)(-60)"
1 : "\\SERVER3\LogicalDisk(C:)\Disk Bytes/sec"
2 : "\\SERVER3\LogicalDisk(D:)\Disk Bytes/sec"
3 : "\\SERVER3\Memory\Available MBytes"
4 : "\\SERVER3\Memory\Page Faults/sec"
5 : "\\SERVER3\Network Interface(HP NC7782 Gigabit Server Adapter)\Bytes Total/sec"
6 : "\\SERVER3\Network Interface(MS TCP Loopback interface)\Bytes Total/sec"
7 : "\\SERVER3\PhysicalDisk(0 C:)\Disk Bytes/sec"
8 : "\\SERVER3\PhysicalDisk(1 D:)\Disk Bytes/sec"
9 : "\\SERVER3\Process(java)\Page Faults/sec"
10 : "\\SERVER3\Processor(0)\% Processor Time"
11 : "\\SERVER3\Processor(1)\% Processor Time"
12 : "\\SERVER3\Processor(2)\% Processor Time"
13 : "\\SERVER3\Processor(3)\% Processor Time"
14 : "\\SERVER3\Processor(4)\% Processor Time"
15 : "\\SERVER3\Processor(5)\% Processor Time"
16 : "\\SERVER3\Processor(6)\% Processor Time"
17 : "\\SERVER3\Processor(7)\% Processor Time"
18 : "\\SERVER3\Processor(_Total)\% Processor Time"
...
36 : "Server monitoring"
Enter your options:

3. Enter the fields you want in the chart. The timestamp field needs to be the first one; fields are separated by spaces.

0 4 9 18

4. Specify the time format. The default is set to perfmon (US English Windows). Press enter, if you want to use the default.

Specify time format. Put HH:mm:SS into round brackets. Default is: DD/MM/YYYY (HH:mm:SS).XXX
DD/MM/YYYY (HH:mm:SS).XXX

5. The script is generated.

gnuplot script created. Generate a picture with the following command
pgnuplot script.plt

6. Edit the script if necessary. If you do not edit the script, you will get a chart like the one above.

set terminal png
set output "chart.png"
set xdata time
set timefmt "%H:%M:%S"
set format x "%H:%M"
set yrange [0:100]
cd "temp"
plot "SERVER3.csv.tmp" using 1:(0.01*$2) with lines title "0.01 * \\\\SERVER3\\Memory\\Page Faults/sec" smooth bezier, \
"SERVER3.csv.tmp" using 1:(0.01*$3) with lines title "0.01 * \\\\SERVER3\\Process(java)\\Page Faults/sec" smooth bezier, \
"SERVER3.csv.tmp" using 1:(1*$4) with lines title "1 * \\\\SERVER3\\Processor(_Total)\\% Processor Time" smooth bezier

7. Generate the chart with the following command

pgnuplot script.plt

8. Check file chart.png

Limitations

  • The script is very simple and definitely will not work for all data files. Nevertheless, for an experienced ruby programmer it should not be a problem to modify it.
  • Hopefully there are not many bugs in there. If you find some, give me a note (comment under this article is appreciated).

I hope you will find the script useful.

2 comments

  1. I’m a Ruby newby, so I have no idea what the following means:

    process.rb:19:in `initialize’: No such file or directory – temp\perfmon.csv.tmp
    (Errno::ENOENT)

    I’ve done scripting and programming in other languages… but can’t seem to find what’s causing the tmp file to not be created.

    Any ideas?

  2. found the answer:
    line 118 calls ‘save_array’, using just \\#{TEMP_DIR} … the problem is that this doesn’t capture the root directory that process.rb was ran in – for example, I ran it in c:\temp, and it was only capturing “temp”, and as a result, it wasn’t able to create/find the file. I added “C:\\” to the beginning of the string, and that fixed the problem. A better solution would be to set a temp variable with the directory & drive (and parents, if any) that the process was ran from, and use that…

Comments are closed.