Page 1 of 1

send logfiles via TI Process

Posted: Tue Mar 13, 2012 10:49 am
by Christian Koenig
Dear all,

again a Question from my side and again hope that someone can help me. As you can see below I have a Process who is sending and email over commandline. Ecerything is working fine with this line.


name = 'Load_DIM_All_2_0_Create_Default_Subset';
logname = 'C:\cpm\TM1Data\atpissw_fap\TM1ProcessError_20120312105347_Load_DIM_All_2_0_Create_Default_Subset.log';

#*** with Attachement (the original Username and Password is replaced with * in this tread)
executecommand('C:\Programme\MDRApps\SMTPSEND\smtpsend.exe /MailServer=smtp.gmx.net /Port=25 /UserName=************ /Password=************ /From=pitagora@gmx.at /Subject="Error in process ' | name | ' !" /Body=error /To=christian.koenig@pitagora.at /Attachment="' | logname | '"',0);

My Problem is now follow:
You can see that i attache the Logfile from called "TM1ProcessError_20120312105347_Load_DIM_All_2_0_Create_Default_Subset.log". But In my Situation the name ot the logfile is everytime different becuase there is a Timestamp in the name "TM1ProcessError_20120312105347_Load_DIM_All_2_0_Create_Default_Subset.log"
How i can find out now what my last logfile is.
Or is it possible to deactivate the Timestamp in the Logfile name?

Hope my describtion of the Situation it is clear enought

Chris

Re: send logfiles via TI Process

Posted: Tue Mar 13, 2012 11:34 am
by rmackenzie
Christian Koenig wrote:How i can find out now what my last logfile is.
This function should help you.

Re: send logfiles via TI Process

Posted: Tue Mar 13, 2012 2:27 pm
by Christian Koenig
thx to rmackenzie. Here the final code which is working now

#****Begin: Generated Statements***
#****End: Generated Statements****

#*** Variable for smtpsend (smtpsend Version 8.0.0.3)

vsmtppath = 'C:\Programme\MDRApps\SMTPSEND\smtpsend.exe';
vsmtp = 'smtp.gmx.net';
vport = '25';
vusername = 'pitagora@gmx.at';
vpassword = 'pitagora';
vemailfrom = 'pitagora@gmx.at';
vemailto = 'christian.koenig@pitagora.at';

name = 'Load_DIM_All_2_0_Create_Default_Subset';
logfile = WildcardFileSearch( 'C:\cpm\TM1Data\log\TM1ProcessError_??????????????_Load_DIM_All_2_0_Create_Default_Subset.log', '');
logname = 'C:\cpm\TM1Data\log\'|logfile;

# ASCIIOUTPUT('c:\asci.txt', logfile, logname);

#*** Mit Attachement
executecommand('"' | vsmtppath | '" /MailServer="' | vsmtp | '" /Port="' | vport | '" /UserName="' | vusername | '" /Password="' | vpassword | '" /Fro
m="' | vemailfrom | '" /Subject="Error in process ' | name | ' !" /Body="Error in TM1 - Process ' | name | ' !" /To="' | vemailto | '" /Attachment= "'
| logname | '"',0);

#*** Logfiles verschieben. Der folgende Prozess verschiebt alle Logfiles von Folder "Log" nach "LogOld"
# ausser "Tm1s.log und TM1Server.log
executecommand('xcopy.bat',0);

Re: send logfiles via TI Process

Posted: Tue Mar 13, 2012 3:55 pm
by lotsaram
Gruss Chris,

You might want to consider 2 things:
1/ A while loop when getting the log file name and sending email notification of the error log in case multiple error logs are produced or this "notify and sweep" process was not triggered when the last process error log was produced. Otherwise you will miss notifying some logs
2/ If you do go for the while loop then make sure it has some kind of escape counter, otherwise if anything goes wrong with the xcopy move then the WildcardFileSearch will keep finding the same file over and over and sending the same email over and over and because TI is quite fast this will quickly create hundreds of thousands of emails or in other words an internal email server denial of service attack which your customer's IT department will not be too pleased about :lol: (actually exactly this happened once to one of my consultants :oops: )