File text help please

Discuss RoboTask here
Post Reply
Murr
Posts: 5
Joined: Wed Apr 20, 2005 7:40 am
Location: United States

File text help please

Post by Murr »

Hi. PLease bear with my stupidity.
I am not a big scripter and even with the interface, very new to me and sort of lost. Once I get some direction and do things a few times I will start tp pick it up.
Here is what I need to do if anyone can help.
Basically, I have a log file being created in txt format. Appends each day, adds the date and results of somthing.
I need to look at the file, and if it sees a particular portion of text (preferrably looking at todays date first and searching anything after that instance), it then needs to either send an email, page, or some sort of alert.
Last part I may play with as I eventually will try and create an snmp trap based on if it finds the text it is looking for which will alert things.
Thanks in advance as any guidance is appreciated.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File text help please

Post by Oleg »

A few questions:
How many lines in your log file?
Can you send a few lines from this log file, I want look at these.
Last edited by Oleg on Wed Apr 20, 2005 2:27 pm, edited 1 time in total.
Murr
Posts: 5
Joined: Wed Apr 20, 2005 7:40 am
Location: United States

File text help please

Post by Murr »

Hi. Thanks for the reply. There are many lines, but let me paste a piece here.
The log is created every evening. It appends to the end of the log with the date, time and series of events.
Example of file:
***************FAILURE EXAMPLE*************
Sat 12/18/2004 19:45:00.27
The device configuration information is invalid (See the log file)
Tsimsnap2 backup program has finished with error!
**********************************************
The line I would need to find is in italics. It would be helpful if it could only search in the file below where it first find's that day's date. If not, I would just nave new file each night, not a running log (back them up elsewhere) if need be.
Then if it sees it, would have it email me or something.
Thanks
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File text help please

Post by Oleg »

There are many lines, but let me paste a piece here.
How many? 100, 1000, 1000000? (Approximately.)
Sat 12/18/2004 19:45:00.27
The device configuration information is invalid (See the log file)

Tsimsnap2 backup program has finished with error!
I.e. one record consists of four lines:
1 - Date and time
2 - Description
3 - Empty
4 - Resume

And you want to analyse resume string.
I'm right?

How many records per day?

I'll try to write a BASIC script.
Murr
Posts: 5
Joined: Wed Apr 20, 2005 7:40 am
Location: United States

File text help please

Post by Murr »

Hi. Thanks for the replay and again, this is very much appreciated. I cannot stress that enough.
He is a link to a copy of the log file I mentioned:
http://www.swlabr.com/log.txt
When it runs it adds each day it adds the date and time stamp followed by the results. Link shows log with nothing but successes. Length could be as many lines as it keeps adding each day until we decide to archive it.
Here is a paste of a normal day's success output followed by a failure since the log link has no failures.
Thu 10/28/2004 19:45:00.23
Now stopping the service SQLSERVERAGENT!
Sucessfully stopped SQLSERVERAGENT service!
Now stopping sqlserver cgtmw03 service!
Sucessfully stopped cgtmw03 service!
Successfully unmounted file system G:\
Successfully unmounted file system L:\
Now establishing devices used by the specified sqlserver instance remotely, please wait...
Successfully established devices used by the specified SQL Server instance remotely!
Please wait until all devices used by the specified databases get synchronized...
Successfully synchronized devices used by the specified database(s)!
Now flushing file systems used by the specified database(s) remotely ..
Now splitting devices used by the specified sqlserver instance remotely, please wait...
Successfully split devices used by the specified sqlserver instance remotely!
Successfully mounted file system G:\!
Successfully mounted file system L:\!
Now flushing file system G:\...
Now flushing file system L:\...
Now starting sqlserver cgtmw03 service!
Sucessfully started cgtmw03 service!
Now starting the service SQLSERVERAGENT!
Sucessfully started SQLSERVERAGENT service!
Tsimsnap2 backup program has finished with success!
Fri 10/29/2004 19:45:00.30
A NULL argument has been encountered, where a pointer is required
Tsimsnap2 backup program has finished with error!
Hopefully this makes sense and clears things up in me trying to explain it.
Thank you for your help thus far.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File text help please

Post by Oleg »

