Java stack trace parser in awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Java stack trace parser in awk
# 1  
Old 03-18-2015
Java stack trace parser in awk

I want the developers to get a mail with Java stack traces on a daily bases. When something is flaged as known issue and will get a fix but mean while this does not need to get sent each dayl. This is what I got so far. It's a bash script that runs some AWK in it.

To get the files that needs to be parsed
Code:
WORK_LOG="$(find $APP_DATA/log/ -maxdepth 1 -newermt "1 days ago" ! -newermt "00:00")"

This is working. All stack traces contains "exception:" string and can be x lines untill a INFO log message accurs and we stop printing.
Code:
awk '/excepeion\:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p' $WORK_LOG  #>> output_test.log



Now what I need is to get rid of line containing known errors string so next part of awk don't catch them. I will give developers ability to paste strings that will be ignored into a config file
Code:
KNOW_EXCEPTION1="known error"

What I'm trying to do is get awk to remove the known exception rows before the print from here to here part.
Code:
awk '!/'"$KNOW_EXCEPTION1"'/{print $1} /excepeion\:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p'$WORK_LOG  >> output_test.log


This I found through google but I need to work it into what I already have and I can't get it to work.
Code:
awk '!/known error/'


Last edited by chipmunken; 03-18-2015 at 12:08 PM..
# 2  
Old 03-18-2015
Code:
awk -v exc="${KNOW_EXCEPTION1}" '$0 !~ exc ........

# 3  
Old 03-18-2015
How should I tie these together? I know a patter can follow another patter with a space but I'm getting syntax error if I do what you wrote.

Code:
awk -v exc="${KNOW_EXCEPTION1}" '$0 !~ exc  /excepeion\:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p' $WORK_LOG

Code:
awk: $0 !~ exc /excepeion\:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p
awk:                     ^ backslash not last character on line

# 4  
Old 03-18-2015
Code:
awk -v exc="${KNOW_EXCEPTION1}" '$0 !~ exc && /excepeion:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p' $WORK_LOG

Do you have 2 patterns that wou;d like to OR and do the action?
# 5  
Old 03-18-2015
Maybe sth along this line (untested):
Code:
awk     'NR==FNR                {KnErr[$0]; next}
         /exception/            {for (k in KnErr) if ($0 ~ k) next
                                 P=1
                                }
         /UTC Level INFO Scope/ {P=0}
         P
        ' known_errors.conf $WORK_LOG

# 6  
Old 03-18-2015
Quote:
Originally Posted by vgersh99
Code:
awk -v exc="${KNOW_EXCEPTION1}" '$0 !~ exc && /excepeion:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p' $WORK_LOG

Do you have 2 patterns that wou;d like to OR and do the action?
I want it to first remove the known exception rows before the next part works it's magic and prints the "wanted" exceptions

So first this
Code:
$0 !~ exc

and THEN do
Code:
/exception\:/{p=1;print;next} p&&/UTC Level INFO Scope/{p=0};p

# 7  
Old 03-18-2015
I guess what I had last should work. Try it and let us know.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Server hung, is this a stack trace?

Hi everyone, Our Red Hat server hung yesterday, and I managed to log into the console and see the following message: RIP: 0010: mwait_idle_with_hints+0x66/ 0x67 RSP: 0018:ffffffff80457f40 EFLAGS: 00000046 RAX: 0000000000000010 RBX: ffff810c20075910 RCX: 0000000000000001 RDX:... (6 Replies)
Discussion started by: badoshi
6 Replies

2. Programming

View Stack Trace of different cores

I have a C program which is running as daemon and has some threads. The program is running on dual core cpu and it may happen that different threads may run on different cpu core. The problem is sometimes it crashes with some heap memory corruption probably between threads. GDB command(t a a... (2 Replies)
Discussion started by: rupeshkp728
2 Replies

3. Shell Programming and Scripting

Stack Trace

Hi All Thought it would be kind of fun to implement a stack trace for a shell script that calls functions within a sub shell. This is for bash under Linux and probably not portable - #! /bin/bash error_exit() { echo "=======================" echo $1 echo... (4 Replies)
Discussion started by: steadyonabix
4 Replies

4. AIX

How to get the stack trace using kdb?

Hi All, I am trying to debug my core file using kdb. When I try to get the stack trace I am facing this error. core mapped from @ 700000000000000 to @ 70000000306fc04 Preserving 1680415 bytes of symbol table Dump does not start with valid magic number WARNING: Possibly truncated or... (2 Replies)
Discussion started by: Sachin1987
2 Replies

5. Filesystems, Disks and Memory

get stack trace from C program on Solaris 8

I'm on solaris 8. I need to check the stack trace inside my C program. I don't have printstack or walkstack. I tested getcontext and it works. But how do I get the symbols from "stack_t" ? Help please. Many thanks! (4 Replies)
Discussion started by: rydahl
4 Replies

6. UNIX for Advanced & Expert Users

help required - stack trace

Hi all, One of our programs written in Java, produced this logfile. This job runs 48 threads and only one thread failed with this error. The code is a blackbox(external product), so cant look at the source code. From what I can infer from the log, the job was trying to write the log messages into... (9 Replies)
Discussion started by: ranj@chn
9 Replies

7. Shell Programming and Scripting

Need to capture ERROR msg and stack trace

Hi all, I was hoping someone can point me in the right direction. I'm trying to filter out errors from a web log- any lines with ERROR in it. I know I could simply use the grep command to do this. However, there are times when a stack trace follows the error line. I would like to capture these... (2 Replies)
Discussion started by: gswhoops
2 Replies

8. Programming

printing a stack trace with backtrace

I am trying to print a stack trace programatically using backtrace and backtrace_symbols. The problem is that the stack being printed in a mangled format. Is there a way to get the output in more of a human readable form? I am using Red Hat and the program is written in c++. (2 Replies)
Discussion started by: dmirza
2 Replies

9. Programming

Core file without a readable stack trace

I am using gdb to examine a core file but the output contains only the method addresses in hex. Is there anyway to translate these addresses to a human-readable form? :confused: (0 Replies)
Discussion started by: ciregbu
0 Replies
Login or Register to Ask a Question