Graphing pgstat output

If you’re using the pgd pgstat utility I posted about previously, you can graph the output with very little effort using gnuplot. In my case I use pgd pgstat for capturing output for various PostgreSQL performance tests, and of course graphing that output is important.

I won’t go into detail about installing gnuplot here. Once you have it installed, use this example script to create the graphs. In my case I spool the output to aquaterm on my Macbook Pro. In the plot lines simply change “using 16″ to “using N” where N is the pgd output column you would like to graph. For instance, column 2 is commits, column 16 is load average. This creates nice looking graphs for your reports, presentations or analytics. When your ready to go to the next level, this FAQ is excellent.

I don’t think gnuplot is great to show graphs over time, for instance in monitoring tools or capacity tools. I will write about using rrdtool for this at some point. But for quickly graphing the output of pgd pgstat, gnuplot can’t be beat.

Here is an example gnuplot file:

	set terminal aqua
	set title "PostgreSQL performance"
	set ylabel "executions / 10 seconds"
	plot \
	"data.out" using 11 title "Server #1 Inserts" with lines , \
	"data.out" using 12 title "Server #1 Updates" with lines, \
	"data.out" using 2 title "Server #1 Total Commits" with lines

Here is an example graph: