The Problem that I am having is when the code ran and populated the progflag.csv file, columns MEMSIZE, SECOND and SASEXE were blank. The next problems are the IF else statement isn't working and the email function isn't sending the progflag.csv attachment.
a. What I want the program to do is to only read in all files that have a
.log. extension. There other files in the same directory with different extension such as .html, and .ksh,
There are four steps that occur when the program output data to progflag.csv (data comes from multiple log files that are read in by the program):
1 for example if the following criteria in file12.log.20163005 doesn't exist, such as MEMSIZE , a directory path will the text /SASFoundation and the variable Real Time row value(Real Time 0.1) is less than 1.0, no data is outputted to progflag.csv .
-
if in file9.log.20163005, the following variables and values exist for example "MEMSIZE=200" and variable Real Time (Real Time 4.0) row value is More than 1.0, output the values and the column names to the proflag.csv.
-
if in file25.log.20163005, for example there is a directory path will text /SASFoundation and the variable Real Time (Real Time 0.2) row value is less than 1.0, output the values and its column name to the proflag.csv
An example in the progflag.csv results from the steps are as follows:
MEMSIZE SECOND SASEXE filename:
200 4.0 file1.log.20163005
SASFoundation file25.log.20163005
- last, step only send an email if progflag.csv file rows are populated.
Here is the code:
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]}
BEGIN {
printf "MEMSIZE\tSECOND\tSASEXE\tFilename\n"
for(i=split("memsize ,Real Time ,SASFoundation",A,",");i;i--) L[A]=i
}
FNR==1 {
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{pr()}
if MEMSIZE OR SECOND >1.0 OR SASEXE AND Filename then
' *.log.* > progflag.csv
[ -s progflag.csv ] && mailx -s "subject text -a "Programs flagged" receiver@domain.com < progflag.csv
ELSE ''