Problem: FileCompare udv usage

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
bfrauneder
Posts: 4
Joined: Wed Jun 27, 2007 4:02 am

Problem: FileCompare udv usage

Post by bfrauneder »

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
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

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..
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.
May be we implement such option in version 7...

Regards
Alex
bfrauneder
Posts: 4
Joined: Wed Jun 27, 2007 4:02 am

Post by bfrauneder »

perhaps you could implement a test to look for a string in all the files of a specific type (eg *.txt)
would help..

any idea how I can solve this issue?
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

bfrauneder wrote:any idea how I can solve this issue?
I would suggest you the following solution.

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% 
)
Now you should create a "Shell Script" test, and specify the full path into "Params" input box, e.g.: C:\temp\%dd%_%mm%_%yyyy%*
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 
Action should be added thru "Good status actions" area.

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
Post Reply