pgFouine - a PostgreSQL log analyzer

« Vivre parmi les cartons me rassure... C'est si beau un carton ! »

Tsung support

« Tsung is an open-source multi-protocol distributed load testing tool.

It can be used to stress HTTP, SOAP and Jabber servers. Tsung (formerly known as IDX-Tsunami) is a free software released under the GPL license.

The purpose of Tsung is to simulate users in order to test the scalability and performances of IP based client/server applications. You can use it to do load and stress testing of your servers. Currently, HTTP and Jabber protocols have been implemented and tested, but it can be easily extended. »

A new PostgreSQL plugin has been added in version 1.2.0.

Introduction

Starting from pgFouine 0.7, a new report type is available to generate sessions for Tsung.

This report type generates an XML file containing a session per pid present in the PostgreSQL log file.

How to generate a sessions file

The following command generates an XML file containing sessions for Tsung:

pgfouine.php -file logs_pgbench_20051211063633_head.log -report tsung -format text > ~/.tsung/tsung_sessions.xml

You can use the -onlyselect option to keep only the read queries:

pgfouine.php -file logs_pgbench_20051211063633_head.log -onlyselect -report tsung -format text > ~/.tsung/tsung_sessions.xml

The file generated looks like:

<sessions>
	<session name="pgfouine-1183" probability="50" type="ts_pgsql">
		<request><pgsql type="connect" database="pgbench" username="postgres" /></request>
		<request><pgsql type="sql"><![CDATA[SET search_path = public]]></pgsql></request>
		<request><pgsql type="sql"><![CDATA[UPDATE accounts SET filler=lower('teSt fiLlEr') WHERE aid < 1000;]]></pgsql></request>
	</session>
	<session name="pgfouine-1190" probability="3" type="ts_pgsql">
		<request><pgsql type="connect" database="pgbench" username="postgres" /></request>
		<request><pgsql type="sql"><![CDATA[SET search_path = public]]></pgsql></request>
		<request><pgsql type="sql"><![CDATA[UPDATE accounts SET filler=lower('teSt fiLlEr') WHERE aid < 1000;]]></pgsql></request>
		<thinktime random="true" value="50" />
		<request><pgsql type="sql"><![CDATA[SELECT * FROM accounts WHERE aid=98611;]]></pgsql></request>
		<request><pgsql type="sql"><![CDATA[SELECT * FROM tellers WHERE tid=8;]]></pgsql></request>
	</session>    
</sessions>

tsung.xml file

We put the following tsung.xml file in ~/.tsung directory:

<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd" [
	<!ENTITY sessions SYSTEM "/home/gsmet/.tsung/tsung_sessions.xml">
] >
<tsung loglevel="info">
	<clients>
		<client host="localhost" use_controller_vm="true"/>
	</clients>

	<servers>
		<server host="192.168.0.1" port="5432" type="tcp"></server>
	</servers>

	<load>
		<arrivalphase phase="1" duration="1" unit="minute">
			<users interarrival="2" unit="second"></users>
		</arrivalphase>

		<arrivalphase phase="2" duration="1" unit="minute">
			<users interarrival="1" unit="second"></users>
		</arrivalphase>
	</load>
	
	&sessions;
	
</tsung>

Then we can run tsung by executing:

tsung start

Finally we can run:

/usr/lib/tsung/bin/tsung_stats.pl

in the log directory (e.g. ~/.tsung/log/20060807-21:10) to generate the report.