Text Log Test and Date Macros

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
costigaj
Posts: 5
Joined: Wed Apr 26, 2006 9:28 am

Text Log Test and Date Macros

Post by costigaj »

I am trying to setup a test for a log file that has the following format

Name%mmmdd%x.log

where the x is a variable from a-z. The log files are a maximum of 10 megs in size and when they exceed 10 megs, a new log is created and the next alphabetic letter is appended as follows:

NameMay26.log
NameMay26a.log
NameMay26b.log
etc.

How would I define a test to lookup conditions within a logset with this type of format in Advanced Host Monitor??

Thanks.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

So you may have several log files in the same directory? You need to create several test items.

Regards
Alex
Yoorix
Posts: 177
Joined: Wed Dec 14, 2005 8:28 am

Re: Text Log Test and Date Macros

Post by Yoorix »

costigaj wrote:where the x is a variable from a-z. The log files are a maximum of 10 megs in size and when they exceed 10 megs, a new log is created and the next alphabetic letter is appended as follows:

NameMay26.log
NameMay26a.log
NameMay26b.log
etc.
Hm. An what will you do when total log size exceeded 260Mb?
costigaj wrote: How would I define a test to lookup conditions within a logset with this type of format in Advanced Host Monitor??
I can suggest solution, but it is not simple. Anyway, you may try it.
You should create two test, master and dependant.
First Test should run Shell Script test, to retrieve the name of last created file in specified folder. E.g:
Start cmd: cmd /c %Script%
Script: @echo off
for /f "eol=; tokens=*" %%i in ('dir D:\Temp\*.* /A-D /B /OD /TW') do SET last_file_name=%%i
echo scriptres:Ok:%last_file_name%
Of course you should set your folder instead of 'D:\Temp\' or pass it as parameter. Now you have the name of newest file in Reply field. For this test you should run HMScript action. Such HMS script should modify special global variable(you should create the one) and set file name(Reply value) into this variable. You should read manual how to do that: http://www.ks-soft.net/hostmon.eng/mfra ... #actScript
Now you may create TextLog test, make it dependant of previous test, and set above mentioned global variable into field "File" input box (HM allows to set user defined macro variables into File input box).
http://www.ks-soft.net/hostmon.eng/mfra ... tm#textlog

Regards,
Yoorix
costigaj
Posts: 5
Joined: Wed Apr 26, 2006 9:28 am

Post by costigaj »

Thanks Alex

Yes. There are potentially multiple. Is there a wildcard variable that I can use to address the issue of the alphabetic prefix at the end of the log file name?

Thanks.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Yes, you may use wildcard (? or *) but this will not help when you have many files in the same directory. HostMonitor will check 1st matched file.
If you may rename, move or remove old log files, then wildcard may help.

Regards
Alex
cterrell9
Posts: 2
Joined: Thu Dec 09, 2004 2:09 pm
Location: Texas
Contact:

Post by cterrell9 »

Yoorix or Alex,

I tried he example provided above to check on only the latest log file in a folder, but I am having no luck getting the "Reply" value from the Shell Script test passed to the 2nd test to check the log.

Here is what I have done so far:
1. Created Shell Script test that Replies with the current log file name
2. Created an HML file with the following line:
"SetUserVariable DirxmlLogName %Reply%"
3. In the Alerts section, I created a profile to run the script in the "Good Status actions" section
4. Created a new Text Log test with "V:\%DirxmlLogFile%" in the File field
5. Added a dependency to the 1st test
6. Added the string I want to test for

Okay. After that, the 1st test returns the correct file name in the "Reply" field, but the 2nd test just shows up as Status=Unknown.

Any idea where I might have gone wrong?

Thank you for any help you can offer!

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

Post by KS-Soft Europe »

cterrell9 wrote:Any idea where I might have gone wrong?
Everything is fine, except one thing.
User Defined Variable should contain prefix "udv_" in its name.
http://www.ks-soft.net/hostmon.eng/mfra ... m#udvmacro
So, you should change things:
1. HMS file should contain "SetUserVariable udv_DirxmlLogName %Reply%"
2. In Text Log test you shoud specify "V:\%udv_DirxmlLogFile%" into the File field. Also you should enable "Use Date macros" option.
http://www.ks-soft.net/hostmon.eng/mfra ... tm#textlog

You may use menu Profiles > Global Macro Variables.. to control the values of the user defined macro varibles.

Regards,
Max
Post Reply