Text Log

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).
Harland Adelaars
Posts: 12
Joined: Thu Dec 28, 2006 9:48 am

Text Log

Post by Harland Adelaars »

I Everyone,

I started with this program yesterday, i didn't know that it was so powerfull, i added a lot of test alreay but now i have i test that i don't get working.

I have a log-file that i want to monitor, it's a log file that is uses by an antivirus update program.

I want the latest lines check that starts with : WARNING

I created a Text Log
looking for string : WARNING
Warn of : last new event
Display found line

I'm using RMA on the remote server!

Other check's like file count works without any problem!

The problem is now that it can't open the file, but if i try it on the server, it opens without any problems.

RMA: 301-Cannot open file

How or what do i have to change so that the text log option will work?

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

Re: Text Log

Post by KS-Soft Europe »

Harland Adelaars wrote:RMA: 301-Cannot open file
Please note, if the test is performed by RMA, the file, you have specified into "File" input box, should be related to filesystem on machine, where RMA is running, not HostMonitor. Are you able to open this file from the machine where RMA is running?
Does RMA started as service or as an application? In case it is started as service, it shoud have necessary rights. We recommend you to start RMA service under admin account. You may specify account using standard Windows Service applet (Start > Run > Services.msc then go to "KS Remote Monitoring Agent" > "Log on" tab). On the other hand, if RMA is started as service, it does not recognize any mapped drives leters. In such case I recommend you to change mapped drive letter to UNC path, e.g. instead "q:" you should specify "\\server\share", where "q:" is a mapped drive letter.

Regards,
Max
Harland Adelaars
Posts: 12
Joined: Thu Dec 28, 2006 9:48 am

Post by Harland Adelaars »

Hi,

Yes i'm using RMA, when i first copy the file to a new file, then everything works without problems. So i changed the script for updating the AV software. Now the check works for 50%.

What i don't understand is that if the last line contans the text WARNING, the check goes to bad, but after 5 min. when the check runs againg the check goes back to good! And still the last line is WARNING?

What i'm trying to create is a readtext log, for the last line, if it starts with WARNING the check has to go to bad, and it can only change when the file doesn't end with WARNING.

How do i configure like the above options?

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

Post by KS-Soft Europe »

Harland Adelaars wrote:What i don't understand is that if the last line contans the text WARNING, the check goes to bad, but after 5 min. when the check runs againg the check goes back to good! And still the last line is WARNING?
It is a correct behaviour.
Quote from the manual:
http://www.ks-soft.net/hostmon.eng/tests.htm#textlog
=====================
Note: HostMonitor changes test status to "Bad" only when it has found NEW event(s) that satisfies all specified requirements. If, after the next probe, the monitor does not find a new "Bad" event, it changes the test status to "Ok".
=====================
Harland Adelaars wrote:What i'm trying to create is a readtext log, for the last line, if it starts with WARNING the check has to go to bad, and it can only change when the file doesn't end with WARNING.
Hm. In such case I would recommend you to use Schell Script method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

You just should go to Script Manager, create new script and specify the following information:
Start cmd: cmd /c %Script% %Params%
Script:

Code: Select all

@echo off
rem %1 - full log file name
rem %2 - string to check

SET error_description=""
SET last_line=""

IF "%1"=="" (
   SET error_description=file not found
   goto fail
)

IF NOT EXIST %1 (
   SET error_description=file not found
   goto fail
)

FOR /F "tokens=* delims=" %%A IN ('type %1') DO SET last_line=%%A

echo %last_line% | find "%2" > NUL
IF ERRORLEVEL 1 (
   echo ScriptRes:Ok:
   goto end
) ELSE (
   SET error_description=%last_line%
   goto fail
)

:fail
   echo ScriptRes:Bad:%error_description%
:end
This script requires two params. First is the full log file name, and the second is the string you want to check, WARNING in your case.

So, you should specify into "Params" box of "Test Properties" window following information:

Code: Select all

C\Log\some_log_file.log WARNING
Please note, script may work incorrect in case the log file path contains spaces, like "C:\Program Files\...".



Regards,
Max
Harland Adelaars
Posts: 12
Joined: Thu Dec 28, 2006 9:48 am

Post by Harland Adelaars »

This works for the BAD results, but on the good servers, we get a script error back.

Can't find the problem.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Harland Adelaars wrote:This works for the BAD results, but on the good servers, we get a script error back.
Could you explain more clear?
What exact error do you get? Please, provide more information. It helps us to solve the problem quickly.

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

Post by KS-Soft Europe »

Foregoing script is quite clear. It takes the last line in specified file and checks for the containing certain string. Probably, you specified incorect parameters for the test. You may copy the script into .bat file and run from the command line to check how it works.

What exact parameters (filename and string to check) have you specified into the "Params" input box?

Regards,
Max
Harland Adelaars
Posts: 12
Joined: Thu Dec 28, 2006 9:48 am

Post by Harland Adelaars »

I Changed the script,

@echo off
rem %1 - full log file name
rem %2 - string to check

SET error_description=""
SET last_line=""

echo ScriptRes:Ok:0

IF "%1"=="" (
SET error_description=file not found
goto fail
)

