02-25-2009
43,
0
Join Date: Aug 2008
Last Activity: 28 May 2009, 3:06 PM EDT
Location: Chennai
Posts: 43
Thanks Given: 0
Thanked 0 Times in 0 Posts
Tune my logic of script
I have big log file, which contains the netstat output from my application server to a particular DB server. I aim is to plot a daily graph for this. Please find the sample log file below.
[2009-02-25:12:27:00] @ [783] - ...........................................................
[2009-02-25:12:27:00] @ [783] - Total number of connection to the DB is 5
[2009-02-25:12:27:00] @ [783] - ...........................................................
[2009-02-25:12:27:00] @ [783] - Netstat output For DB
tcp 0 0 783:57934 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:57901 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:58243 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:57574 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:57572 315-VIP.ipc.us.ae:5150 ESTABLISHED
[2009-02-25:12:28:00] @ [783] - ...........................................................
[2009-02-25:12:28:00] @ [783] - Total number of connection to the DB is 5
[2009-02-25:12:28:00] @ [783] - ...........................................................
[2009-02-25:12:28:00] @ [783] - Netstat output For DB
tcp 0 0 783:57934 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 268 783:57901 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:58243 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:57574 315-VIP.ipc.us.ae:5150 ESTABLISHED
tcp 0 0 783:57572 315-VIP.ipc.us.ae:5150 ESTABLISHED
from which i need to extract like the below
12:27:00 5
12:28:00 5
This is the time and total number of connection to the DB.
For this i have write a one line script like this
awk '/Total/' smp.log | awk 'BEGIN{FS="["} {print $2, $3}' | awk 'BEGIN{FS="]"} {print $1, $3}' | awk 'BEGIN{FS=":"} {print $2":"$3":"$4}' | awk '{print $1, $12}'
I think i am using too much awk command for this.. It would be great if some one tune my logic.
Thanks,
Senthilkumar