KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Problem: FileCompare udv usage

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
bfrauneder



Joined: 27 Jun 2007
Posts: 4

PostPosted: Mon Aug 27, 2007 7:51 am    Post subject: Problem: FileCompare udv usage Reply with quote

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
Back to top
View user's profile Send private message
KS-Soft



Joined: 03 Apr 2002
Posts: 12795
Location: USA

PostPosted: Mon Aug 27, 2007 11:02 am    Post subject: Reply with quote

Quote:
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
Back to top
View user's profile Send private message Visit poster's website
bfrauneder



Joined: 27 Jun 2007
Posts: 4

PostPosted: Fri Aug 31, 2007 1:47 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Fri Aug 31, 2007 3:41 am    Post subject: Reply with quote

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/mframe.htm#tests.htm#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:
@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:
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index