Script to Gather data from logs and export to a CSV file

Greetings,

After a few hours of trial and error, I decide to ask for some help.

I am new to AWK and shell script, so please don't laugh :stuck_out_tongue:

I made the below script, to gather data from some logs and have the output into a CSV file :


#!/bin/sh
#Script to collect Errors

file="/Path/Errors_Report_$(date +%Y%m%d).csv"

DAY=`date +%d -d "Yesterday"`

#Header of the CSV file

echo -e "User_ID,Host_name,Date,Time,Code_302,Code_304,Code_305,Code_1,Code_2,Code_3,Code_7,Code_10,Code_18,Code_101,Code_201,Code_300,Code_301,Code_303,Code_306,Code_14,Code_9999,Code_19,Code_9,Code_11" > /path/Error_Report_$(date +%Y%m%d).csv

grep 'Pattern' Path/File_$(date +%Y%m%d)* |awk -F "|" '{if ($28~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$28; else if($29~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$29; else if($30~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$30}' | cut -d, -f1,2,10 | awk -F "," '{if ($3~/ Error1/) print $1","$2","302; else if ($3~/ Error2/) print $1","$2","304; else if ($3~/ Error3/) print $1","$2","305; else if ($3~/ Error4/) print $1","$2","1; else if ($3~/ Error5/) print $1","$2","2; else if ($3~/ Error6./) print $1","$2","3; else if ($3~/ Error7./) print $1","$2","7; else if ($3~/ Error 8/) print $1","$2","10; else if ($3~/ Error./) print $1","$2","18; else if ($3~/ Error 9/) print $1","$2","101; else if ($3~/ Error 10/) print $1","$2","201; else if ($3~/ Error11/) print $1","$2","300; else if ($3~/ Error12/) print $1","$2","301; else if ($3~/ Error13/) print $1","$2","303; else if ($3~/ Error14/) print $1","$2","306; else if ($3~/ Error15/) print $1","$2","14; else if ($3~/ Error16/) print $1","$2","9999; else if ($3~/ Error17./) print $1","$2","19; else if ($3~/ Error18/) print $1","$2","9; else if ($3~/ Error19/) print $1","$2","11}' | sort | uniq -c | awk -F" " '{print $1","$2}' |  awk -F "," '{if($4==302) print $2","$3","$1",,,,,,,,,,,,,,,,,,,"; else if($4==304) print $2","$3",,"$1",,,,,,,,,,,,,,,,,,"; else if($4==305) print $2","$3",,,"$1",,,,,,,,,,,,,,,,,"; else if($4==1) print $2","$3",,,,"$1",,,,,,,,,,,,,,,,"; else if($4==2) print $2","$3",,,,,"$1",,,,,,,,,,,,,,,"; else if($4==3) print $2","$3",,,,,,"$1",,,,,,,,,,,,,,"; else if($4==7) print $2","$3",,,,,,,"$1",,,,,,,,,,,,,"; else if($4==10) print $2","$3",,,,,,,,"$1",,,,,,,,,,,,"; else if($4==18) print $2","$3",,,,,,,,,"$1",,,,,,,,,,,"; else if($4==101) print $2","$3",,,,,,,,,,"$1",,,,,,,,,,"; else if($4==201) print $2","$3",,,,,,,,,,,"$1",,,,,,,,,"; else if($4==300) print $2","$3",,,,,,,,,,,,"$1",,,,,,,,"; else if($4==301) print $2","$3",,,,,,,,,,,,,"$1",,,,,,,"; else if($4==303) print $2","$3",,,,,,,,,,,,,,"$1",,,,,,"; else if($4==306) print $2","$3",,,,,,,,,,,,,,,"$1",,,,,"; else if($4==14) print $2","$3",,,,,,,,,,,,,,,,"$1",,,,"; else if($4==9999) print $2","$3",,,,,,,,,,,,,,,,,"$1",,,"; else if($4==19) print $2","$3",,,,,,,,,,,,,,,,,,"$1","; else if($4==9) print $2","$3",,,,,,,,,,,,,,,,,,,"$1","; else if($4==11) print $2","$3",,,,,,,,,,,,,,,,,,,,"$1}' | awk -F"," '{print "2001,Server1,"$1","$2":00:00,"$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14","$15","$16","$17","$18","$19","$20","$21","$22}' >> /Path/Error_Report_$(date +%Y%m%d).csv

