The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
searching and storing unknown number of lines based on the string with a condition swamymns Shell Programming and Scripting 7 05-13-2008 01:02 AM
How to enter if-then condition on command prompt/line ? mpc8250 Shell Programming and Scripting 3 02-10-2008 12:27 PM
display all lines shary Shell Programming and Scripting 3 02-17-2007 04:09 PM
display lines after a particular line number rajashekar.y UNIX for Dummies Questions & Answers 6 01-03-2007 03:53 AM
how to concatenate two command in one line and get the display in one screen vasikaran UNIX for Dummies Questions & Answers 9 07-01-2005 05:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-10-2008
vithala vithala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
concatenate and display 2 lines as 1 with a condition for 2 line ?

I have 2 pattern of lines (SQL query and Time taken)in a log i need to capture all SQL queries with time taken >20 sec and need to display as one line.


2 lines from log:

2007-10-23 11:39:17,061 DEBUG [server.startup : 1] [com.fourcs.clm.fw.pem.CLMPEMDBService] - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN C WHERE A.GROUP_ID = B.GROUP_ID AND B.FN_ID = C.FN_ID ORDER BY A.GROUP_CD


2007-10-23 11:39:17,061 DEBUG [server.startup : 1] [com.fourcs.clm.fw.pem.CLMPEMDBService] - Time Taken : 640
  #2 (permalink)  
Old 07-10-2008
vithala vithala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
i have tried to display results Time taken > 20000 by using a command but i want this results to be concatenated with above line(SQL Query line) for Time taken > 20000

cd /logs/WS/apps/logs

grep -i 'Time Taken :' /logs/WS/apps/logs/SQLPerformance_x1prdapp7*Node01_C*S*.log > /export/home/jftl784/script/Latest_SQLTIME_TMP.txt
awk '$12 > 20000 {print $0}' < /export/home/jftl784/script/Latest_SQLTIME_TMP.txt > /export/home/jftl784/script/Latest_SQLTIME_TMP_2.txt

grep -v 'Non-deferrable Alarm :' < /export/home/jftl784/script/Latest_SQLTIME_TMP_2.txt > /export/home/jftl784/script/Latest_SQLTIME_MSGS_$1.txt
  #3 (permalink)  
Old 07-10-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
Post a portion of your log file and the desired output.

Regards
  #4 (permalink)  
Old 07-10-2008
vithala vithala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
Input :
2007-10-23 11:39:17,061 DEBUG [server.startup : 1] [com.fourcs.clm.fw.pem.CLMPEMDBService] - SQL Query : SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN C WHERE A.GROUP_ID = B.GROUP_ID AND B.FN_ID = C.FN_ID ORDER BY A.GROUP_CD

2007-10-23 11:39:17,061 DEBUG [server.startup : 1] [com.fourcs.clm.fw.pem.CLMPEMDBService] - Time Taken : 640

output:
SELECT A.GROUP_CD , C.FN_CD FROM UP_GROUP A , PRD_GROUP_TO_FN B , PRD_FN C WHERE A.GROUP_ID = B.GROUP_ID AND B.FN_ID = C.FN_ID ORDER BY A.GROUP_CD
: Time Taken : 640
  #5 (permalink)  
Old 07-10-2008
vithala vithala is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 6
Log file contents :
2007-10-23 11:42:30,759 DEBUG [WebContainer : 0] [com.fourcs.clm.fw.pem.CLMPEMDBService] - SQL Query : Select UIG.UIG_ID , UIG.UIG_REF AS UIG_CD , GRP_ORDER , UIG.UIG_NM , GLANG.GROUP_LABEL , GLANG.GROUP_DESC , ROLE_CD , UIL_ID from (select GRP.UIG_ID , GRP.UIG_REF , GRP.UIG_NM , GRP_ORDER , ROLE_CD , UIL_ID from UI_INTFXLOCATION x , UI_GROUP GRP where x.UII_ID=13 and x.UIG_ID=GRP.UIG_ID and x.IS_ACTIVE='Y')
UIG LEFT JOIN UI_GROUP_LANG GLANG on UIG.UIG_ID=GLANG.UIG_ID and GLANG.LANG_CD='eng' order by GRP_ORDER
2007-10-23 11:42:30,759 DEBUG [WebContainer : 0] [com.fourcs.clm.fw.pem.CLMPEMDBService] - Time Taken : 354
2007-10-23 11:42:31,573 DEBUG [WebContainer : 0] [com.fourcs.clm.fw.pem.CLMPEMDBService] - PEM Event : SQLExcessTimeEvent for SQL Refer : Not Available
2007-10-23 11:42:31,573 DEBUG [WebContainer : 0] [com.fourcs.clm.fw.pem.CLMPEMDBService] - SQL Query : select UIE.UIE_ID , UIE.UIE_REF AS UIE_CD , UIE.UIE_NM , UIE_URL , UIE_LANG.ELEMENT_LABEL , UIE_LANG.ELEMENT_DESC , UIG_ID , ELMNT_ORDER , IS_MANDATORY from (select elm.UIE_ID , elm.UIE_REF , elm.UIE_NM , UIE_URL , grpx.UIG_ID , grpx.ELMNT_ORDER , IS_MANDATORY from UI_INTFXLOCATION intf , UI_GROUP grp , UI_GRPXELMNT
grpx , UI_ELEMENT elm where intf.UII_ID=13 and intf.UIG_ID=grp.UIG_ID and grp.UIG_ID=grpx.UIG_ID and grpx.UIE_ID=elm.UIE_ID and grpx.IS_ACTIVE='Y')UIE left join UI_ELEMENT_LANG UIE_LANG on UIE.UIE_ID=UIE_LANG.UIE_ID and UIE_LANG.LANG_CD='eng' order by UIG_ID , ELMNT_ORDER
2007-10-23 11:42:31,573 DEBUG [WebContainer : 0] [com.fourcs.clm.fw.pem.CLMPEMDBService] - Time Taken : 708
  #6 (permalink)  
Old 07-10-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 750
Code:
awk '
{
    FS="- "
    OFS=" : "
    split($NF,a,OFS)
    if (tolower(a[2]) ~ "select")
       sav = a[2]
    if (a[2]+0 > 20)
       print sav, a[1], a[2]
}' file
  #7 (permalink)  
Old 07-10-2008
Diabolist Diabolist is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 44
Hmm, I read your other post. This may not be what you want... but o-well.

Code:
#!/bin/ksh

INPUT=zzz.input
QUERYFILE=zzz.query
TIMEFILE=zzz.time
OUTPUT=zzz.out

grep "SQL Query :" $INPUT > $QUERYFILE

grep "Time Taken :" $INPUT |awk '{if ($NF > 20000) print $0; else print ""}' > $TIMEFILE

paste $QUERYFILE $TIMEFILE > $OUTPUT
The awk statement might be better as this:

Code:
awk '{if ($NF > 20000) print "ALERT - Time taken:",$NF; else print "OK - Time taken:",$NF}'
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:21 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0