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.
Text Log Test and Date Macros
Re: Text Log Test and Date Macros
Hm. An what will you do when total log size exceeded 260Mb?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.
I can suggest solution, but it is not simple. Anyway, you may try it.costigaj wrote: How would I define a test to lookup conditions within a logset with this type of format in Advanced Host Monitor??
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:
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 ... #actScriptStart 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%
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
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
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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Everything is fine, except one thing.cterrell9 wrote:Any idea where I might have gone wrong?
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