IF NOT EXIST %1 (
SET error_description=file not found
goto fail
)

FOR /F "tokens=* delims=" %%A IN ('type %1') DO SET last_line=%%A

echo %last_line% | find "%2" > NUL

IF ERRORLEVEL 1 (
echo ScriptRes:Ok:0
goto end
) ELSE (
SET error_description=%last_line%
goto fail
)

:fail
echo ScriptRes:Bad:%error_description%
:end

Then the script works fine by me...

Thanks for the help
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Harland Adelaars wrote:Then the script works fine by me...

Ok. Glad to hear that.
Harland Adelaars wrote:Thanks for the help
You are welcome.

Regards,
Max
THEngels
Posts: 6
Joined: Tue Sep 04, 2007 2:53 am
Location: Wijnandsrade (NL)

Post by THEngels »

KS-Soft Europe wrote: Hm. In such case I would recommend you to use Schell Script method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

You just should go to Script Manager, create new script and specify the following information:
Start cmd: cmd /c %Script% %Params%
Script:

Code: Select all

*script*
This script requires two params. First is the full log file name, and the second is the string you want to check, WARNING in your case.

So, you should specify into "Params" box of "Test Properties" window following information:

Code: Select all

C\Log\some_log_file.log WARNING
Please note, script may work incorrect in case the log file path contains spaces, like "C:\Program Files\...".

Regards,
Max
Hi, I had the same issue as Mr.Adelaars, I solved it, partially, with your script, which I found on this page. The problem however is that I need it to work with directory listings with spaces (like c:\program files\..), is there any workaround to solve this issue?

Thanks in advance for any help,

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

Post by KS-Soft Europe »

THEngels wrote:The problem however is that I need it to work with directory listings with spaces (like c:\program files\..), is there any workaround to solve this issue?
The simplest solution I see, is to use "\Progra~1" instead of "\Program Files" in the path (without quotes!). For instance, you should specify the path like: C:\Progra~1\.. instead of c:\program files\..
Could you try that?

Regards,
Max
THEngels
Posts: 6
Joined: Tue Sep 04, 2007 2:53 am
Location: Wijnandsrade (NL)

Post by THEngels »

That indeed does work thanks! However, if I have a dir called "copy of test" using "copy~1" does not work.

If I use this little modification of your code:

Code: Select all

@echo off
rem %1 - full log file name
rem %2 - string to check

SET error_description=""
SET last_line=""

IF NOT EXIST %1 (
   SET error_description=file not found
   goto fail
)

FOR /F "tokens=* delims=" %%A IN ('type %1') DO SET last_line=%%A

echo %last_line% | find "%2" > NUL
IF ERRORLEVEL 1 (
   echo ScriptRes:Ok:
   goto end
) ELSE (
   SET error_description=%last_line%
   goto fail
)

:fail
   echo ScriptRes:Bad:%error_description%
:end
and use it in the command prompt as follows:

Code: Select all

ted.bat "D:\copy of test\copy of test.txt" WARNING
Where ted.bat contains the said code, it does return results. However if I try to use this code within HostMonitor the script returns no results (possibly due to the quotation marks (") ? ).

Is there a possible workaround for this?

Thanks in advance for any help,

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

Post by KS-Soft Europe »

THEngels wrote:However if I try to use this code within HostMonitor the script returns no results (possibly due to the quotation marks (") ? ).
Is there a possible workaround for this?
Yes, you are right. Looks like Hostmonitor does not work properly with quoted parameters. I think, we will fix the problem in next version. As a workaround, I would suggest you to use hardcoded file path with in the script body:
@echo off
rem %1 - string to check

SET error_description=""
SET last_line=""

FOR /F "tokens=* delims=" %%A IN ('type "C:\Temp\copy of test\copy of test\test.txt"') DO SET last_line=%%A

echo %last_line% | find "%1" > NUL
IF ERRORLEVEL 1 (
echo ScriptRes:Ok:
goto end
) ELSE (
SET error_description=%last_line%
goto fail
)

:fail
echo ScriptRes:Bad:%error_description%
:end
As you can see, the script nowrequires just one parameter. You may slightly modify and use foregoing script until we fix the problem. Sorry for the inconvenience.

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

Post by KS-Soft »

HostMonitor correctly resolves parameters. Problem is related to "cmd /c" command that does not care about number of parameters and interprets list of parameters as single string. E.g. you may try to execute something like cmd /c "test.bat" "param1". You will receive 'test.bat" "param' is not recognized as an internal or external command error.
We can modify HostMonitor a little to use ShortPathName for temporary files (script)... but in such case cmd /c will pass parameters in quotes (e.g. command cmd /c test.bat "param1" will assign "param1" to %1 variable, not param but "param". It can be a problem as well :roll:

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

Post by KS-Soft »

Ok, update available at www.ks-soft.net/download/hm684d.zip
Please install version 6.82 before using this update.

This version uses ShortPathName for temporary files (scripts) so it may pass path to the script to cmd.exe without using quotation marks. However if you need to use parameters with space, you should use "" for such parameters and in some cases you may need use %~1 .. %~n variables in your BAT file. In such case cmd.exe will remove any surrounding quotes (") and process BAT file correctly

Regards
Alex
Post Reply