I has solved your problem without BASIC script. See task below.
This task checks your log file with "File Monitor" triggering event.
In this task I used log filename c:\log.txt. Please, change the name of this file in file monitor and in first step of task.
This task check lines after line with today's date and search the word "error". If this word has encountered, task shows dialog message with current error string.

Save text of this task to any text file and use Menu | Task | Import to import into RoboTask.
Do not forget to enable this task after importing.

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
Events=FOLDER
ExternalName=STRING|"Task35"
Hide=INTEGER|0
ID=INTEGER|1257788744
Name=STRING|"Log file analysis"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|2

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""LOG_FILENAME"" with value ""C:\log.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"LOG_FILENAME"
varvalue=STRING|"C:\log.txt"

[Actions\Action10]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action11]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action11\Params]
case=STRING|"0"
operator=STRING|"6"
type=STRING|"0"
value1=STRING|"{PROCESSING_DATE}"
value2=STRING|"{LOG_LINE}"

[Actions\Action12]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""BEGIN_PROCESS"" with value ""true"""
Params=FOLDER

[Actions\Action12\Params]
expand=STRING|"0"
varname=STRING|"BEGIN_PROCESS"
varvalue=STRING|"true"

[Actions\Action13]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action14]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""PROCESSING_DATE"" with value ""{MonthNo}/{Day}/{Year}"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"1"
varname=STRING|"PROCESSING_DATE"
varvalue=STRING|"{MonthNo}/{Day}/{Year}"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""SEARCH_STRING"" with value ""error"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"SEARCH_STRING"
varvalue=STRING|"error"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""BEGIN_PROCESS"" with value ""False"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varname=STRING|"BEGIN_PROCESS"
varvalue=STRING|"False"

[Actions\Action5]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER

[Actions\Action5\Params]
destvar=STRING|"LOG_LINE"
file=STRING|"{LOG_FILENAME}"
linecount=STRING|"0"
sourcetext=STRING|"0"

[Actions\Action6]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action6\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{begin_process}"

[Actions\Action7]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action7\Params]
case=STRING|"0"
operator=STRING|"6"
type=STRING|"0"
value1=STRING|"{SEARCH_STRING}"
value2=STRING|"{log_line}"

[Actions\Action8]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""[{Time}, {DayOfWeek}, {Date}]"""
Params=FOLDER

[Actions\Action8\Params]
icon=STRING|"1"
msg0=STRING|"[{Time}, {DayOfWeek}, {Date}]"
msg1=STRING|"Alarm!!!! Error has occured!!!"
msg2=STRING|"{log_line}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Events]
Event1=FOLDER

[Events\Event1]
Enabled=INTEGER|-1
EventID=STRING|"E_FILE_MONITOR"
Params=FOLDER

[Events\Event1\Params]
chg=STRING|"1"
chga=STRING|"1"
chgsl=STRING|"1"
chgsm=STRING|"1"
chgtl=STRING|"1"
chgtm=STRING|"1"
del=STRING|"0"
folder1=STRING|"C:\"
foldercount=STRING|"1"
id=STRING|"XZR0JLX97"
incmask=STRING|"log.txt"
interval=STRING|"60"
listmode=STRING|"1"
mon_files=STRING|"1"
mon_folders=STRING|"0"
new=STRING|"0"
saveresults=STRING|"0"
subfolders1=STRING|"0"
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

File text help please

Post by Oleg »

I can write a BASIC script if needed. BASIC script is working faster.
But i think that your log file has a non standard text format, because each line is ended with one char <LF> (0A)
In standart text file at the end of string is placed the chars pair <CR><LF> (in hex 0D 0A)
Murr
Posts: 5
Joined: Wed Apr 20, 2005 7:40 am
Location: United States

File text help please

Post by Murr »

Wow.
Words aren't enough to express my appreciaton.
Will test it out and let you know how it goes.
Thanks very much.
Murr
Posts: 5
Joined: Wed Apr 20, 2005 7:40 am
Location: United States

File text help please

Post by Murr »

Oleg,
Again, Thanks for the help. Works. Just have to change file names and such
You mentioned the basic script works faster. If it was already done, would love to check it out too. If not, don't go nuts and make one. Just curious to check that one out as well.
Post Reply