Line count of trace files for 24 period


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Line count of trace files for 24 period
# 1  
Old 01-21-2015
Line count of trace files for 24 period

Hi,
Using solaris 10 5.10 o/s
I am learning awk as I work here on the job.
What I need to do is isolate the trace file for the last 24 hours. After that I need to open those trace files and search for 'TNS-|ORA-' message from each one. These trace files MAY HAVE an occurance of them. I only need to recognize either one just once above before moving onto the next file otherwise it will become time consuming. The ultimate goal here is to do a total count (wc -l) for metric purposes. In other words if that line item includes the above it is to be counted.
So far this is what I got and would like to have some assistance or guidance as to how to complete this.

Code:
ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | grep 'Jan 20' | awk '{print $9}'
output:
/oracle/diag/rdbms/abcdef/abcdef/trace/abcdef _d000_21750.trc
/oracle/diag/rdbms/abcdef/abcdef/trace/abcdef_d000_22001.trc
/oracle/diag/rdbms/abcdef/abcdef/trace/abcdef_d001_22002.trc

I generated the above list.
This is what I believe needs to happen next:
I need to loop thru this list, open each line using ‘more’ or ‘cat’ and do a "find" on 'TNS-|ORA-'. If it returns positive add it to the count.
count wc -l.

This part doesn’t work:
Code:
| awk 'BEGIN {more *.trc;} {egrep 'TNS-|ORA-' *.trc} END | wc –l

Any help or suggestions in this matter would be appreciated.
Thanks
al

Last edited by Corona688; 01-21-2015 at 01:39 PM..
# 2  
Old 01-21-2015
Moderator's Comments:
Mod Comment Posting "Does not work" without explanation does not help you or anyone. If a command does not work for you, please show the exact circumstances you used it, and the exact error or malfunction you received. Do not paraphrase errors, or post the text as links, images, or attachments if you can avoid it: Paste the exact message, in code tags, like [code] text [/code] or by selecting the text and using the Image button.

Thank you.

The UNIX and Linux Forums


Not the most efficient solution, but your code could probably use a rewrite from scratch. The ls -l is especially pointless and likely to break down.
Code:
ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | grep 'Jan 20' | awk '{print $9}' | 
        xargs awk '/TNS-|ORA-/' | wc -l

# 3  
Old 01-21-2015
Try this:
Code:
find /oracle/diag/rdbms/*/*/trace -type f -name '*d00*.trc' -mtime 0 -exec egrep -c 'ORA-|TNS-' '{}' '+'

# 4  
Old 01-21-2015
Without further info I can tell you that this:
Code:
awk 'BEGIN {more *.trc;} {egrep 'TNS-|ORA-' *.trc} END | wc –l

cannot work. You have some logical and syntactical errors in there, e.g. a missing closing quote and awk and shell mixed up. awk does not know more or egrep, it needs a command or a script built from pattern {action} pairs. action is one or more awk commands, it cannot cope with shell commands.
# 5  
Old 01-21-2015
Quote:
Originally Posted by Corona688
...
Not the most efficient solution, but your code could probably use a rewrite from scratch. The ls -l is especially pointless and likely to break down.
Code:
ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | grep 'Jan 20' | awk '{print $9}' | 
        xargs awk '/TNS-|ORA-/' | wc -l

That can be simplified to
Code:
ls -l /oracle/diag/rdbms/*/*/trace/*d00*.trc | awk '/Jan 20/ {print $9}' | 
        xargs egrep -c 'TNS-|ORA-'

# 6  
Old 01-22-2015
Hi ,

Here is the final solution that works for me. I spent 3 hours learning about the syntax and making adjustments. This I am presently using at work.

Code:
find /oracle/diag/rdbms/*/*/trace -type f -name '*d00*.trc' -mtime 0 -exec egrep -c 'NS Primary Error' '{}' '+'

After reviewing the results I made an adjustment to the search string to 'NS PRIMARY ERROR' . This returned unique timestamps when the files were detailed indicating the total number of times the request was refused.

Thanks for your suggestions.

regards

al

Last edited by Corona688; 01-22-2015 at 12:36 PM.. Reason: Fix accidental quadruple post
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count the pipes "|" in line and delete line if count greter then number.

Hello, I have been working on Awk/sed one liner which counts the number of occurrences of '|' in pipe separated lines of file and delete the line from files if count exceeds "17". i.e need to get records having exact 17 pipe separated fields(no more or less) currently i have below : awk... (1 Reply)
Discussion started by: ketanraut
1 Replies

2. Shell Programming and Scripting

List line count of multiple files in windows server 2012

how to find out line count ( wc -l ) for multiple fines in windows cmd the command which i a using to find line count for single file is type sec0001.txt | find /c /v "" but how to use it for multiple files to get output filewise as if this command is run like type sec*.txt |... (2 Replies)
Discussion started by: sagar_1986
2 Replies

3. Shell Programming and Scripting

Error files count while coping files from source to destination locaton as well count success full

hi All, Any one answer my requirement. I have source location src_dir="/home/oracle/arun/IRMS-CM" My Target location dest_dir="/home/oracle/arun/LiveLink/IRMS-CM/$dc/$pc/$ct" my source text files check with below example.text file content $fn "\t" $dc "\t" $pc "\t" ... (3 Replies)
Discussion started by: sravanreddy
3 Replies

4. Shell Programming and Scripting

Count number of pattern matches per line for all files in directory

I have a directory of files, each with a variable (though small) number of lines. I would like to go through each line in each file, and print the: -file name -line number -number of matches to the pattern /comp/ for each line. Two example files: cat... (4 Replies)
Discussion started by: pathunkathunk
4 Replies

5. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

6. Shell Programming and Scripting

To get the Files between Time Period

All, How to get the list of files through a unix command which exists / created / updated between 8 PM to 11:59 PM from a particular location. Regards Oracle User (3 Replies)
Discussion started by: Oracle_User
3 Replies

7. Shell Programming and Scripting

Get connection count over a period of time

I used this script to get the connection to a domain in two specific minutes. I need to extend to give result over a range of minutes. The below gives total number of connections in the minutes 00:40 and 01:13 on 22nd March. egrep "22/Mar/2013:00:40|22/Mar/2013:01:13"... (1 Reply)
Discussion started by: anil510
1 Replies

8. Shell Programming and Scripting

awk Adding a Period at the end of a line

I started venturing in learning the art of using AWK/GAWK and wanted to simply added a period from line #11 to line #28 or to the end of the file if there is data. So for example: 11 Centos.NM 12 dojo1 13 redhat.5.5.32Bit 14 redhat.6.2.64Bit... (5 Replies)
Discussion started by: metallica1973
5 Replies

9. AIX

function trace back and address to line number conversion

Hi, I am new to AIX and I am developing a small tool for our product which helps debug memory leaks etc. Q1)Is there a way in which i can get a function trace back as to the call (lets say malloc() )has been made in which file--> in which function. I tried using the #pragma options (... (0 Replies)
Discussion started by: Wkdunreal
0 Replies

10. UNIX for Dummies Questions & Answers

insert period at the end of each line

file1 contains: this is a test this is a test and only a test this is another test this is another test and only another only i'd like my file to look like this: this is a test. this is a test and only a test. this is another test. this is another test and only another only. (6 Replies)
Discussion started by: tjmannonline
6 Replies
Login or Register to Ask a Question