|
View previous topic :: View next topic |
Author |
Message |
grzchr15
Joined: 12 Dec 2007 Posts: 3
|
Posted: Thu Mar 13, 2008 2:32 am Post subject: How to debug error at hms scripts |
|
|
We have a hms script like:
Example
Code: | ExecuteProgram 1000 wget http://webserver/cms_ip_tab?rma=%CommentLine1% -O "C:\Program Files\HostMonitor6\Lists\cms_ip_tab-%CommentLine1%.txt"
ImportFromFile cms_ip_tab-%CommentLine1%.txt SkipDuplicates WriteLog
SaveTestList servername.hml |
This test files contains at minimum a test like
%CommentLine1%=agentservernameXXX
Code: | ImportMode = Replace
DefaultFolder = Root\rma-agentservername\
; ------- Test #1 -------
Method = HTTP
;--- Common properties ---
DestFolder = Root\rma-agentservernameXXX\
Title = http://home.andritz.com/cms_ip_tab?rma=agentservernameXXX
Comment =agentservernameXXX
RelatedURL = http://home.andritz.com/cms_ip_tab?rma=agentservernameXXX
ScheduleMode= OneTestPerDay
ScheduleTime= 02:00:00
Alerts = reload-cms_ip_tab-reload
ReverseAlert= No
UnknownIsBad= Yes
WarningIsBad= Yes
UseCommonLog= Yes
PrivLogMode = Default
CommLogMode = Default
SyncCounters= Yes
SyncAlerts = No
DependsOn = list
;--- Test specific properties ---
URL = http://home.andritz.com/cms_ip_tab?rma=agentservernameXXX
Request = GET
Redirect = Yes
PostData =
Agent = KSHostMonitor:/1.0
Timeout = 50000
AllowCookies= No
OtherHeaders=
AuthMethod = None
CheckContents= mustcontain
CExpression = SERIAL=2008213
CMatchCase = No
CWholeWord = No
UseFrames = No
UseImages = No
...Some more tests
|
The action for bad result ( It compares the SERIAL=2008213 ) is to run the action for so long as the test is bad.
But when there is a script error in the hms script , it will never change.
So again
How to debug error at hms scripts
How to see the error like "Folder in Hostmonitor does not exist"
and maybe a feature request: It would be nice to run hms scripts also at RCC (Remote console) |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Mar 13, 2008 3:38 am Post subject: Re: How to debug error at hms scripts |
|
|
grzchr15 wrote: | How to debug error at hms scripts | Hm. In fact there is no well known principles to debug "HMS Script". However, you may "echo" each line of the script into particular file to check macro variables are properly resolved. You just should duplicate each string in a script file with "ExecuteProgram" command in order to start "cmd /c echo" system command. E.g.:
Code: | ExecuteProgram 1000 wget http://webserver/cms_ip_tab?rma=%CommentLine1% -O "C:\Program Files\HostMonitor6\Lists\cms_ip_tab-%CommentLine1%.txt"
ExecuteProgram 10000 cmd /c echo ExecuteProgram 1000 wget http://webserver/cms_ip_tab?rma=%CommentLine1% -O "C:\Program Files\HostMonitor6\Lists\cms_ip_tab-%CommentLine1%.txt" > c:\script_debug.log
ImportFromFile cms_ip_tab-%CommentLine1%.txt SkipDuplicates WriteLog
ExecuteProgram 10000 cmd /c echo ImportFromFile cms_ip_tab-%CommentLine1%.txt SkipDuplicates WriteLog >> c:\script_debug.log
SaveTestList servername.hml | As you may see, foregoing script will save all lines into c:\script_debug.log file.
grzchr15 wrote: | How to see the error like "Folder in Hostmonitor does not exist" | "ImportFromFile" command has optional "WriteLog" parameter, that tells HostMonitor to record to the system log file information about all errors and warnings during the import process. System log is specified in "Options" -> "System Log" tab.
On the other hand, you may use "CreateFolder" commands into import file. This helps you to avoid "Folder in Hostmonitor does not exist" errors. Quote from the manual:
http://www.ks-soft.net/hostmon.eng/examples/import1.htm
===================================
CreateFolder = Root\USA Branch\Support\part2\
; creates new folder(s). The value of this parameter should specify the full
; path to the folder that you want to create.
; E.g. CreateFolder = Root\USA Branch\Support\part2\ will successively create
; folders USA Branch (in the Root folder), Support (in USA Branch subfolder)
; and part2 (in Support subfolder). Of course if some (or all) of specified
; folders already exist, HostMonitor will not create second copy of them.
===================================
grzchr15 wrote: | and maybe a feature request: It would be nice to run hms scripts also at RCC (Remote console) | Need to think about it...
Regards,
Max |
|
Back to top |
|
|
grzchr15
Joined: 12 Dec 2007 Posts: 3
|
Posted: Thu Mar 13, 2008 12:34 pm Post subject: '%DateTime%' gets split into multiply strings in HMS? |
|
|
How to avoid broken macro parameters?
HMS Code
Code: | ExecuteProgram 10000 cmd /c echo ExecuteProgram 1000 "C:\jobs\hostmonitor\set.cmd" OK '%DateTime%' '%TestName%' '%Status%' '%Reply_CStyle%' '%TestMethod%' ""%LastTestTime%"" '%StatusID%' '%SimpleStatus%' '%Agent%' '%AckComment%' '%LastStatus%' '%PreviousStatus%' '%TaskComment%' '%TestID%' '%CommentLine1%' >>"C:\jobs\hostmonitor\hmslog.log" |
Batch File
Code: | type "C:\Program Files\HostMonitor6\Lists\set.log" >"C:\Program Files\HostMonitor6\Lists\setall.log"
set >"C:\Program Files\HostMonitor6\Lists\set.log"
echo 1: (%1) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 2: (%2) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 3: (%3) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 4: (%4) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 5: (%5) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 6: (%6) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 7: (%7) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 8: (%8) >>"C:\Program Files\HostMonitor6\Lists\set.log"
shift
shift
shift
shift
shift
shift
shift
shift
echo 9: (%1) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 10: (%2) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 11: (%3) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 12: (%4) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 13: (%5) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 14: (%6) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 15: (%7) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 16: (%8) >>"C:\Program Files\HostMonitor6\Lists\set.log"
type set.log |
Broken output:
Code: | 1: (OK)
2: ('3/13/2008) <- Broken Date
3: (7:20:38) <- Broken Date
4: (PM') <- Broken Date
5: ('http://servername/cms_ip_tab?rma)
6: (vaxsms001')
7: ('Host) <- Broken Status
8: (is) <- Broken Status
9: (alive') <- Broken Status
10: ('532) <- Broken Time
11: (ms') <- Broken Time
12: ('HTTP)
13: (test)
14: ((servername)')
15: ('3/13/2008)
16: (7:20:22)
|
How to avoid broken macro parameters?
Thanks again for support and quick responsees |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Thu Mar 13, 2008 1:27 pm Post subject: Re: '%DateTime%' gets split into multiply strings in HMS? |
|
|
grzchr15 wrote: | How to avoid broken macro parameters? | As you know, command line parser recognizes the batch parameters, separated by space. So, %DateTime%, represented by '3/13/2008 7:20:38 PM' value, is recognized as 3 parameters. If you want to pass a parameter, that contains spaces, you should enclose it into quotation marks , e.g. "%DateTime%". In this case you will see the date time as a single parameter in your oputput file: ("03/13/2008 21:19:01"). To get rid of surrounding quotation marks , you should use ~ sign, e.g %~1%, %~2%, etc. According to the microsoft: Code: | %~I - Expands %I which removes any surrounding quotation marks (""). |
So, in your HMS code you should enclose all variables into quotation marks ("%DateTime%" "%TestName%" "%Status%", etc.) and in batch file add the ~ sign to the parameters variable:
Code: | type "C:\Program Files\HostMonitor6\Lists\set.log" >"C:\Program Files\HostMonitor6\Lists\setall.log"
set >"C:\Program Files\HostMonitor6\Lists\set.log"
echo 1: (%~1) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 2: (%~2) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 3: (%~3) >>"C:\Program Files\HostMonitor6\Lists\set.log"
echo 4: (%~4) >>"C:\Program Files\HostMonitor6\Lists\set.log"
...
echo 16: (%~8) >>"C:\Program Files\HostMonitor6\Lists\set.log"
type set.log |
Regards,
Max |
|
Back to top |
|
|
|
|
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
|