Text Log
-
- Posts: 12
- Joined: Thu Dec 28, 2006 9:48 am
Text Log
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
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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Re: Text Log
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?Harland Adelaars wrote:RMA: 301-Cannot open file
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
-
- Posts: 12
- Joined: Thu Dec 28, 2006 9:48 am
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
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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
It is a correct behaviour.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?
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".
=====================
Hm. In such case I would recommend you to use Schell Script method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShellHarland 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.
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
So, you should specify into "Params" box of "Test Properties" window following information:
Code: Select all
C\Log\some_log_file.log WARNING
Regards,
Max
-
- Posts: 12
- Joined: Thu Dec 28, 2006 9:48 am
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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
What exact parameters (filename and string to check) have you specified into the "Params" input box?
Regards,
Max
-
- Posts: 12
- Joined: Thu Dec 28, 2006 9:48 am
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
@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
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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?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: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.Code: Select all
*script*
So, you should specify into "Params" box of "Test Properties" window following information:Please note, script may work incorrect in case the log file path contains spaces, like "C:\Program Files\...".Code: Select all
C\Log\some_log_file.log WARNING
Regards,
Max
Thanks in advance for any help,
Best Regards,
THEngels
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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\..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?
Could you try that?
Regards,
Max
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:
and use it in the command prompt as follows:
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
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
Code: Select all
ted.bat "D:\copy of test\copy of test.txt" WARNING
Is there a possible workaround for this?
Thanks in advance for any help,
Best Regards,
Ted
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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: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?
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.@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
Regards,
Max
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
Regards
Alex
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

Regards
Alex
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
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