#!/usr/bin/awk -f # Copyright 2001 Antonio Fiol - W3ping S.A. # E-mail: fiol@w3ping.com # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA function datediff ( start, end, sf, ef, diff ) { split (start, sf, /\.|:/); split (end, ef, /\.|:/); diff= (ef[5]-sf[5]); diff+=(ef[4]-sf[4])*1000; diff+=(ef[3]-sf[3])*1000*60; diff+=(ef[2]-sf[2])*1000*60*60; diff+=(ef[1]-sf[1])*1000*60*60*24; #Month change not controlled return diff; } BEGIN { OFS=";" } /StartTransactionCommand/ { start[$2]=$1; } /query:/ { record=$0; gsub(/.*query: /,"",record); gsub(/[m-]?([0-9]+\.?|\.[0-9])[0-9]*/,"",record); # Consider numbers like 123, -123.4 or m123 gsub(/'[^']*'/,"''",record); gsub(/ *;.*$/,"",record); # Hope that query was not like query1;query2;. We will delete query2 :-( query[$2]=record; } /CommitTransactionCommand/ { if($2 in start) { print datediff(start[$2], $1), "\""query[$2]"\""; fflush(); } delete start[$2]; delete query[$2]; }