Hi,
I have a file which consists of the following information in repeating blocks.
************First iteration***************
xr_lab#show memory compare start
Thu Sep 19 14:38:06.400 WIB <<<<<<<<<< START TIME
Successfully stored memory snapshot in /var/log/malloc_dump_memcmp_start.out
xr_lab#
xr_lab#
xr_lab#show memory compare end
Thu Sep 19 14:40:56.123 WIB <<<<<<<<<< END TIME
Successfully stored memory snapshot in /var/log/malloc_dump_memcmp_end.out
xr_lab#
xr_lab#show memory compare report
Thu Sep 19 14:41:08.084 WIB
PID NAME MEM BEFORE MEM AFTER DIFFERENCE MALLOCS-NEW
-------------------------------------------------------------------------------
2550 sysdb_svr_local 7881443 7878256 -3187 87391
7582 mibd_interface 8670334 8484152 -186182 267657
**********Second iteration************
xr_lab#show memory compare start
Thu Sep 19 14:43:07.946 WIB <<<<<<<<<< START TIME
Successfully stored memory snapshot in /var/log/malloc_dump_memcmp_start.out
xr_lab#
xr_lab#
xr_lab#
xr_lab#show memory compare end
Thu Sep 19 14:45:27.916 WIB <<<<<<<<<< END TIME
Successfully stored memory snapshot in /var/log/malloc_dump_memcmp_end.out
xr_lab#
xr_lab#
xr_lab#show memory compare report
Thu Sep 19 14:45:42.091 WIB
PID NAME MEM BEFORE MEM AFTER DIFFERENCE MALLOCS-NEW
-------------------------------------------------------------------------------
6777 ospf 24294569 24283592 -10977 227389
7582 mibd_interface 8369050 8514825 145775 126259
I would like to capture the {start time, mem_before} in one column, and {end time, mem_after} in another column for mibd_interface.
The logic I need looks something like this. Can you please assist to develop it further?
awk '/show memory compare start/{
getline; start_time=$0;
}
/show memory compare end/{
getline; end_time=$0;
}
if(start_time); /mibd_interface/print $3
if(end_time); /mibd_interface/print $4