The output is like below :


User_ID,Host_name,Date,Time,Code_302,Code_304,Code_305,Code_1,Code_2,Code_3,Code_7,Code_10,Code_18,Code_101,Code_201,Code_300,Code_301,Code_303,Code_306,Code_14,Code_9999,Code_19,Code_9,Code_11
2001,Server1,2016-11-18,00:00:00,,,,,,,,,,,,,,,,,,,,5
2001,Server1,2016-11-18,00:00:00,1,,,,,,,,,,,,,,,,,,,
2001,Server1,2016-11-18,00:00:00,,,,,,,,,,,,,,1,,,,,,
2001,Server1,2016-11-18,00:00:00,,,,,,,,,,,,,,,,,,,42,
2001,Server1,2016-11-18,01:00:00,,,,,,,,,,,,,,,,,,,,3
2001,Server1,2016-11-18,01:00:00,2,,,,,,,,,,,,,,,,,,,
2001,Server1,2016-11-18,01:00:00,,,,,,,,,,,,,,3,,,,,,
2001,Server1,2016-11-18,01:00:00,,,,,,,,,,,,,,,,,,,21,

The plan was to gather all data and have the amount of errors found from a given time in just one line like below, grouping by hours all errors in just one line :


User_ID,Host_name,Date,Time,Code_302,Code_304,Code_305,Code_1,Code_2,Code_3,Code_7,Code_10,Code_18,Code_101,Code_201,Code_300,Code_301,Code_303,Code_306,Code_14,Code_9999,Code_19,Code_9,Code_11
2001,smom01brb.rio.oi.ombr,2016-11-18,00:00:00,1,,,,,,,,,,,,1,,,,,,42,5

And that is what I am not able to achieve with my knowledge, which is very limited by the way.

How could I make the script output the information in the desired format ? All errors from a time set, just in one line, instead of one line from each errors counted ?

Any sugestion to fix the script I did are welcome and any other script which accomplish that is more than welcome.

Thanks for you time in reading my doubt / request and thanks in advanced for all sugestions.

That has to be close to the record for the longest 1-liner posted on this site.

I've formatted your posted code below to make it a little more readable.

Some questions:

1) Can you supply some example input.
2) Is " Pattern " fixed text or should this be an argument to your script?
3) Should "2001" and "Server1" be hard-coded in the final awk script, extracted from the input, sourced from a configuration file or passed as arguments to the script?

I feel the error strings you are searching for in the 3rd awk script in the process chain (eg "Error 10", "Error17.",etc) should be setup in a configuration file with pattern and output position. Perhaps something like this:

ERROR_PATTERN,OUTPUT_POSITION
Error1,1
Error 10,11
Error16,18
echo -e "User_ID,Host_name,Date,Time,Code_302,Code_304,Code_305,"\
"Code_1,Code_2,Code_3,Code_7,Code_10,Code_18,Code_101,Code_201,"\
"Code_300,Code_301,Code_303,Code_306,Code_14,Code_9999,Code_19,"\
"Code_9,Code_11" > /path/Error_Report_$(date +%Y%m%d).csv

