Checking for a string

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
markdemanbey
Posts: 8
Joined: Tue Aug 08, 2006 7:23 am

Checking for a string

Post by markdemanbey »

Hi all.

I'm (almost) completely new to Host Monitor, and I'm trying to accomplish a task with it, with a view to buying the product.

I have a system that writes a new log file every morning to a share. This log file, if the task has been successful, will have a final line of -

Ended : Tue Aug 08

or whatever the date today is. I want host monitor to tell me if the last line in that text file doesn't match todays date. I can do this if I hard code a "compare files" test, but I don't want to do toing this every night before I go home.

Any ideas?

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

Post by KS-Soft »

You may setup Compare Files test method, mark second "Translate macros" option, then choose "Alert when file does not contain string" option and type "Ended : %mmm% %dd%" as string to compare.
If name of the file depends on date as well, then you should also mark 1st "Translate macros" option.

Regards
Alex
markdemanbey
Posts: 8
Joined: Tue Aug 08, 2006 7:23 am

Post by markdemanbey »

Thanks for that Alex.

I tried what you said, but the %mmm% %dd% doesn't seem to work. Works OK if I just use fixed strings (if I keep the string as "Ended :" it comes back as a good result, if I change the text file to read "Ededed :" Host Monitor throws a bad result), but as soon as I add in the %mmm% bit it comes back as a bad result.

Does the %mmm% variable only work in the file name?

Thanks.
markdemanbey
Posts: 8
Joined: Tue Aug 08, 2006 7:23 am

Post by markdemanbey »

Alex, I should mention - this isn't comparing files. THe previous days logs are overwritten.

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

Post by KS-Soft Europe »

markdemanbey wrote:I tried what you said, but the %mmm% %dd% doesn't seem to work.
I think, you should use %ddd% %mmm% %yy% variable in your case.
%ddd% - Current day as an abbreviation (Sun-Sat) using system's regional settings.
%mmm% - Current month as an abbreviation (Jan-Dec) using system's regional settings.
%yy% - Current year as a two-digit number (00-99).
markdemanbey wrote:Does the %mmm% variable only work in the file name?
In Compare Files test you may use macro variables in search string too.
markdemanbey wrote:Alex, I should mention - this isn't comparing files. THe previous days logs are overwritten.
Quote from manual:
==================
You can use this test to compare two files or to search a string in the file
============================
Compare Files test is exactly what you are looking for. Text Log file works in another way.

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

Post by KS-Soft Europe »

Sorry, small fix. Variable should be like this: %ddd% %mmm% %dd%
%ddd% - Current day as an abbreviation (Sun-Sat) using system's regional settings.
%mmm% - Current month as an abbreviation (Jan-Dec) using system's regional settings.
%dd% - Current day as a number with a leading zero (01-31).

Regards,
Max
markdemanbey
Posts: 8
Joined: Tue Aug 08, 2006 7:23 am

Post by markdemanbey »

Thanks for the help - unfortunately the test is STILL giving invalid results. In the test I have -

Test by - Host Monitor
Test method - Compare Files
Alert when - file contains a string
File - \\wmln2-m3-001\tech$\logs\test.log (Translate macros is ticked)
String - Ended : %ddd% %mmm% %dd%
Compare - (all unticked)

The rest of the test is left pretty blank. To be honest, it LOOKS as if it should work. And it does if I remove the %ddd% %mmm% %dd%. It just seems to ignore these values.
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

I think you forgot to mark second "Translate macros" option.
Quote from my 1st reply
You may setup Compare Files test method, mark second "Translate macros" option, THEN choose "Alert when file does not contain string" option and type "Ended : %mmm% %dd%" as string to compare.
Regards
Alex
markdemanbey
Posts: 8
Joined: Tue Aug 08, 2006 7:23 am

Post by markdemanbey »

Thanks Alex. I did see that, but when I select the second translate macros box, it it disappears when I change the alert from "files are different" to "file does not contain a string". So I put the path to the file in the second box BEFORE o change the alert type?

Thanks.
markdemanbey
Posts: 8
Joined: Tue Aug 08, 2006 7:23 am

Post by markdemanbey »

Alex, I take it back. I've had a play and it works fine now.

Thanks for your help.

Mark.
Post Reply