02-25-2009
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
3 More Discussions You Might Find Interesting
1. Solaris
I have very big log file around 2-3 GB in that it contians 24 hours log data. My work is extract only 5-5 data and count the patterns from them. I worte a script in linux and we're using that.
sed -n "/2009 05:/,/2009 17:/p" trace.log | grep -f patterns.txt > temp.log
while read string ;do... (5 Replies)
Discussion started by: senthil.ak
5 Replies
2. Shell Programming and Scripting
Hi,
I have this routine that reads a microsoft dhcp.netsh dump. Where it finds optionvalue 3 STRING "0.0.0.0"
Replace it with the router IP based on the network
!/usr/bin/perl
while ( <> )
{
if ( /\# NET / ) { $net = $'; $net =~ s///g; }
else
{
s/set optionvalue 3... (1 Reply)
Discussion started by: richsark
1 Replies
3. Shell Programming and Scripting
Hi !
My script read out data out of 144 files per day - every ten minutes a file with data.
data-file
WR030B 306.71 0
WR050B 315.13 0
WR120B 308.34 0
WV030B 3.52 0
WV050B 5.06 0
WV120B 6.65 0
TLUFT02B 8.60... (3 Replies)
Discussion started by: IMPe
3 Replies
TBL(1) General Commands Manual TBL(1)
NAME
tbl - format tables for nroff or troff
SYNOPSIS
tbl [ files ] ...
DESCRIPTION
Tbl is a preprocessor for formatting tables for nroff or troff(1). The input files are copied to the standard output, except for lines
between
Details are given in the
tbl(1)
reference manual.
EXAMPLE
tab) thesinputxample, letting represent a tab (which should be typed as a genuine
.TS
c s s
c c s
c c c
l n n.
Household Population
Town Households
Number Size
Bedminster 789 3.26
Bernards Twp. 3087 3.74
Bernardsville 2018 3.30
Bound Brook 3425 3.04
Branchburg 1644 3.49
Bridgewater 7897 3.81
Far Hills 240 3.19
.TE
yields
Household Population
Town Households
NumberSize
Bedminster 783.26:
Bernards Twp. 3083.74:
Bernardsville 2013.30:
Bound Brook 3423.04:
Branchburg 1643.49:
Bridgewater 7893.81:
Far Hills 243.19:
If no arguments are given, tbl reads the standard input, so it may be used as a filter. When tbl is used with eqn or neqn the tbl command
should be first, to minimize the volume of data passed through pipes.
SEE ALSO
troff(1), eqn(1)
M. E. Lesk, TBL.
7th Edition April 29, 1985 TBL(1)