I have a log file that is 80,000kb so it's quite large.
This log file lets me know when a certain TM1 (IBM) server goes down and then comes back up.
What happens is I kick off an import process, and the last step it restarts the server. Once the server restarts, I need to run a data export. However, the server can take anywhere from 4-8 minutes to restart so instead of checking manually, I want to capture dynamically.
My intent is to search the log file right before it downs down for the last occurrence of the following string: "TM1 Server is ready" and set the entire line in a variable.
Then, kepe scanning the file checking for the LAST instance of that string and set in a new variable. If the variables DO NOT equal each other, that means the server is now up.
My issue is that FINDSTR is very slow. Is there another method?
Here is my script I was working on:
Code: Select all
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
PUSHD "\\server\IBMCognos\ASCEND\LOG"
ECHO %TIME%
SET "LASTOCCURENCE="
SET "NEWOCCURENCE="
SET /A "CNT=0"
:LOOP
for /F "delims=" %%G in ('FINDSTR /C:"TM1 Server is ready" tm1server.log') DO (
IF "%CNT%"=="0" SET "LASTOCCURENCE=%%G"
IF "%CNT%" NEQ "0" SET "NEWOCCURENCE=%%G"
IF "!LASTOCCURENCE!" NEQ "!NEWOCCURENCE!" GOTO STARED
SET /A "CNT+=1" & GOTO LOOP
)
:STARTED
ECHO TM1 APP has been started
ECHO %TIME%
POPD
echo "!LASTOCCURENCE!"
echo "!NEWOCCURENCE!"
pause
Here is a sample log file ( see last night) :
Code: Select all
16104 [] INFO 2018-01-11 04:40:46.920 TM1.Process Process "ASCEND_TOUCH_FILE_MDM" run from process "ASCEND_MDM_EXPORT_WRAPPER" by user "R*EXPORT_WRAPPER"
16104 [] INFO 2018-01-11 04:40:48.748 TM1.Process Process "ASCEND_TOUCH_FILE_MDM": finished executing normally, elapsed time 1.83 seconds
16104 [] INFO 2018-01-11 04:40:48.748 TM1.Process Process "ASCEND_MDM_EXPORT_WRAPPER": finished executing normally, elapsed time 178.13 seconds
16104 [] INFO 2018-01-11 04:40:48.748 TM1.Process Process ASCEND_EXPORT_CC_CMSO_MASTERDATA executed by chore EXPORT_WRAPPER
16104 [] INFO 2018-01-11 04:40:49.842 TM1.Process Process "ASCEND_EXPORT_CC_CMSO_MASTERDATA": finished executing normally, elapsed time 1.09 seconds
16104 [] INFO 2018-01-11 04:40:49.842 TM1.Process Process ASCEND_EXPORT_CC_MDM_MASTERDATA executed by chore EXPORT_WRAPPER
16104 [] INFO 2018-01-11 04:40:54.732 TM1.Process Process "ASCEND_EXPORT_CC_MDM_MASTERDATA": finished executing normally, elapsed time 4.89 seconds
16104 [] INFO 2018-01-11 04:40:54.732 TM1.Process Process ASCEND_EXPORT_CC_FULL executed by chore EXPORT_WRAPPER
16104 [] INFO 2018-01-11 04:41:01.092 TM1.Process Process "ASCEND_EXPORT_CC_FULL": finished executing normally, elapsed time 6.36 seconds
16104 [] INFO 2018-01-11 04:41:01.092 TM1.Process Process ASCEND_EXPORT_CE_MASTERDATA executed by chore EXPORT_WRAPPER
16104 [] INFO 2018-01-11 04:41:01.983 TM1.Process Process "ASCEND_EXPORT_CE_MASTERDATA": finished executing normally, elapsed time 0.89 seconds
16104 [] INFO 2018-01-11 04:41:01.998 TM1.Process Process ASCEND_EXPORT_SAP_IO_REF_MAP executed by chore EXPORT_WRAPPER
16104 [] INFO 2018-01-11 04:41:04.842 TM1.Process Process "ASCEND_EXPORT_SAP_IO_REF_MAP": finished executing normally, elapsed time 2.84 seconds
16104 [] INFO 2018-01-11 04:41:04.920 TM1.Chore Chore "EXPORT_WRAPPER" time = 299.98 seconds
16128 [] INFO 2018-01-11 04:41:04.920 TM1.Server Starting PseudoElement thread. Thread Id: 16128
1848 [] INFO 2018-01-11 04:41:04.920 TM1.Server Starting RebuildFacetModel thread. Thread Id: 1848
9744 [] INFO 2018-01-11 04:41:04.920 TM1.Server Starting spy thread. Thread Id: 9744
16104 [] INFO 2018-01-11 04:41:04.920 TM1.Server TM1 Server load time (secs) = 537
8368 [] INFO 2018-01-11 04:41:05.717 TM1.Server TM1 Server is ready
Thanks!