grep 'Pattern' Path/File_$(date +%Y%m%d)* |awk -F "|" '{
     if($28~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$28;
else if($29~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$29;
else if($30~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$30}' |
cut -d, -f1,2,10 |
awk -F "," '{
     if ($3~/ Error1/)   print $1","$2","302;
else if ($3~/ Error2/)   print $1","$2","304;
else if ($3~/ Error3/)   print $1","$2","305;
else if ($3~/ Error4/)   print $1","$2","1;
else if ($3~/ Error5/)   print $1","$2","2;
else if ($3~/ Error6./)  print $1","$2","3;
else if ($3~/ Error7./)  print $1","$2","7;
else if ($3~/ Error 8/)  print $1","$2","10;
else if ($3~/ Error./)   print $1","$2","18;
else if ($3~/ Error 9/)  print $1","$2","101;
else if ($3~/ Error 10/) print $1","$2","201;
else if ($3~/ Error11/)  print $1","$2","300;
else if ($3~/ Error12/)  print $1","$2","301;
else if ($3~/ Error13/)  print $1","$2","303;
else if ($3~/ Error14/)  print $1","$2","306;
else if ($3~/ Error15/)  print $1","$2","14;
else if ($3~/ Error16/)  print $1","$2","9999;
else if ($3~/ Error17./) print $1","$2","19;
else if ($3~/ Error18/)  print $1","$2","9;
else if ($3~/ Error19/)  print $1","$2","11}' | sort | uniq -c |
awk -F" " '{print $1","$2}' |
awk -F "," '{
     if($4==302)  print $2","$3","$1",,,,,,,,,,,,,,,,,,,";
else if($4==304)  print $2","$3",,"$1",,,,,,,,,,,,,,,,,,";
else if($4==305)  print $2","$3",,,"$1",,,,,,,,,,,,,,,,,";
else if($4==1)    print $2","$3",,,,"$1",,,,,,,,,,,,,,,,";
else if($4==2)    print $2","$3",,,,,"$1",,,,,,,,,,,,,,,";
else if($4==3)    print $2","$3",,,,,,"$1",,,,,,,,,,,,,,";
else if($4==7)    print $2","$3",,,,,,,"$1",,,,,,,,,,,,,";
else if($4==10)   print $2","$3",,,,,,,,"$1",,,,,,,,,,,,";
else if($4==18)   print $2","$3",,,,,,,,,"$1",,,,,,,,,,,";
else if($4==101)  print $2","$3",,,,,,,,,,"$1",,,,,,,,,,";
else if($4==201)  print $2","$3",,,,,,,,,,,"$1",,,,,,,,,";
else if($4==300)  print $2","$3",,,,,,,,,,,,"$1",,,,,,,,";
else if($4==301)  print $2","$3",,,,,,,,,,,,,"$1",,,,,,,";
else if($4==303)  print $2","$3",,,,,,,,,,,,,,"$1",,,,,,";
else if($4==306)  print $2","$3",,,,,,,,,,,,,,,"$1",,,,,";
else if($4==14)   print $2","$3",,,,,,,,,,,,,,,,"$1",,,,";
else if($4==9999) print $2","$3",,,,,,,,,,,,,,,,,"$1",,,";
else if($4==19)   print $2","$3",,,,,,,,,,,,,,,,,,"$1",";
else if($4==9)    print $2","$3",,,,,,,,,,,,,,,,,,,"$1",";
else if($4==11)   print $2","$3",,,,,,,,,,,,,,,,,,,,"$1}' |
awk -F"," '{
  print "2001,Server1,"$1","$2":00:00,"$3","$4","$5","$6","$7",
  "$8","$9","$10","$11","$12","$13","$14","$15","$16","$17",
  "$18","$19","$20","$21","$22}' >>
  /Path/Error_Report_$(date +%Y%m%d).csv
1 Like

Thanks for replying back.

Answering your questions :

Some questions:

1) Can you supply some example input.

The information is gathered from a log entry similar to the one below, and there are millions of it per day :

2016-11-18 14:44:31,728:        |Thread_180|1|CUSTOMER_ID|B|UNIQUE_ID|ACT|A|null|1.99|MODE|mmp|2016-11-18 14:12:12.0|2016-11-18 14:12:12.0|null|0|R|0|1|null|N|-|-1|||null|SITE_NAME|[TID=3,1.99,,-,,,-,-ERROR_CODE,1,0.0,,,]|[CBCK=96,-,,,-#not required]|[BAL=100,1.99,,-,,,-,-#Continue,1,0.0,,,]|[CONTENT_ID=actinfo=MODE;null;null;IP;USER/protocolnumber;0000000000000000/,cosid:1]|[CAMPAIGN_ID=null]|[TOTAL_AMNT=null]|[RECO:refId=00000000-0000-0000-0000-000000000000,chrg_refid=000000000000000000]|[TSK = Q,0,00,2016-11-19 14:12:12.0,2016-11-18 14:12:12.0]

2) Is " Pattern " fixed text or should this be an argument to your script?

