collecting info

Discuss RoboTask here
Post Reply
5243
Posts: 23
Joined: Wed Feb 25, 2015 12:04 pm

collecting info

Post by 5243 »

I have a question. I'd like to have a task that only collects error warnings from other tasks.

example:

task01 runs 1x per minute
task02 runs 1x per minute
task03 runs 1x per minute

then task 4 runs 1x per hour, and will send 1 report if there are errors in task 1,2 or 3.
Mailing the info is not a problem, collecting the errors information from different tasks and then combine them in 1 text file, is the problem.

is this possible?
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: collecting info

Post by Oleg »

You can extract all error and warning messages from log files of these tasks by using regular expressions
Look at my small example below.
Just specify necessary log files in 1-st step

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task231"
Hide=INTEGER|0
ID=INTEGER|-2006886938
LogOnAsUser=INTEGER|1
Name=STRING|"collect errors and warnings form logs"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=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 ""LOGFILES"" with value ""20B41AB4.log{EOL}2430EFAC.log"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"LOGFILES"
varvalue=STRING|"20B41AB4.log{EOL}2430EFAC.log"

[Actions\Action10]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""collected.txt """
Params=FOLDER

[Actions\Action10\Params]
ifnonzero=STRING|"0"
program=STRING|"{TempDir}\collected.txt"
runas=STRING|"0"
wait=STRING|"0"

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

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"TEXT"

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

[Actions\Action3\Params]
destvar=STRING|"FILENAME"
line0=STRING|"{LogFiles}"
linecount=STRING|"1"
sourcetext=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{EOL}*****************************{EOL}Log File: {FileName}"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{EOL}*****************************{EOL}Log File: {FileName}"

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

[Actions\Action5\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
file=STRING|"{LogFolder}\{filename}"
linecount=STRING|"0"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?im)^(e\s|w\s).+$"
savelengths=STRING|"0"
saveoffsets=STRING|"0"
singleline=STRING|"0"
ungreedy=STRING|"0"
useexternal=STRING|"1"
variable=STRING|"line"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{EOL}{line(0)}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{EOL}{line(0)}"

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

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

[Actions\Action9]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {TempDir}\collected.txt"
Params=FOLDER

[Actions\Action9\Params]
encode=STRING|"0"
fileexists=STRING|"0"
filname=STRING|"{TempDir}\collected.txt"
line0=STRING|"{text}"
linecount=STRING|"1"
suppress=STRING|"1"

Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Oleg Yershov
5243
Posts: 23
Joined: Wed Feb 25, 2015 12:04 pm

Re: collecting info

Post by 5243 »

thank you Oleg for your quick response!

This task is almost all right, the only thing what is missing is, at the moment the log files are collected, the log files need to be emptied, is this perhaps also possible?

ps....maybe emptying the log file is not a good option?
maybe it's better to get only the error info from the last hour?
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: collecting info

Post by Oleg »

look at the 2-nd version of the task
You have to extract log time from each record and calculate the time difference
Put the log list into step #1
Put the max time delta into step #2 (delta must be in minutes. 1 hour = 60 minutes)

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task332"
Hide=INTEGER|0
ID=INTEGER|2003726288
LogOnAsUser=INTEGER|1
Name=STRING|"collect errors and warnings form logs (ver2)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|2
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action20=FOLDER
Action21=FOLDER
Action22=FOLDER
Action23=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 ""LOGFILES"" with value ""20B41AB4.log{EOL}2430EFAC.log"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"LOGFILES"
varvalue=STRING|"20B41AB4.log{EOL}2430EFAC.log"

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

[Actions\Action10\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{TimeFound}"

[Actions\Action11]
ActionID=STRING|"A_TIMEDIFFERENCE"
Enabled=INTEGER|-1
Name=STRING|"Time Difference"
Params=FOLDER

[Actions\Action11\Params]
datetime1=STRING|"{dt(1)}"
datetime2=STRING|"{DateTime}"
format=STRING|"1"
valuekind=STRING|"0"
varname=STRING|"logtime"

[Actions\Action12]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then // newer than 60 minutes"
Params=FOLDER

[Actions\Action12\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"4"
type=STRING|"1"
value1=STRING|"{logtime}"
value2=STRING|"{delta}"

[Actions\Action13]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER

[Actions\Action13\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{Line}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)^(e\s|w\s).+$"
savesubexpression=STRING|"0"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"errorfound"

[Actions\Action14]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then //is error or warning"
Params=FOLDER

[Actions\Action14\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{ErrorFound}"

[Actions\Action15]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{EOL}{line}"""
Params=FOLDER

