Text log test

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

Post by KS-Soft »

However, it always replies ‘0’ even when “service stopped” message is in the log file. Could you please let me know what I am doing wrong?
0? What about status of the test?

Regards
Alex
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Hello Alex,

The status of the test remains 'Ok'.

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

Post by KS-Soft »

This means program cannot find specified string. Please check test parameters.
Note: search is case sensitive

Regards
Alex
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Alex,

When testing the utility from a cmd window, it returns the expected values (e.g. scriptres:Ok:7).
But when using the test method "by external program", the reply field of the test remains '0' and the status 'Ok'

the test properties are as follows:

; ------- Test #01 -------


Method = ExternalPrg
;--- Common properties ---
DestFolder = Root\tEMP\
Title = LDN-SV-CVLIFFE - LIFFE exchange disconnection utility
Comment = O:\Hostmonitor\texteventscheck.exe
RelatedURL =
ScheduleMode= Regular
Schedule = Lun-Ven, 8:00-21:00, London
Interval = 120
Alerts =
ReverseAlert= No
UnknownIsBad= Yes
WarningIsBad= Yes
UseCommonLog= Yes
PrivLogMode = Default
CommLogMode = Default
;--- Test specific properties ---
CommandLine = O:\Hostmonitor\external_program\texteventscheck.exe O:\Hostmonitor\external_program\test2.log "bad" "good"
Condition = DifferentFrom
ErrorLevel = 0
WindowMode = shownormal
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Utility was designed for Shell Script test method
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Regards
Alex
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Thank you Alex, it works now.
However, I still have the following issue: for a one of the applications that needs to be monitored, the utility returns “scriptres:Unknown:I/O error 32”. (when the utility checks in text log file written by the application).

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

Post by KS-Soft »

Error #32 means "The process cannot access the file because it is being used by another process".
You may try version 0.11 of the utility http://www.ks-soft.net/download/utils/t ... scheck.exe (we modified some flags).
However if that applocation locks file for reading, there is nothing we ca do

Regards
Alex
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Alex,

Unfortunately, i still get the same error message. However, the file can be opened with notepad for example. It is not locked by the application.

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

Post by KS-Soft »

We cannot reproduce problem so far. Do you know what exactly mode/flags are used by the application when it opens/creates file?

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

Post by KS-Soft »

Ok, lets try version 0.12 http://www.ks-soft.net/download/utils/t ... scheck.exe

Regards
Alex
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Many thanks Alex. it works now :D

Regards,
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Alex,

Some of the files that need to be monitored are up to 30 MB. When the log file is that big, the test can still take a long time to complete. Does the utility audit the whole file at each test or does it start from the last line it has read during the previous test?

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

Post by KS-Soft Europe »

raphaelb wrote:Some of the files that need to be monitored are up to 30 MB. When the log file is that big, the test can still take a long time to complete.
30 MB is a bit big file. It is hard to parse such huge file.
raphaelb wrote:Does the utility audit the whole file at each test or does it start from the last line it has read during the previous test?
Utility starts from the begin of file each time the test performed.

Could you try the following script? The script the same as earlier, but I have done small modifications:

Code: Select all

@echo off 
rem %1 - Filename full path 
rem %2 - Bad pattern string 
rem %3 - Good pattern string 
rem %4 - filename to store last line number

set last_pattern_status=Ok
set last_pattern_line=
set last_line_number=1
set line_iterator=0

IF EXIST %4 (
 for /f "usebackq eol=; tokens=*" %%i in (%4) do SET last_line_number=%%i   
)

rem Step 1: Retrieving line 
for /f "eol= tokens=* skip=%last_line_number%" %%i in (%1) do ( 
   echo "%%i" | find "%~2" > NUL 
   IF NOT ERRORLEVEL 1 ( 
      set last_pattern_status=Bad
      set last_pattern_line=FAILURE
   ) 
   echo "%%i" | find "%~3" > NUL 
   IF NOT ERRORLEVEL 1 ( 
      set last_pattern_status=Ok
      set last_pattern_line=SUCCESS
   ) 
   set /A line_iterator=line_iterator + 1
) 


set /A last_line_number=last_line_number+line_iterator
echo %last_line_number% > %4
echo ScriptRes:%last_pattern_status%:%last_pattern_line%
As you can see, I have added fourth parameter - filename to store last line number. So, the script works in following way. It checks for the specified file and if it exists, script read the last line number from the file and skip the number of lines from the log. If specified file does not exist, script starts from beginning. At the end, script writes to the file the last line number to use it on next startup.

However, script have some disadvantages:
1. Script will work a long time for the first time.
2. You have to manage files with line number by your self.

Regards,
Max
raphaelb
Posts: 18
Joined: Thu May 31, 2007 4:21 am

Post by raphaelb »

Hello Max / Alex,

Thank you for the updated script.
Would it be possible to take into account the last line number read in the utility as well? i.e. if reply field gets 2 variables (“line number of the last message” concatenated with “last line read number”), would it be possible to use the second one to start reading at this line of the file?

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

Post by KS-Soft Europe »

raphaelb wrote:Would it be possible to take into account the last line number read in the utility as well? i.e. if reply field gets 2 variables (“line number of the last message” concatenated with “last line read number”)
Yes, it is possible, you just should change the last line of the script with the following one:
echo ScriptRes:%last_pattern_status%:%last_pattern_line%,%last_line_number%
raphaelb wrote:would it be possible to use the second one to start reading at this line of the file?
Sorry, I do not think it is possible.

Do not you like the temporary file like a storage? You may use some date stamps in the file names and use scheduled task to delete them on the regular basis.

Regards,
Max
Post Reply