"Pattern" is what I want to grep, it is the "TID" I marked in red on the log example above.

3) Should "2001" and "Server1" be hard-coded in the final awk script, extracted from the input, sourced from a configuration file or passed as arguments to the script?

Yes. They are fixed value. This script will run in multiple servers, and in each server this information is different. In this case I pass this information here :

print "2001,Server1...

Talking about the code.

The first part the one starting with the :

"Echo -e"

is the header of the CSV file.

So I must keep this.

The first part of the script starting here :

grep 'Pattern' Path/File_$(date +%Y%m%d)*

...

Is where I grep all varitions of this :

[CHG=3,1.99,,-,,,-,-ERROR_CODE,1,0.0,,,]

ERROR_CODE will vary from case to case, there are several error, some of short description and other with a long description.

The Second Part :

 awk -F "," '{
     if ($3~/ Error1/) 

Going from Error1 to Error19 is where I count the errors, based on the description.

And third part :

awk -F "," '{
     if($4==302) 

Is where my doubts start. Here is where I pass the format to a CSV file . here :

else if($4==11)   print $2","$3",,,,,,,,,,,,,,,,,,,,"$1}' |

Is where I pass the amount of "Error 11" to the last position of the output file.

And the last part :

awk -F"," '{
  print "2001,Server1,"$1","$2":00:00...

Is where I count all errors I gathered, considering that 2001, server1 are fixed and the :00:00 is the time.

I will upload one sample of the report.

And sorry for the long post. I just tried to put as much information as I could.

This might get you started.

It uses a file called cfg which will contain your error codes along with their output position and column heading.

For testing I used this:

TEST,2,Code_304
THIS,3,Code_305
ERROR_CODE,12,Code_300
THAT,20,Code_11

Program is a follows:

PAT="TID"
SERV="2001,Server1"

awk -v PAT="$PAT" -v SERV="$SERV" -F "," '
FNR==NR{ P[$2]=$1 ; Heading[$2]=$3; FldMax=$2>FldMax?$2:FldMax ; next }
$0 ~ PAT {

   DTM=$1
   #Truncate Mins and Secs from DTM - we want totals per hour
   gsub(/:.*/,":00:00",DTM)

   #replace space between date and time with comma
   gsub(/ /,",",DTM)

   #build list of date/times we found in the log
   if (!(DTM in D)) {
      D[DTM];Times[++L]=DTM
   }
   # Test fields 28 thru 30 for PAT match and count per DTM value
   for(i=28;i<30;i++)
     if ($i ~ PAT) {
        split(substr($1,74,10)","substr($1,85,2)","$i, V, ",");
        for(j in P) if (V[10] ~ P[j]) {
             C[DTM,j]++
             next
        }
        next
     }
}
END {
  printf "%s","User_ID,Host_name,Date,Time"
  for(field=1;field<=FldMax;field++)
     printf ",%s", Heading[field]
  printf "\n"
  for(line=1;line<=L;line++) {
    printf "%s,%s",SERV,Times[line];
    for(field=1;field<=FldMax;field++)
       printf ",%s",C[Times[line],field]
       printf "\n"
  }
}' cfg FS="|" ./File_$(date +%Y%m%d)* > ./Error_Report_$(date +%Y%m%d).csv

With this input:

