Problem with compage files and date macro

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
mp1
Posts: 200
Joined: Tue Mar 07, 2006 3:24 am

Problem with compage files and date macro

Post by mp1 »

Hi,

I want to check a logfile, if there is an line with the date from today.
So I tried it with the compare files test method:


file: C:\test.log (the file name is always the same)
string: %dd%.%mm%.%yyyy%


The log file looks like this:

17.02.2008 xxxxxxxxxx
18.02.2008 xxxxxxxxxxxx
18.02.2008 xxxxxx

Unfortunately I didn't get it work. I have HM 7.10.
I tried it with the translate macro option and without.

What do I wrong?

Thanks in advance

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

Post by KS-Soft Europe »

Sorry, "Compare files" test method does not support macro variables in the search string. "Translate macros" option is only applied to the filenames. Quote from the manual:
http://www.ks-soft.net/hostmon.eng/mfra ... tm#filecmp
==========================================
If you need to check some files that are dynamically created and do not have static name (e.g. some logs that are created on daily basis and have different file name every day), you may enable "Translate macros" options. With this option enabled you may use special date macro variables and User Defined Variables in file name.
==========================================

You may try "Text Log" test method, which offers "Macros" option, that allows you to use date&time macro variables in the "look for" string/expression.
http://www.ks-soft.net/hostmon.eng/mfra ... tm#textlog


Regards,
Max
mp1
Posts: 200
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Hi Max,

Thanks for the quick reply.
I already tried it with the text log method, with no success.

Look for sting: %dd%.%mm%.%yyyy%
activated the Macros option

So the text log method only checks new entries.
I added some entries like:

18.02.2008 xxxxxxxxxxxx
18.02.2008 xxxxxx

... but got no alarm.

I also tried it with a global macro variable in the search string:

%udv_date%

udv_date = %dd%.%mm%.%yyyy%

How does the text log method check for new entries?
(file change date ... ???)

Regards,

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

Post by KS-Soft Europe »

Sorry, it is my fault. "Text Log" test method will not help you also. "Macros" option allows you to use global (user defined) macro variables, not date&time.

I think, you may try to use the following script within "Shell Script" test method. http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

You just should add this script into the "Script Manager".
Start cmd: cmd /c %Script% %Params%
Script:

Code: Select all

@echo off
REM Script retrieves system date and parse it.
REM Output variables:
REM %Year%, %Month%, %Day%
REM %iDate%,%sDate% - Date Separators from registry


rem Select date
:: Export registry's date format settings to a temporary file
START /W REGEDIT /E _TEMP.REG "HKEY_CURRENT_USER\Control Panel\International"

:: Read the exported data
FOR /F "tokens=2* delims==" %%A IN ('TYPE _TEMP.REG ^| FIND /I "iDate"') DO SET iDate=%%A
FOR /F "tokens=2* delims==" %%A IN ('TYPE _TEMP.REG ^| FIND /I "sDate"') DO SET sDate=%%A
DEL _TEMP.REG

SET iDate=%iDate:"=%
SET sDate=%sDate:"=%

IF %iDate%==0 FOR /F "TOKENS=1-4* DELIMS=%sDate%" %%A IN ('DATE/T') DO (
	SET Year=%%C
	SET Month=%%A
	SET Day=%%B
)
IF %iDate%==1 FOR /F "TOKENS=1-4* DELIMS=%sDate%" %%A IN ('DATE/T') DO (
	SET Year=%%C
	SET Month=%%B
	SET Day=%%A
)
IF %iDate%==2 FOR /F "TOKENS=1-4* DELIMS=%sDate%" %%A IN ('DATE/T') DO (
	SET Year=%%A
	SET Month=%%B
	SET Day=%%C
)

:: Remove the day of week if applicable
FOR %%A IN (%Year%)  DO SET Year=%%A
FOR %%A IN (%Month%) DO SET Month=%%A
FOR %%A IN (%Day%)   DO SET Day=%%A

type %1 | find "%Day%.%Month%.%Year%" > NUL
IF ERRORLEVEL 1 (
  echo ScriptRes:Bad:
) ELSE (
  echo ScriptRes:Ok: 
)
Script requires just one parameter - filename to check.

Regards,
Max
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Quote from the manual
Macros
With this option enabled you may use global (user defined) macro variables in the "look for" string/expression
In your case it resolves %udv_date% to %dd%.%mm%.%yyyy% but does not processes date macro variables.
I think we can implement this option in next version of HostMonitor.
How does the text log method check for new entries?
(file change date ... ???)
HostMonitor checks time stamp, size of the file, also it keeps position of the last check.

Regards
Alex
mp1
Posts: 200
Joined: Tue Mar 07, 2006 3:24 am

Post by mp1 »

Thanks thanks,

The script works perfect.
In your case it resolves %udv_date% to %dd%.%mm%.%yyyy% but does not processes date macro variables.
I think we can implement this option in next version of HostMonitor.
This would be great

Best regards,

Martin
Post Reply