Hi all,
Please go through my requirement.
I have a log file in the location /opt/WebSphere61/AppServer/profiles/EMQbatchprofile/logs/EMQbatch
This file contains the follwing pattern data
<af type="tenured" id="42" timestamp="May 14 13:44:13 2011" intervalms="955.624">
<minimum requested_bytes="200" />
<time exclusiveaccessms="0.055" />
<tenured freebytes="0" totalbytes="2147483648" percent="0" >
<soa freebytes="0" totalbytes="2147483648" percent="0" />
<loa freebytes="0" totalbytes="0" percent="0" />
</tenured>
<gc type="global" id="42" totalid="42" intervalms="956.093">
<refs_cleared soft="2665" threshold="32" weak="341" phantom="6" />
<finalization objectsqueued="109" />
<timesms mark="661.941" sweep="17.140" compact="0.000" total="679.629" />
<tenured freebytes="227799624" totalbytes="2147483648" percent="10" >
<soa freebytes="227799624" totalbytes="2147483648" percent="10" />
<loa freebytes="0" totalbytes="0" percent="0" />
</tenured>
</gc>
<tenured freebytes="227799080" totalbytes="2147483648" percent="10" >
<soa freebytes="227799080" totalbytes="2147483648" percent="10" />
<loa freebytes="0" totalbytes="0" percent="0" />
</tenured>
<time totalms="680.097" />
</af>
<af type="tenured" id="43" timestamp="May 14 13:50:13 2011" intervalms="9230.118">
<minimum requested_bytes="200" />
<time exclusiveaccessms="0.055" />
<tenured freebytes="0" totalbytes="2147483648" percent="0" >
<soa freebytes="0" totalbytes="2147483648" percent="0" />
<loa freebytes="0" totalbytes="0" percent="0" />
</tenured>
<gc type="global" id="42" totalid="42" intervalms="956.093">
<refs_cleared soft="2665" threshold="32" weak="341" phantom="6" />
<finalization objectsqueued="109" />
<timesms mark="661.941" sweep="17.140" compact="0.000" total="679.629" />
<tenured freebytes="227799624" totalbytes="2147483648" percent="10" >
<soa freebytes="227799624" totalbytes="2147483648" percent="10" />
<loa freebytes="0" totalbytes="0" percent="0" />
</tenured>
</gc>
<tenured freebytes="227799080" totalbytes="2147483648" percent="13" >
<soa freebytes="227799080" totalbytes="2147483648" percent="10" />
<loa freebytes="0" totalbytes="0" percent="0" />
</tenured>
<time totalms="8540.01" />
</af>
Based on the above data I need to generate a csv file which is shown below.
Desired Output:
hostname, gc type, datetime, duration, location, intervalms, percent
tkdp2csmftp50, af, May 14 13:44:13 2011, 0.680097, EMQbatchprofile, .955624, 10
tkdp2csmftp50, af, May 14 13:50:13 2011, 8.54001, EMQbatchprofile, 9.230118, 13
In the desired output tkdp2csmftp50 is the hostname and the timings (Fields duration and intervalms)which are in millisecs needs to be converted in secs (divided by thousand) and location should be the from the directory path given above (/opt/WebSphere61/AppServer/profiles/EMQbatchprofile/logs/EMQbatch)