2016-11-18 14:44:31,728:        |Thread_180|1|CUSTOMER_ID|B|UNIQUE_ID|ACT|A|null|1.99|MODE|mmp|2016-11-18 14:12:12.0|2016-11-18 14:12:12.0|null|0|R|0|1|null|N|-|-1|||null|SITE_NAME|[TID=3,1.99,,-,,,-,-ERROR_CODE,1,0.0,,,]|[CBCK=96,-,,,-#not required]|[BAL=100,1.99,,-,,,-,-#Continue,1,0.0,,,]|[CONTENT_ID=actinfo=MODE;null;null;IP;USER/protocolnumber;0000000000000000/,cosid:1]|[CAMPAIGN_ID=null]|[TOTAL_AMNT=null]|[RECO:refId=00000000-0000-0000-0000-000000000000,chrg_refid=000000000000000000]|[TSK = Q,0,00,2016-11-19 14:12:12.0,2016-11-18 14:12:12.0]
2016-11-18 14:50:31,728:        |Thread_180|1|CUSTOMER_ID|B|UNIQUE_ID|ACT|A|null|1.99|MODE|mmp|2016-11-18 14:12:12.0|2016-11-18 14:12:12.0|null|0|R|0|1|null|N|-|-1|||null|SITE_NAME|[TID=3,1.99,,-,,,-,-ERROR_CODE,1,0.0,,,]|[CBCK=96,-,,,-#not required]|[BAL=100,1.99,,-,,,-,-#Continue,1,0.0,,,]|[CONTENT_ID=actinfo=MODE;null;null;IP;USER/protocolnumber;0000000000000000/,cosid:1]|[CAMPAIGN_ID=null]|[TOTAL_AMNT=null]|[RECO:refId=00000000-0000-0000-0000-000000000000,chrg_refid=000000000000000000]|[TSK = Q,0,00,2016-11-19 14:12:12.0,2016-11-18 14:12:12.0]
2016-11-18 14:54:31,728:        |Thread_180|1|CUSTOMER_ID|B|UNIQUE_ID|ACT|A|null|1.99|MODE|mmp|2016-11-18 14:12:12.0|2016-11-18 14:12:12.0|null|0|R|0|1|null|N|-|-1|||null|SITE_NAME|[TID=3,1.99,,-,,,-,-THIS,1,0.0,,,]|[CBCK=96,-,,,-#not required]|[BAL=100,1.99,,-,,,-,-#Continue,1,0.0,,,]|[CONTENT_ID=actinfo=MODE;null;null;IP;USER/protocolnumber;0000000000000000/,cosid:1]|[CAMPAIGN_ID=null]|[TOTAL_AMNT=null]|[RECO:refId=00000000-0000-0000-0000-000000000000,chrg_refid=000000000000000000]|[TSK = Q,0,00,2016-11-19 14:12:12.0,2016-11-18 14:12:12.0]
2016-11-18 14:55:31,728:        |Thread_180|1|CUSTOMER_ID|B|UNIQUE_ID|ACT|A|null|1.99|MODE|mmp|2016-11-18 14:12:12.0|2016-11-18 14:12:12.0|null|0|R|0|1|null|N|-|-1|||null|SITE_NAME|[TID=3,1.99,,-,,,-,-THAT,1,0.0,,,]|[CBCK=96,-,,,-#not required]|[BAL=100,1.99,,-,,,-,-#Continue,1,0.0,,,]|[CONTENT_ID=actinfo=MODE;null;null;IP;USER/protocolnumber;0000000000000000/,cosid:1]|[CAMPAIGN_ID=null]|[TOTAL_AMNT=null]|[RECO:refId=00000000-0000-0000-0000-000000000000,chrg_refid=000000000000000000]|[TSK = Q,0,00,2016-11-19 14:12:12.0,2016-11-18 14:12:12.0]
2016-11-18 16:44:31,728:        |Thread_180|1|CUSTOMER_ID|B|UNIQUE_ID|ACT|A|null|1.99|MODE|mmp|2016-11-18 14:12:12.0|2016-11-18 14:12:12.0|null|0|R|0|1|null|N|-|-1|||null|SITE_NAME|[TID=3,1.99,,-,,,-,-THAT,1,0.0,,,]|[CBCK=96,-,,,-#not required]|[BAL=100,1.99,,-,,,-,-#Continue,1,0.0,,,]|[CONTENT_ID=actinfo=MODE;null;null;IP;USER/protocolnumber;0000000000000000/,cosid:1]|[CAMPAIGN_ID=null]|[TOTAL_AMNT=null]|[RECO:refId=00000000-0000-0000-0000-000000000000,chrg_refid=000000000000000000]|[TSK = Q,0,00,2016-11-19 14:12:12.0,2016-11-18 14:12:12.0]

I got this output

User_ID,Host_name,Date,Time,,Code_304,Code_305,,,,,,,,,Code_300,,,,,,,,Code_11
2001,Server1,2016-11-18,14:00:00,,,1,,,,,,,,,2,,,,,,,,1
2001,Server1,2016-11-18,16:00:00,,,,,,,,,,,,,,,,,,,,1
1 Like

Thank you very much for the code and sorry for the delay .

Your code is light years ahead of anything I did in awk, actually my awk knowledge is limited to �print $�.

And after a few hours trying to make your code work, unfortunately I it did not run here.
Probably I did not understand you code properly, but I am getting this :

awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F "," '
awk: billing_errors.awk:10:           ^ syntax error
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F "," '
awk: billing_errors.awk:10:                          ^ syntax error
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F "," '

removing the � from here :

awk -v PAT="$PAT" -v SERV="$SERV" -F "," '

gave another errors :

awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F ","
awk: billing_errors.awk:10:           ^ syntax error
awk: billing_errors.awk:10: awk -v PAT="$PAT" -v SERV="$SERV" -F ","
awk: billing_errors.awk:10:                          ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:    ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                  ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                             ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                                                                               ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                                                                       ^ syntax error
awk: billing_errors.awk:47: } cfg FS="|" /var/log/ERROR..log > /var/report/Billing_Errors_$(date +%Y%m%d).csv
awk: billing_errors.awk:47:                                                                             ^ syntax error

I created a cfg file , following your instructions and the file is in the same path as the script.

Probably I did something wrong, but could you please advise what I did wrong and where I will inform to use the cfg file and from where it will read.

Thanks again.

What I guess you have done is to copy and past this shell script into a file you named billing_errors.awk and then ran it with awk -f or #!/usr/bin/awk

The code block under "Program is as follows" in my post above is a shell script that invokes awk from line 4. Sorry for the confusion, I should have started it with #!/bin/sh to make that clear.

Save the script as billing_errors.sh and run it within a shell.

1 Like

Now it ran smoothly but it did not bring the output, actually it found nothing ...

Probably I messed with files, so if you could be kind and explain one more thing :

Here :

}' cfg FS="|" ./File_$(date +%Y%m%d)* > ./Error_Report_$(date +%Y%m%d).csv

The cfg is the file in which I put the errors right and the ./File_$(date +%Y%m%d)* will be the log files in which it will look for the parameter ?

Because it is taking forever to run or is not bringing any result when depending of the file I mentioned there.

Thanks again !

Yes cfg is the configuration file. also not I change the full path to ./ while testing here so it is currently looking for ./File_YYYMMDD* input files not /path has you originally had.

Have you checked the Error_Report_YYYMMDD.csv file?

When you say nothing is appearing does that include the headings?

If you are just getting headings and not data records, this means the your Pattern set on line 1 in PAT variable is not matching any line.

If you get lines with all blank totals then PAT matches the line fields 28-30 mismatch OR no error codes match.

1 Like

Another thought, if it is not completing and you are sending files with millions of records, try a single smaller test file first.

Got it.

All clear. Using the same criteria as yours I manage to achieve the desired output. A few lines of the code is very complex, but will help me improve.

I just need to do some small changes and the report will be perfect.

I am considering this as Solved. And I really appreciate your help .

Once again, thank you very much.

---------- Post updated at 04:21 AM ---------- Previous update was at 12:56 AM ----------

Just another question.

Script is working properly, but I don't know how to avoid this line :

2001,Server1,TIMESTAMP:00:00,,,,,,,,,,,,,,,,,,,,
2001,Server1,2016-11-21,20:00:00,,,,,,,,,,,,,,,,,,,,
2001,Server1,2016-11-21,21:00:00,,,,,,,,,,,,,,,,,,,,

Any ideia ?

Thanks again !