LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 06-04-2016, 10:00 PM   #1
dfn
LQ Newbie
 
Registered: Sep 2015
Posts: 7

Rep: Reputation: Disabled
Search for keywords and its values from multiple log files


My program searches for certain keywords and its values from multiple log files and output the information to a text file and sends email.

One of the Keyword is name real time . if real time row value in the log files is greater than 5:00:00 than output the column name and its value and the filename to progflag.log

In progflag.txt, I am getting headers with no column values.

Code:
MEMSIZE SECOND   SASEXE   FILENAME
Here is what the output results need to show in progflag.txt

Code:
MEMSIZE   SECOND     SASEXE             Filename
200                                     SASFoundation_MEMSIZE.log                       
400       06:00:00   SASFoundation       GT_5hr.log
In the below example, there should be only 2 filenames in the progflag.txt and not three. no_SASFoundation_no_MEMSIZE.log doesn't meet the criteria so there shouldn't be any data for this file in progflag.csv.

[/CODE]
#!/bin/bash

Code:
cd /log/tmp/*.log | awk -F '[=:]' '
  function pr() {printf FORMAT, K[1],K[2],K[3],K[0]}
  BEGIN {FORMAT="%s\t%s\t%16s\t%s\n"
      printf FORMAT, "MEMSIZE","SECOND","SASEXE","Filename\n"
        for(i=split("/Memsize/ $2, ,/Real Time/ $2 ,/SASFoundation/ $3",A,",");i;i--) L[A[i]]=i
      FORMAT="%s\t%.1f\t%16s\t%s\n"
  }
  FNR==1 {
      if(K[1] || K[2]>'5:00:00' || K[3]) pr()
       K[0]=FILENAME
      K[1]=K[2]=K[3]=x
  }
  $1 in L {v=$2;gsub("^[/ ]*","",v);gsub(/ *$/,"",v);K[L[$1]]=v}
  END{if(K[1] || K[2]>'5:00:00' || K[3]) pr()}' *.log > progflag.txt

[ -s progflag.txt ] && mailx -s "subject text" -a  progflag.txt receiver@domain.com < "Code Need to be Evaluated"
Attached Files
File Type: log no_SASFoundation_no_MEMSIZE.log (1.0 KB, 10 views)
File Type: log SASFoundation_MEMSIZE.log (1.1 KB, 10 views)
File Type: log more_than_5_hr.log (1.1 KB, 11 views)
File Type: txt progflag.txt (166 Bytes, 7 views)

Last edited by dfn; 06-04-2016 at 10:03 PM.
 
Old 06-05-2016, 11:00 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,851
Blog Entries: 1

Rep: Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868Reputation: 1868
First problem in your code: cd /log/tmp/*.log
 
Old 06-06-2016, 08:25 AM   #3
dfn
LQ Newbie
 
Registered: Sep 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Analog log file analyzer / search engine keywords AdultFoundry Linux - Server 0 01-01-2016 10:49 AM
Multiple values in a search option gene.rye Linux - Newbie 3 11-29-2010 10:13 AM
grep multiple values in single pass through log file. 1ankit1 Programming 2 11-13-2010 04:45 PM
Search values within multiple files line to line Chrizzieej Programming 5 09-26-2008 04:11 PM
Sarch files for multiple keywords with AND titopoquito Linux - Software 4 03-06-2005 07:51 AM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 10:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration