Sending email on failure of TI process

Post Reply
aagrawal12
Posts: 21
Joined: Thu Nov 05, 2009 8:56 am
OLAP Product: TM1
Version: 9.4.1 9.5.1 9.5.2 and 10.2.2
Excel Version: 2003 2007 and 2010

Sending email on failure of TI process

Post by aagrawal12 »

Hi,
Can anybody plz tell me how to configure the TI for getting a mail of failure of TI process

Thanks in advance,
Abhishek
User avatar
jim wood
Site Admin
Posts: 3958
Joined: Wed May 14, 2008 1:51 pm
OLAP Product: TM1
Version: PA 2.0.7
Excel Version: Office 365
Location: 37 East 18th Street New York
Contact:

Re: Sending email on failure of TI process

Post by jim wood »

The work around we use is that we use SQL to control all of our schedules. If that fails it sends out an email,

Jim.

(Bit of a cheat I know but we handle a large amount of data each week and completing any tranformations in SQL has decreased the schedule run time by around an hour.)
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
aagrawal12
Posts: 21
Joined: Thu Nov 05, 2009 8:56 am
OLAP Product: TM1
Version: 9.4.1 9.5.1 9.5.2 and 10.2.2
Excel Version: 2003 2007 and 2010

Re: Sending email on failure of TI process

Post by aagrawal12 »

hi jim,
can u guide how can we use sql to montior the TI process
Any help would be useful.

Thanks,
Abhishek
Railroader
Posts: 3
Joined: Wed Aug 05, 2009 4:15 pm
OLAP Product: TM1
Version: 9.4 MR1
Excel Version: 2007

Re: Sending email on failure of TI process

Post by Railroader »

We user Microsoft Operations Manager with a service that monitors the logs folder
lotsaram
MVP
Posts: 3702
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Sending email on failure of TI process

Post by lotsaram »

The best solution is probably external to TM1 with batch scheduling and control software such as Tivoli, Control M or Operations Manager but for companies without such a solution it can be done all within TM1 using a combination of TI, batch files or vb script and an email executable.

There are 2 basic approaches which are generally used and probably many variations thereof:
1/ "Alerting for specific process errors"
- Call the process with ExecuteProcess
- Check the ProcessReturnCode
- If not ProcessExitNormal (such as ProcessExitSeriousError) then send an email

2/ "Scanning the logging directory for process error logs"
- Use a TI with WildcardFileSearch to regularly (hourly, daily, etc.) scan the logging directory for files matching "TM1ProcessError*.log"
- when a file is found send an email to the TM1 admin with the name of the TI process, maybe attach the log file to the email
- move the process error log files for which mails have been dispatched to another directory to prevent emailing again for the same log file

That should give you something to go on ...
dfrench77
Posts: 52
Joined: Thu Feb 17, 2011 2:52 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2007

Re: Sending email on failure of TI process

Post by dfrench77 »

Lotsaram,

I am trying to implement this solution and I am stuck at the 2nd step.
2/ "Scanning the logging directory for process error logs"
- Use a TI with WildcardFileSearch to regularly (hourly, daily, etc.) scan the logging directory for files matching "TM1ProcessError*.log"
- when a file is found send an email to the TM1 admin with the name of the TI process, maybe attach the log file to the email
- move the process error log files for which mails have been dispatched to another directory to prevent emailing again for the same log file
My code in TI is as follows in the Epilog:

Code: Select all

file = WildcardFileSearch( 'C:\TM1Files\Logs\TM1ProcessError_2012*load*.log', ' ');


ExecuteCommand('C:\SendEmail\sendEmail.exe -f fromemail@xxxx.com -t toemail@xxx.com -s emailserver -u file -m Testing Email Message', 0);

AsciiOutput('email_test.txt', file);
My 1st question:
This code works fine. I receive email but the Subject line does is not the TM1ProcessError_2012*load*.log file name. It is just file. However my Asciiuotput file provides the file name. How can I get the file name in the subject line of the email?

My 2nd question:
How would you attach a file to the email message? Has anyone done this?

Thanks,

dfrench77
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Sending email on failure of TI process

Post by Duncan P »

You need to get the name of the file into the command line. The TI function to do this is EXPAND (http://publib.boulder.ibm.com/infocente ... xpand.html).

Try

Code: Select all

file = WildcardFileSearch( 'C:\TM1Files\Logs\TM1ProcessError_2012*load*.log', ' ');
command = EXPAND( 'C:\SendEmail\sendEmail.exe -f fromemail@xxxx.com -t toemail@xxx.com -s emailserver -u "%file%" -m "Testing Email Message"'

ExecuteCommand(command, 0);

AsciiOutput('email_test.txt', file);
dfrench77
Posts: 52
Joined: Thu Feb 17, 2011 2:52 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2007

Re: Sending email on failure of TI process

Post by dfrench77 »

Duncan,

Thanks the code work perfectly. I have used the expand function before in an export to ODBC tables.

Can you help with my 2nd question?
How would you attach a file to the email message? Has anyone done this?
Regards,

dfrench77
lotsaram
MVP
Posts: 3702
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Sending email on failure of TI process

Post by lotsaram »

The issue as Duncan pointed out is that you are passing in the literal string "file" and not the value of the string variable. This can also be done without using Expand just with concatenating.

Code: Select all

file = WildcardFileSearch( 'C:\TM1Files\Logs\TM1ProcessError_2012*load*.log', ' ');
command = 'C:\SendEmail\sendEmail.exe -f fromemail@xxxx.com -t toemail@xxx.com -s emailserver -u ' | file | '-m Testing Email Message';

ExecuteCommand(command, 0);

AsciiOutput('email_test.txt', file);
Is that the actual code you are using? Because unless your email address is toemail@xxx.com I don't see how you would be receiving anything.

To create an attachment will depend on the command line reference of the particular email utility you are using for sendemail.exe I think it is -a and you would need to pass in the full path and filename. (it doesn't look like you are trying too hard here as all that's needed is a quick look at the documentation of the email utility, you might want to brush up on the request for assistance guidelines. I know you are an accountant as opposed to a consultant but still we're not here to just do it for you.)

Presumably you are going to put your emailing code within a while loop so that you pass the last file found into WildcardFileSearch to return all matching files in sequence. When you do this don't forget you need to move the error log file somewhere else as well with a separate ExecuteCommand to a batch file otherwise you will find that our process is just continually sending an email notifying of the same file or files.
dfrench77
Posts: 52
Joined: Thu Feb 17, 2011 2:52 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2007

Re: Sending email on failure of TI process

Post by dfrench77 »

Lotsaram,

Thanks for the pointer on the concatenation. No, toemail@xxx.com is not my email account. It will be replaced with appropriate email.

Regarding the -a for file, you are correct, as usual, it is documented in the utility. Reading is essential, I heard :D. To my defense, I scanned the documentation looking for attachment, instead reading and looking for file attachment.

Yes, my plan based on the research I have done in the forum, bihints, tm1-tutorals, etc.., is to use the move command to move the old log files to a another directory.

Thanks for you the assistance.

Regards,

dfrench77
dfrench77
Posts: 52
Joined: Thu Feb 17, 2011 2:52 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2007

Re: Sending email on failure of TI process

Post by dfrench77 »

I am back. I have come to another stumbling block.

I am using the ExecuteCommand in a TI statement to execute the move command to move a log file to another folder. Below is the code:

Code: Select all

MoveCmd= 'move'|' ' | EXPAND('C:\TM1Files\TM1_Logs\file%') | ' '| EXPAND('C:\TM1Files\TM1_Logs\Old_TM1ProcessErrorLogs\%file%');  

AsciiOutput('email_test.txt',MoveCmd);

ExecuteCommand(MoveCmd, 0);
I receive the following error when executing this command in TI.

Error: Epilog procedure line (33): The system cannot find the file specified.

Below is the output of the AsciiOutput file:

move C:\TM1Files\TM1_Logs\TM1ProcessError_20120730174524_load_budget_to_forecast.log C:\TM1Files\TM1_Logs\Old_TM1ProcessErrorLogs\TM1ProcessError_20120730174524_load_budget_to_forecast.log

When I execute this command in the command prompt window it executes successfully and moves the specified file.

Can anyone tell me why the command is failing in TI but executing successfully in command prompt window?

Thank you,

dfrench77
Duncan P
MVP
Posts: 600
Joined: Wed Aug 17, 2011 1:19 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2
Excel Version: 2003 2007
Location: York, UK

Re: Sending email on failure of TI process

Post by Duncan P »

ExecuteCommand can only execute programs. move is not a program but an intrinsic command of the command shell. The easiest way to get round this is to create a batch file called move.bat containing the line

Code: Select all

move %1 %2
and then call it using e.g.

Code: Select all

ExecuteCommand( 'c:\tm1files\move.bat c:\tm1files\tm1_logs\' | file | ' c:\tm1files\tm1_logs\old_tm1processerrorlogs\' | file );
Unfortunately you will get a window popping up. We have not found a way of preventing this. If anyone knows how, please share.
dfrench77
Posts: 52
Joined: Thu Feb 17, 2011 2:52 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2007

Re: Sending email on failure of TI process

Post by dfrench77 »

Duncan,

Thank for your assistance. The code is working! I used the switch /y after the move command (i.e., move /Y %1 %2) and I am not getting a pop up window prompting. This may be the solution for the window popping up, someone please confirm.

Thanks again,

dfrench77
User avatar
Harvey
Community Contributor
Posts: 236
Joined: Mon Aug 04, 2008 4:43 am
OLAP Product: PA, TM1, CX, Palo
Version: TM1 8.3 onwards
Excel Version: 2003 onwards
Contact:

Re: Sending email on failure of TI process

Post by Harvey »

I'm currently working on a Flow solution to this problem.

Our solution involves generating an instruction file from TI using ASCIIOUTPUT and moving it into a queue folder. The file contains all the information required to generate the notification email by event type.

The Flow Responder Windows Service monitors this folder and detects when a new file is found there. It then consumes the file and generates a notification email.

Responder implements a plugin architecture, so you could do a lot more with it than just generate an email. I think it's a pretty powerful platform and opens up some very cool options for TI that are difficult to achieve any other way.

Anyway, I'll be releasing this soon, but if anyone on this thread would be interested to try out what I have, let me know and I'll send you the installer and some instructions.
Take your TM1 experience to the next level - TM1Innovators.net
Post Reply