Checking for a string
-
- Posts: 8
- Joined: Tue Aug 08, 2006 7:23 am
Checking for a string
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.
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.
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
If name of the file depends on date as well, then you should also mark 1st "Translate macros" option.
Regards
Alex
-
- Posts: 8
- Joined: Tue Aug 08, 2006 7:23 am
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.
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.
-
- Posts: 8
- Joined: Tue Aug 08, 2006 7:23 am
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
I think, you should use %ddd% %mmm% %yy% variable in your case.markdemanbey wrote:I tried what you said, but the %mmm% %dd% doesn't seem to work.
%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).
In Compare Files test you may use macro variables in search string too.markdemanbey wrote:Does the %mmm% variable only work in the file name?
Quote from manual:markdemanbey wrote:Alex, I should mention - this isn't comparing files. THe previous days logs are overwritten.
==================
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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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
%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
-
- Posts: 8
- Joined: Tue Aug 08, 2006 7:23 am
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.
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.
-
- Posts: 8
- Joined: Tue Aug 08, 2006 7:23 am
-
- Posts: 8
- Joined: Tue Aug 08, 2006 7:23 am