I want to get an alert if a string appears in our daily generated logfile.
To get the name of the logfile I have a FileAvailability test(bf_logfilename) which looks for %dd%_%mm%_%yyyy%* (which is our format for the logfiles)
I have a Global Variable udv_logfilename which is defined as %::bf_logfilename::FileName%
If I make a test with a script to display the Variable name the filename looks ok. (something like 27_08_2007_10_03_50_logfile.txt)
But I need to look for the String "Error" in this file.
So I added a CompareFile Test and set it to alert when contains file.
The filename is set to %udv_logfilename% Translate macros enabled.
Should work i think..
But when I start the test as a reply I get: "File "Fil742a87" not found"
Whats the problem? What have i done wrong?
bernhard
Problem: FileCompare udv usage
No, it will not work. HostMonitor resolves %udv_logfilename%, then checks for date macro variables. It does not resolve test related variables (%::bf_logfilename::FileName%). Such variables can be used as parameter of some action but not the test. In other words: action may refer to test parameters or test results; while another test cannot refer to test results.So I added a CompareFile Test and set it to alert when contains file.
The filename is set to %udv_logfilename% Translate macros enabled.
Should work i think..
May be we implement such option in version 7...
Regards
Alex
-
- Posts: 4
- Joined: Wed Jun 27, 2007 4:02 am
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
I would suggest you the following solution.bfrauneder wrote:any idea how I can solve this issue?
You should create two test, master and dependant.
1. First test should be a "Shell script", that retrieves the last file name according to the given pattern and place the value into "Reply" field: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
To implement this, you have to create new script within "Script Manager" with the following values:
Start cmd: cmd /c %Script% %Params%
Script:
Code: Select all
@echo off
rem %1 - FilePath
set last_file_name=""
for /f "eol=; tokens=*" %%i in ('dir %1 /A-D /B /OD /TW') do SET last_file_name=%%i
IF %last_file_name%=="" (
echo scriptres:Bad:File not found
) ELSE (
echo scriptres:Ok:%last_file_name%
)
Please, do not forget to enable "Translate macro" option. To this script, you have to assign an alert profile, with "Execute HMS script" action, which should set the %udv_logfilename% variable. You may use the following HMS script:
Code: Select all
SetUserVariable udv_logfilename %Reply%
SaveUserVariables
2. Now you should create a "Compare Files" test, select "Alert when file contains string", specify the file as C:\Temp\%udv_logfilename%, and specify string to find into "String" input box. You also should enable "Translate macros" option. Now you have to specify the foregoing "Shell script" test as a "Master" for this test.
That's all. Everything should work fine.
Regards,
Max