[Actions\Action15\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{EOL}{line}"

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

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

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

[Actions\Action19]
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 ""DELTA"" with value ""60"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"DELTA"
varvalue=STRING|"60"

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

[Actions\Action21]
ActionID=STRING|"A_FILE_TEXTWRITE"
Enabled=INTEGER|-1
Name=STRING|"Create text file {TempDir}\collected.txt"
Params=FOLDER

[Actions\Action21\Params]
encode=STRING|"0"
fileexists=STRING|"0"
filname=STRING|"{TempDir}\collected.txt"
line0=STRING|"{text}"
linecount=STRING|"1"
suppress=STRING|"1"

[Actions\Action22]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""collected.txt """
Params=FOLDER

[Actions\Action22\Params]
ifnonzero=STRING|"0"
program=STRING|"{TempDir}\collected.txt"
runas=STRING|"0"
wait=STRING|"0"

[Actions\Action23]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action23\Params]
message=STRING|"*** finish ***"
type=STRING|"3"

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

[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"TEXT"

[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action4\Params]
message=STRING|"*** begin ***"
type=STRING|"3"

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

[Actions\Action5\Params]
destvar=STRING|"FILENAME"
line0=STRING|"{LogFiles}"
linecount=STRING|"1"
sourcetext=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TEXT"" with value ""{Text}{EOL}*****************************{EOL}Log File: {FileName}"""
Params=FOLDER

[Actions\Action6\Params]
expand=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"{Text}{EOL}*****************************{EOL}Log File: {FileName}"

[Actions\Action7]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action7\Params]
message=STRING|"Process file {filename}"
type=STRING|"3"

[Actions\Action8]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop // by logfile"
Params=FOLDER

[Actions\Action8\Params]
destvar=STRING|"LINE"
file=STRING|"{LogFolder}\{filename}"
linecount=STRING|"0"
sourcetext=STRING|"0"

[Actions\Action9]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match //extract time"
Params=FOLDER

[Actions\Action9\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{line}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"^.\s(.+):\s"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"dt"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"timefound"
Oleg Yershov
5243
Posts: 23
Joined: Wed Feb 25, 2015 12:04 pm

Re: collecting info

Post by 5243 »

Hi Oleg,

this is a very good example!
Thank you so much for this.

The only problem is that the search function in the text lines is very processor intensive and takes a very long time.
In this project, processor speed very important.

is there perhaps also the possibility to copy the entire log file
save and/or send it, and then give a 'clear log' command?

In this case, this would be so much faster, and less processor intensive!
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: collecting info

Post by Oleg »

... and then give a 'clear log' command?
There is no such command

How many lines in you log files?
I think that there is no sense to use more than 10000 lines
You can change it in RoboTask options (menu Options->Settings)
Oleg Yershov
5243
Posts: 23
Joined: Wed Feb 25, 2015 12:04 pm

Re: collecting info

Post by 5243 »

Hi, Oleg,

I've checked all my log files and I saw that there's one log file that gave a warning every second.
So that is al lot of text in one hour.

I deleted this log file from the task, and now its working perfect!!
Thank you!

:-)
5243
Posts: 23
Joined: Wed Feb 25, 2015 12:04 pm

Re: collecting info

Post by 5243 »

Hi Oeleg,

I have just one more question, is it also possible to see only the last two line from te log file????
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: collecting info

Post by Oleg »

Look at the example below:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1146"
Hide=INTEGER|0
ID=INTEGER|1613239958
LogOnAsUser=INTEGER|1
Name=STRING|"Show last 2 lines from the text"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FILENAME"" with value ""D:\Temp\file1.txt"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"FILENAME"
varvalue=STRING|"D:\Temp\file1.txt"

[Actions\Action2]
ActionID=STRING|"A_TXT_NUMBEROFLINES"
Enabled=INTEGER|-1
Name=STRING|"TXT Number of Lines"
Params=FOLDER

[Actions\Action2\Params]
external=STRING|"1"
filename=STRING|"{filename}"
linecount=STRING|"0"
variable=STRING|"num"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""num"""
Params=FOLDER

[Actions\Action3\Params]
incement=STRING|"-1"
vaiable=STRING|"num"

[Actions\Action4]
ActionID=STRING|"A_TXT_EXTRACTLINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Extract Line"
Params=FOLDER

[Actions\Action4\Params]
external=STRING|"1"
filename=STRING|"{filename}"
linecount=STRING|"0"
linenum=STRING|"{num}"
variable=STRING|"line1"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""num"""
Params=FOLDER

[Actions\Action5\Params]
incement=STRING|"1"
vaiable=STRING|"num"

[Actions\Action6]
ActionID=STRING|"A_TXT_EXTRACTLINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Extract Line"
Params=FOLDER

[Actions\Action6\Params]
external=STRING|"1"
filename=STRING|"{filename}"
linecount=STRING|"0"
linenum=STRING|"{num}"
variable=STRING|"line2"

[Actions\Action7]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Last 2 lines:"""
Params=FOLDER

[Actions\Action7\Params]
icon=STRING|"1"
msg0=STRING|"Last 2 lines:"
msg1=STRING|"{Line1}"
msg2=STRING|"{Line2}"
msg4=STRING|"Text contains {num} lines"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"

Oleg Yershov
5243
Posts: 23
Joined: Wed Feb 25, 2015 12:04 pm

Re: collecting info

Post by 5243 »

Thank you!

You are always super helpful, you always give a super service!
Post Reply