Searching log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching log
# 1  
Old 01-29-2010
Java Searching log

Code:
<ALM_ID>EMS Huawei/T2000 ManagedElement 589865 PTP /rack=1/shelf=1/slot=11/domain=sdh/port=1 CTP /sts3c_au4-j=64@#@1-75@#@UNEQ@#@15<ALM_ID>} Available} {{Additional Information} {} Available} {{Event Type} CommunicationsAlarm Available} {{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589865} {PTP /rack=1/shelf=1/slot=11/domain=sdh/port=1} {CTP /sts3c_au4-j=64}} Available}}
04/01/10:18:50:48 {Communications Alarm} {{{Probable Cause} 1376 Available} {{Event Time} {Tue, Nov 17, 2009 09:31:33 PM} Available} {{Specific Problem} {5523789 23015986 39792941 54015744} Available} {{Perceived Severity} Minor Available} {{Additional Text} {Huawei/T2000;589858;/rack=1/shelf=1/slot=1/domain=sdh/port=2
native ProbableCause=J0_MM,
service affecting=SA_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;TN_CMBT_34XXX_M01_W_L_HDXC001;/rack=1/shelf=1/slot=1/domain=sdh/port=2,
additionalInfo = AlarmSerialNo=25524438; AlarmReason=Trace identifier mismatch; ProductName=OptiX OSN 7500; EquipmentName=N2SLQ16; AffirmState=TRUE; DetailInfo=; ,
,
<ALM_ID>EMS Huawei/T2000 ManagedElement 589858 PTP /rack=1/shelf=1/slot=1/domain=sdh/port=2@#@1-87@#@TIM@#@22<ALM_ID>} Available} {{Additional Information} {} Available} {{Event Type} CommunicationsAlarm Available} {{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589858} {PTP /rack=1/shelf=1/slot=1/domain=sdh/port=2}} Available}}
04/01/10:18:50:48 {Communications Alarm} {{{Probable Cause} 1376 Available} {{Event Time} {Wed, Nov 18, 2009 07:47:36 AM} Available} {{Specific Problem} {5523789 23015986 39792941 54015744} Available} {{Perceived Severity} Minor Available} {{Additional Text} {Huawei/T2000;589855;/rack=1/shelf=1/slot=1/domain=sdh/port=3
native ProbableCause=J0_MM,
service affecting=SA_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;TN_TNDM_31XXX_B01_W_L_HDXC001;/rack=1/shelf=1/slot=1/domain=sdh/port=3,
additionalInfo = AlarmSerialNo=25532028; AlarmReason=Trace identifier mismatch; ProductName=OptiX OSN 7500; EquipmentName=N2SLQ16; AffirmState=TRUE; DetailInfo=; ,
,
<ALM_ID>EMS Huawei/T2000 ManagedElement 589855 PTP /rack=1/shelf=1/slot=1/domain=sdh/port=3@#@1-87@#@TIM@#@22<ALM_ID>} Available} {{Additional Information} {} Available} {{Event Type} CommunicationsAlarm Available} {{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589855} {PTP /rack=1/shelf=1/slot=1/domain=sdh/port=3}} Available}}
04/01/10:18:50:48 {Communications Alarm} {{{Probable Cause} 30011 Available} {{Event Time} {Sun, Apr 5, 2009 05:23:01 PM} Available} {{Specific Problem} {4343122 23024452 39793968 56570157 70464000} Available} {{Perceived Severity} Critical Available} {{Additional Text} {Huawei/T2000;33554513;/rack=1/shelf=594997/slot=4/domain=wdm/port=4;/dsr=1
native ProbableCause=IN_PWR_LOW,
service affecting=SA_NON_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;MADURAI-TM;/rack=1/shelf=TN_MDRI_TN-06_M01_W_M_HOTMF03/slot=4/domain=wdm/port=4;/dsr=1,
additionalInfo = AlarmSerialNo=25558954; AlarmReason=Input power is too low; ProductName=OptiX BWS1600G; EquipmentName=TMX; AffirmState=TRUE; DetailInfo=; ,
,

This is the log i have in this each alram is sepearated by two commas(,) as you can see above
in this log i want to search particular alarm wit emsname for example in the first alarm "TN_CMBT_34XXX_M01_W_L_HDXC001" this is the ems name
so when i grep this log with this ems name i want whole alarm till that comma , how i have to search please help me

Code:
cat logfile | grep TN_CMBT_34XXX_M01_W_L_HDXC001

if i am doing like this i am getting only that particular line but i want the whole alram please help me

Last edited by Franklin52; 01-29-2010 at 01:55 PM.. Reason: Please use code tags!
# 2  
Old 01-29-2010
Code:
awk '/TN_CMBT_34XXX_M01_W_L_HDXC001/{f=1}
{a[NR%8]=$0}
f && /^,$/{for(i=1;i<8;i++){print a[i]}print;exit}' file

Use nawk or /usr/xpg4/bin/awk on Solaris if you get errors.
# 3  
Old 01-29-2010
Code:
awk ' {arr=length(arr) == 0 ? $0 : arr"\n"$0; if (/TN_CMBT_34XXX_M01_W_L_HDXC001/){flag=1}} 
$0 ~ "^,$" && flag { print arr; flag=0;arr="" } ' file

# 4  
Old 01-30-2010
hi franklin could you please explain your code

and do we have any one liners for that using "Strings command"

Thnaks for your help
# 5  
Old 01-30-2010
Quote:
Originally Posted by sridharragilla
hi franklin could you please explain your code

and do we have any one liners for that using "Strings command"

Thnaks for your help
What do you mean with "Strings command"?

Code:
awk '/TN_CMBT_34XXX_M01_W_L_HDXC001/{f=1}
{a[NR%8]=$0}
f && /^,$/{for(i=1;i<8;i++){print a[i]}print;exit}' file

Explanation:

Code:
awk '/TN_CMBT_34XXX_M01_W_L_HDXC001/{f=1}

  • Set a flag if the pattern is matched

Code:
{a[NR%8]=$0}

  • Fill the elements of the array, here a mod operator is used as index

Code:
f && /^,$/

  • If flag is set and the line contains only a comma

Code:
{for(i=1;i<8;i++){print a[i]}print;exit}' file

  • Print the array and exit

If the explanation above is unclear to you, you can have a read of one of the awk tutorials here:

https://www.unix.com/answers-frequent...tutorials.html
# 6  
Old 01-31-2010
Hi Frnaklin

i executed the given command by you
Code:
 
awk '/KA_SDBL_45XXX_S01_W_L_HDXC001/{f=1}
> {a[NR%8]=$0}
> f && /^,$/{for(i=1;i<8;i++){print a[i]}print;exit}' eventDump_jan04_hw_t2000_am.log
 
04/01/10:10:02:12 {Communications Alarm} {{{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589914} {PTP /rack=1/shelf=1/slot=5/domain=sdh/port=1}} Available} {{Event Type} CommunicationsAlarm Available} {{Event Time} {Mon, Jan 4, 2010 10:15:01 AM} Available} {{Probable Cause} Unknown Available} {{Specific Problem} {5590601 21251406 39078214 55133508 73348919 90124589 103954232} Available} {{Perceived Severity} Major Available} {{Additional Text} {Huawei/T2000;589914;/rack=1/shelf=1/slot=5/domain=sdh/port=1
native ProbableCause=SM_BEI,
service affecting=SA_NON_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;RJ_JIPR_90XXX_MXX_W_U_HDXC002;/rack=1/shelf=1/slot=5/domain=sdh/port=1,
additionalInfo = AlarmSerialNo=27545598; AlarmReason=Indication of OTU layer SM section BEI backward defect; ProductName=OptiX OSN 7500; EquipmentName=N1SF64; AffirmState=FALSE; DetailInfo=; ,
,
,


but in the output the regular expression was not found

Last edited by Scott; 01-31-2010 at 03:43 AM.. Reason: Code tags, please...
# 7  
Old 01-31-2010
Strange, this is what I get with the given input file:

Code:
$ awk '/TN_CMBT_34XXX_M01_W_L_HDXC001/{f=1}
{a[NR%8]=$0}
f && /^,$/{for(i=1;i<8;i++){print a[i]}print;exit}' file
<ALM_ID>EMS Huawei/T2000 ManagedElement 589865 PTP /rack=1/shelf=1/slot=11/domain=sdh/port=1 CTP /sts3c_au4-j=64@#@1-75@#@UNEQ@#@15<ALM_ID>} Available} {{Additional Information} {} Available} {{Event Type} CommunicationsAlarm Available} {{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589865} {PTP /rack=1/shelf=1/slot=11/domain=sdh/port=1} {CTP /sts3c_au4-j=64}} Available}}
04/01/10:18:50:48 {Communications Alarm} {{{Probable Cause} 1376 Available} {{Event Time} {Tue, Nov 17, 2009 09:31:33 PM} Available} {{Specific Problem} {5523789 23015986 39792941 54015744} Available} {{Perceived Severity} Minor Available} {{Additional Text} {Huawei/T2000;589858;/rack=1/shelf=1/slot=1/domain=sdh/port=2native ProbableCause=J0_MM,
service affecting=SA_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;TN_CMBT_34XXX_M01_W_L_HDXC001;/rack=1/shelf=1/slot=1/domain=sdh/port=2,
additionalInfo = AlarmSerialNo=25524438; AlarmReason=Trace identifier mismatch; ProductName=OptiX OSN 7500; EquipmentName=N2SLQ16; AffirmState=TRUE; DetailInfo=; ,
,
$ awk '/TN_TNDM_31XXX_B01_W_L_HDXC001/{f=1}
{a[NR%8]=$0}
f && /^,$/{for(i=1;i<8;i++){print a[i]}print;exit}' file
<ALM_ID>EMS Huawei/T2000 ManagedElement 589858 PTP /rack=1/shelf=1/slot=1/domain=sdh/port=2@#@1-87@#@TIM@#@22<ALM_ID>} Available} {{Additional Information} {} Available} {{Event Type} CommunicationsAlarm Available} {{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589858} {PTP /rack=1/shelf=1/slot=1/domain=sdh/port=2}} Available}}
04/01/10:18:50:48 {Communications Alarm} {{{Probable Cause} 1376 Available} {{Event Time} {Wed, Nov 18, 2009 07:47:36 AM} Available} {{Specific Problem} {5523789 23015986 39792941 54015744} Available} {{Perceived Severity} Minor Available} {{Additional Text} {Huawei/T2000;589855;/rack=1/shelf=1/slot=1/domain=sdh/port=3native ProbableCause=J0_MM,
service affecting=SA_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;TN_TNDM_31XXX_B01_W_L_HDXC001;/rack=1/shelf=1/slot=1/domain=sdh/port=3,
additionalInfo = AlarmSerialNo=25532028; AlarmReason=Trace identifier mismatch; ProductName=OptiX OSN 7500; EquipmentName=N2SLQ16; AffirmState=TRUE; DetailInfo=; ,
,
$ awk '/MADURAI-TM/{f=1}
{a[NR%8]=$0}
f && /^,$/{for(i=1;i<8;i++){print a[i]}print;exit}' file
<ALM_ID>EMS Huawei/T2000 ManagedElement 589855 PTP /rack=1/shelf=1/slot=1/domain=sdh/port=3@#@1-87@#@TIM@#@22<ALM_ID>} Available} {{Additional Information} {} Available} {{Event Type} CommunicationsAlarm Available} {{Managed Object} {{HW_T2000_Sys vtnoc_ns:.hw_t2000} {Managed_Element 589855} {PTP /rack=1/shelf=1/slot=1/domain=sdh/port=3}} Available}}
04/01/10:18:50:48 {Communications Alarm} {{{Probable Cause} 30011 Available} {{Event Time} {Sun, Apr 5, 2009 05:23:01 PM} Available} {{Specific Problem} {4343122 23024452 39793968 56570157 70464000} Available} {{Perceived Severity} Critical Available} {{Additional Text} {Huawei/T2000;33554513;/rack=1/shelf=594997/slot=4/domain=wdm/port=4;/dsr=1
native ProbableCause=IN_PWR_LOW,
service affecting=SA_NON_SERVICE_AFFECTING,
affectedTP list=,
nativeEMS Name=Huawei/T2000;MADURAI-TM;/rack=1/shelf=TN_MDRI_TN-06_M01_W_M_HOTMF03/slot=4/domain=wdm/port=4;/dsr=1,
additionalInfo = AlarmSerialNo=25558954; AlarmReason=Input power is too low; ProductName=OptiX BWS1600G; EquipmentName=TMX; AffirmState=TRUE; DetailInfo=; ,
,

Am I missing something?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help searching for dates - Oracle ALERT log

Hi, I am searching for some specific string in an Oracle DB alert log and then possibly print the latest date string that I can find that the error happen. I can't work out how to search for date strings more so searching in some specific direction, i.e backward or forward. At the moment,... (1 Reply)
Discussion started by: newbie_01
1 Replies

2. Shell Programming and Scripting

Searching Error Message from a log life between timestamp of every 10 minutes

HI Everyone, My task is to search error messages last 10 minutes everytime from a log file. My script, date1=`date -d '10 minutes ago' "+%H:%M:%S"` date2=`date "+%H:%M:%S"` awk -v d1="${date1}" -v d2="${date2}" '$0~d1{p=1} $0~d2{p=0} p' filename No error getting in... (3 Replies)
Discussion started by: ctscbe
3 Replies

3. UNIX for Dummies Questions & Answers

Get line numbers while searching the pattern in log

Hi Folks, I am searching for a pattern in logs through putty by opening the file in vi editor and reaching to the last of the file by $ and then searching the pattern , lets say I have to search the pattern abc then it would be ?abc Now I want line numbers along with the matching pattern to be... (3 Replies)
Discussion started by: SankalpS
3 Replies

4. UNIX for Dummies Questions & Answers

Regarding vi commands for searching something in Log

Hi Folks, Please advise me that I have to search some thing in log , I have reached to that Location through putty and I have opened that log file through putty with VI editor .. cd /var/abc.log tail -f abc.log vi abc.log and I see the logs but please advise me the commands..If I need to... (3 Replies)
Discussion started by: KAREENA18
3 Replies

5. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

6. Shell Programming and Scripting

Searching for a string in a log file with little movement

I have a script which tails a log file and if it finds certain strings in the data tailed it sends an email, basically like this: tail -f logfile > tmp.file & sleep 10 kill $! STRING=$(grep -c "string" tmp.file) && echo $STRING | mailx -s "Warning.." admin@123.com When the string is... (10 Replies)
Discussion started by: Moxy
10 Replies

7. Shell Programming and Scripting

searching a log file and appending to a .txt file

I'm new to shell scripting and am writing a script to help me log the free memory and hd space on a server. As of now, the script just runs 'df -h' and appends the output to a file and then runs 'top' and appends the output to a log file. What I want to do, is have the script also search the... (3 Replies)
Discussion started by: enator45
3 Replies

8. Linux

Searching for gaps in huge (2.2G) log file?

I've got a 2.2 Gig syslog file from our Cisco firewall appliance. The problem is that we've been seeing gaps in the syslog for anywhere from 10 minutes to 2 hours. Currently I've just been using 'less' and paging through the file to see if I can find any noticeable gaps. Obviously this isn't the... (3 Replies)
Discussion started by: deckard
3 Replies

9. Shell Programming and Scripting

help searching log file with dates

Im tyring to create a script that will show me any lines in a file with todays date and yesterdays, the date format in the file is as follows ----- amqxfdcx.c : 728 -------------------------------------------------------- 07/12/05 09:53:20 AMQ6109: An internal WebSphere MQ error has... (3 Replies)
Discussion started by: csaunders
3 Replies

10. Shell Programming and Scripting

Searching for multiple criteria in log files?

I would like a simple shell script that will allow me to display to screen all unsuccessful su attempts in my sulog file, for the present date. I have been trying several different combinations of commands, but I can't quite get the syntax correct. The mess I have right now (don't laugh) is... (4 Replies)
Discussion started by: Relykk
4 Replies
Login or Register to Ask a Question