Problem with 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
llinskey
Posts: 3
Joined: Wed Jul 05, 2006 8:21 pm
Location: Quincy, MA
Contact:

Problem with Date Macro

Post by llinskey »

Hi,

Ive written a script to take a date parameter that has to look like 03/12/2009 which I have done in test properties. I type %mm%/%dd%/%yyyy% and it my new test works fine.

I decided to test for the previous day and tried to change the Param to %mm%/%dd[-1d]%/%yyyy% and the test fails. Further investigation shows me that this macro is being interpreted as 03/%dd[-1d]%/2009

This looks like a bug to me but perhaps I am missing something.

I am using HostMonitor 7.78 on Windows Server 2003. The test is a window batch script

**********************************

@echo off

Find "%1" "c:\program files\3x backup\log\*err.csv" > c:\scripts\result.out
If ErrorLevel 1 GoTo FALSE

:TRUE
Find "COMPLETE" c:\scripts\result.out
If ErrorLevel 1 GoTo OTHER
If ErrorLevel 0 echo ScriptRes:Ok:%1 Baskup ran successfully
GoTo EXIT

:FALSE
Echo ScriptRes:Bad:%1 Backup did not run
GoTo EXIT

:OTHER
Echo ScriptRes:Bad:%1 Backup Failed
GoTo EXIT

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

Post by KS-Soft »

Quote from the manual
===============
When you setup "Folder/File Size", "File/Folder Availability", "Count Files", "Text Log" or "Compare Files" tests you can set "Translate macros" option and use special macro variables in the file name:
===============
As I understand you are using Shell Script test method. That's why such expression does not work.
Its not a bug.

Perhaps you may start test at the same day backup procedure was performed?

Regards
Alex
User avatar
greyhat64
Posts: 246
Joined: Fri Mar 14, 2008 9:10 am
Location: USA

Post by greyhat64 »

llinskey,
If you've written this as a shell script why don't you simply provide a second parameter for the offset. -1 for previous day, -7 for a week prior, etc.?
If you really want to jazz it up use -1d, -1w, -1m, etc., parse the parameter and do the math. :)

I even have an old commandline batch file that can do the math, and it even accommodates leap year! I had some time on my hands in a previous life and wanted to prove I could do it. 8)

I'll even post it in the Library if it would help you to get the date-math right in your script. Or you can email me (see button below) and I'll send it to you. :)
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

I have done some testing on this and it looks like a bug.

Code: Select all

; ------- Test #01 -------


Method      = CompareFiles
;--- Common properties ---
;DestFolder = ELCMHT\!Test\
Title       = compare "HDD.txt" & "%m%/%d[-1d]%/%yyyy%"
Disabled    = Yes
Comment     = alert when DoesntContainString ("HDD.txt" & "%m%/%d[-1d]%/%yyyy%")
RelatedURL  = 
NamePattern = compare "%object%" & "%object2%"
CmntPattern = alert when %testmode% ("%object%" & "%object2%")
ScheduleMode= Regular
Schedule    = 
Interval    = 600
Alerts      = Test Email
ReverseAlert= No
UnknownIsBad= No
WarningIsBad= No
UseCommonLog= Yes
PrivLogMode = Default
CommLogMode = Default
;--- Test specific properties ---
AlertMode   = DoesntContainString
MissingCheck= Yes
UseMacros1  = Yes
UseMacros2  = No
File1       = C:\Temp\HDD.txt
String      = %m%/%d[-1d]%/%yyyy%
WholeWords  = No
CaseSensitive = No

;-----------------------------------------------------------------------------
Response
Test : compare "HDD.txt" & "3/%d[-1d]%/2009"
Method: file compare
Status : Bad


This test allows me to check log files for specific date information - as opposed to the Text Log test, which assumes the file has always existed.

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

Post by KS-Soft »

Sorry, I do not understand what exactly is the bug?
Did we ever said you may use "date expressions" as test name or comment?
Quote from the manual
===============
When you setup "Folder/File Size", "File/Folder Availability", "Count Files", "Text Log" or "Compare Files" tests you can set "Translate macros" option and use special macro variables in the file name
===============

Regards
Alex
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

OK, not a bug, more an oversite?
As it half works, can we please have it fully implemented?

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

Post by KS-Soft »

What exactly do you need? Support of date variables in test name field?
As think this is bad idea. Test that changes its name every day...

Regards
Alex
Paul_NHS
Posts: 59
Joined: Wed Feb 25, 2009 6:17 am

Post by Paul_NHS »

Allow date macros in the string field. This allows you to check the date in a log file - not all log files are always appended.
e.g. String = %m%/%d[-1d]%/%yyyy%

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

Post by KS-Soft »

Oh, you want to use date expressions in "Look for" field of Text Log test method?
I think we can implement such option. I have added task into "to do" list

Regards
Alex
Post Reply