Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Search for selected keywords and its values in multiple log files

  Asked By: Della    Date: Jun 01    Category: Unix / Linux / Ubuntu    Views: 8613

I have several problems with my problems: I hope you can help me.

1) the If else statement isn't working . The IF Else syntax is:

If MEMSIZE OR sasfoundation (SASEXE) OR Real Time(second) >1.0 and Filename, output column name and value to csv or else nothing

Example progflag.cvs:

Memsize Second SASEXE filename
400 4.0 SASFoundaion file11.log.20120314

2) I am not getting any data in the csv file

3) The email syntax isn't working. I am not receiving the cvs file attachment via email

My program read in multiple files with .log, extension. For example file12.log.20120314. The program search for 3 selected items in each log files.

Item 1# : Memsize . Memsize statement stores numeric values. For example memsize=400. the program output the column name (memsize) and its value and the filename to a csv file

example - progflag.csv:
memsize filename
400 file12.log.20120314

Item 2# : Real Time; row value. For example, the row value for Real Time is 4.0. Real Time : 4.0.
In my program Real Time is named Second. For example, SECOND stores 4.0. IF SECOND > 1.0 then output the column name and its value to a cvs file

example - progflag.csv:

Second filename
4.0 file11.log.20120314

If Real Time row value is less than 1.0 then output no data to the cvs file.

Example Real Time: 0.2 0.2 is less than 1.0

item3#: if the program find the directory path /SASFoundation (SASEXE) then output the directory path to a cvs file

Example progflag.cvs

Second SASEXE filename
4.0 SASFoundaion file11.log.20120314

Here is my program:

cd /tmp/*.log.*
awk -F '[=:;.]' '
function pr() {if(NR>1) printf "%s\t%s\t%s\t%s\n", K[1],K[2],K[3],K[0]}
printf "MEMSIZE\tSECOND\tSASEXE\tFilename\n"
for(i=split("memsize ,Real Time ,SASFoundation",A,",");i;i--) L[A[i]]=i
FNR==1 {
$1 in L {v=$2;gsub("^[/ ]*","",v);gsub(/ *$/,"",v);K[L[$1]]=v}
{if ($1 || $2>1.0 || $ 3 && $0) printf $1 "\t" $2 "\t"" $3"\t" $0"\t; elseif($2>1.0 else print ''}'
' *.log.* > progflag.csv

[ -s progflag.csv ] && mailx -s "subject text -a "Programs flagged" receiver@domain.com < progflag.csv



No Answers Found. Be the First, To Post Answer.