Monitoring Log Files

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
jfreude
Posts: 27
Joined: Tue Oct 19, 2004 7:14 am

Monitoring Log Files

Post by jfreude »

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
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Re: Monitoring Log Files

Post by KS-Soft Europe »

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_)?
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:

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%
)

jfreude 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
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=3436

Regards,
Max
jfreude
Posts: 27
Joined: Tue Oct 19, 2004 7:14 am

Post by jfreude »

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
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

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?
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: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.
Ok. I have added your request in our "to-do" list. Low priority.

Regards,
Max
jfreude
Posts: 27
Joined: Tue Oct 19, 2004 7:14 am

Post by jfreude »

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
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Variables supported by actions. You cannot use variables as parameter of the tests (except date/time variables in some cases).

Regards
Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

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.
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,
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
Action should be added to the "Good status actions" area. Now you may use %udv_logfilename% in the "File" input box in "Test Properties" window for the dependant "Text Log" test.
Of course, it is more complicated approach, but it works.

Regards,
Max
jfreude
Posts: 27
Joined: Tue Oct 19, 2004 7:14 am

Post by jfreude »

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
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You should enable "Use date macros" option in "Test properties" window. So, what exact variavle do you use? udv_logname? udv_logfilename? Have you setup Master/Dependant relations between tests?

Regards,
Max
jfreude
Posts: 27
Joined: Tue Oct 19, 2004 7:14 am

Post by jfreude »

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
jfreude
Posts: 27
Joined: Tue Oct 19, 2004 7:14 am

Post by jfreude »

Please forget my last post, it works after setting "Repeat until status changes" for the action :)

Regards,

jfreude
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

jfreude wrote:Please forget my last post, it works after setting "Repeat until status changes" for the action :)

Glad to hear that. :-)

Regards,
Max
Post Reply