?
Solved

Shell Script for getting Errors

Posted on 2012-09-17
4
Medium Priority
?
798 Views
Last Modified: 2012-09-18
Hi Experts,

I have a systemout.log file where I need to monitor for the errors. When I do grep for the errors , it will list me all the errors repeatedly. I am looking for a script where it grep the Error and count it.

I use grep "E" systemout.log

[9/17/12 1:00:00:162 EDT] 0000009a LdapRegistryI E   No user sadmin found
[9/17/12 1:00:00:171 EDT] 0000009a LdapRegistryI E   SECJ0336E: Authentication failed for user sadmin because of the following exception
[9/17/12 1:00:00:194 EDT] 0000009a LTPAServerObj E   SECJ0369E: Authentication failed when using LTPA. The exception is No user sadmin found.
[9/17/12 1:00:00:235 EDT] 0000009a LdapRegistryI E   No user sadmin found
[9/17/12 1:00:00:236 EDT] 0000009a LdapRegistryI E   SECJ0336E: Authentication failed for user sadmin because of the following exception com.ibm.websphere.security.PasswordCheckFailedException: No user sadmin found
[9/17/12 1:00:00:237 EDT] 0000009a LTPAServerObj E   SECJ0369E: Authentication failed when using LTPA. The exception is No user sadmin found.
[9/17/12 5:50:30:922 EDT] 00000070 servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper run [Servlet Error]-[class java.lang.ClassNotFoundException: org.apache.jsp._textOnlyStyles]: java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.apache.jsp._textOnlyStyles
[9/17/12 7:01:26:998 EDT] 0000009a webcontainer  E com.ibm.ws.webcontainer.WebContainer handleRequest SRVE0255E: A WebGroup/Virtual Host to handle /favicon.ico has not been defined.
[9/17/12 7:01:27:033 EDT] 0000009b webcontainer  E com.ibm.ws.webcontainer.WebContainer handleRequest SRVE0255E: A WebGroup/Virtual Host to handle /favicon.ico has not been defined.
[9/17/12 7:01:28:033 EDT]000000c4 servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught exception created in one of the service methods of the servlet /jsp/Search.jsp in application AP_JSP. Exception created : com.ibm.websphere.servlet.error.ServletErrorReport:
[9/17/12 7:50:00:168 EDT] 0000009a LdapRegistryI E   No user sadmin found

Thanks.
0
Comment
Question by:07592161981m
  • 2
4 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 38407872
If you want to count the occurences, you need to use option -c

grep -c "E" filename
0
 

Author Comment

by:07592161981m
ID: 38408172
I want to use tools like sed/find/grep/awk.

I would like to see the output like this:

3 - No user sadmin found
6 -  Authentication failed when using LTPA
2 - SRVE0068E: Uncaught exception created in one of the service methods
3 -  SRVE0255E: A WebGroup/Virtual Host to handle /favicon.ico has not been defined.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38409302
I have something like this:

perl -ne 'BEGIN {%h};/E\s+(.*)/;$h{$1}++; END{print "$_: $h{$_}\n" for keys(%h)}' filename

Open in new window


Problem is that the error messages are long and you did not mention any criteria where to chop them off.
0
 
LVL 20

Accepted Solution

by:
simon3270 earned 1500 total points
ID: 38409664
If all "E" entries have a space either side of the E (they seem to in your examples), then:

    grep " E " systemout.log | sed 's/^.* E //' | sort | uniq -c

will count unique error logs.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question