Monitoring Log Files
Monitoring Log Files
Hey there,
i'd like to check logfiles and have some questions:
1) the logfiles start with MC1_xxxx where xxxx is a increasing integer. is ist possible to create a text log test that only checks the latest file in a directory (optional: the latest file starting with MC1_)?
2) is it with the text log method also possible to test for two successive events in a logfile? the application only fails if in one line "Fehler -1017" and in the next line '(#35)' is contained
<snip>
02.10.2007 07:59:00 Fehler -1017
02.10.2007 07:59:00 Beginne Aufnahme (#35):
</snip>
thanks,
jfreude
i'd like to check logfiles and have some questions:
1) the logfiles start with MC1_xxxx where xxxx is a increasing integer. is ist possible to create a text log test that only checks the latest file in a directory (optional: the latest file starting with MC1_)?
2) is it with the text log method also possible to test for two successive events in a logfile? the application only fails if in one line "Fehler -1017" and in the next line '(#35)' is contained
<snip>
02.10.2007 07:59:00 Fehler -1017
02.10.2007 07:59:00 Beginne Aufnahme (#35):
</snip>
thanks,
jfreude
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Re: Monitoring Log Files
Sorry, "Text Log" test method cannot do that. You may use "Shell Script" test method to retrieve the latest file name in a folder. For instance, you may use the following script:jfreude wrote:1) the logfiles start with MC1_xxxx where xxxx is a increasing integer. is ist possible to create a text log test that only checks the latest file in a directory (optional: the latest file starting with MC1_)?
Code: Select all
@echo off
rem %1 - FileDir
set last_file_name=""
for /f "eol=; tokens=*" %%i in ('dir %1 /A-D /B /OD /TW') do SET last_file_name=%%i
IF %last_file_name%=="" (
echo scriptres:Bad:File not found
) ELSE (
echo scriptres:Ok:%last_file_name%
)
I am afraid, "Text Log" test method is unable to perform such a complicated search. However, you may write a .bat script and use "Shell Script" test method to do that. Here is an example of the script, you just should slightly modify it: http://www.ks-soft.net/cgi-bin/phpBB/vi ... php?t=3436jfreude wrote:2) is it with the text log method also possible to test for two successive events in a logfile? the application only fails if in one line "Fehler -1017" and in the next line '(#35)' is contained
Regards,
Max
Thanks for the fast reply Max.
If i retrieve the latest file name with the script you provided, can i use it as a variable in another text log test?
Is it possible or planned to extend the Text Log method to retrieve the latest file in a directory? I think this would help a lot of HostMon users.
Greets,
jfreude
If i retrieve the latest file name with the script you provided, can i use it as a variable in another text log test?
Is it possible or planned to extend the Text Log method to retrieve the latest file in a directory? I think this would help a lot of HostMon users.
Greets,
jfreude
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Sure. You may use '%::CertainTestName::Reply%' variable. I think, you should set the test, that retrieves the last filename, as a Master for "Text Log" test.jfreude wrote:If i retrieve the latest file name with the script you provided, can i use it as a variable in another text log test?
Ok. I have added your request in our "to-do" list. Low priority.jfreude wrote:Is it possible or planned to extend the Text Log method to retrieve the latest file in a directory? I think this would help a lot of HostMon users.
Regards,
Max
I'm using now the Script to get the filename of the last edited file,
the reply of the test in hostmonitor is ok, it's something like 'L:\test\MC_1444.log'.
But i if use the reply (as variable %::MyTestName::Reply%) as filename in a text log test, the status of the test is always 'unknown'. The test, that retrieves the filename is Master for the Text Log test.
Any idea what's going wrong?
Regards,
jfreude
the reply of the test in hostmonitor is ok, it's something like 'L:\test\MC_1444.log'.
But i if use the reply (as variable %::MyTestName::Reply%) as filename in a text log test, the status of the test is always 'unknown'. The test, that retrieves the filename is Master for the Text Log test.
Any idea what's going wrong?
Regards,
jfreude
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Sorry, I pointed you the wrong direction. As Alex mentioned above, you cannot use variables as parameter of the tests. However, you may use "User Defined"variables. So, to figure it out,jfreude wrote:But i if use the reply (as variable %::MyTestName::Reply%) as filename in a text log test, the status of the test is always 'unknown'. The test, that retrieves the filename is Master for the Text Log test.
t the "Shell script" test, which retrieves last edited file, you have to assign an alert profile, with "Execute HMS script" action, which should set the %udv_logfilename% variable. You may use the following HMS script:
Code: Select all
SetUserVariable udv_logfilename %Reply%
SaveUserVariables
Of course, it is more complicated approach, but it works.
Regards,
Max
Thanks for the hint using User Defined variables - the udv_logname variable is set correctly by the HMS-Script, i can open the file using the value of the variable within the file explorer. But the Text Log test's status is still 'Unknown' when i'm using %udv_logfilename% as Filename.
Regards,
jfreude
Regards,
jfreude
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
It works, the problem was the disabled "Use date macros", I'm using udv_logfilename as variable.
What happens when the variable is once set by the HMS-Script? Could it be set again through the HMS-Script? I tried it, but the value of udv_logfilename has not been refreshed. Is the Script only executed when the status becomes good after a bad event? The Script should be executed with every good status.
The Script Shell Test is Master test for the Text Log Test.
Thanks a lot for your help!
Regards,
jfreude
What happens when the variable is once set by the HMS-Script? Could it be set again through the HMS-Script? I tried it, but the value of udv_logfilename has not been refreshed. Is the Script only executed when the status becomes good after a bad event? The Script should be executed with every good status.
The Script Shell Test is Master test for the Text Log Test.
Thanks a lot for your help!
Regards,
jfreude
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: