dpeterka
Joined: 21 Jul 2003 Posts: 13
|
Posted: Sat Aug 13, 2005 10:10 pm Post subject: 'wrapper' for non-dependant scripts |
|
|
We run a Java engine (WebSphere) which hosts a number of applications any of which can fail for a number of reasons that makes the usage of Host Monitor's built in dependencies ability not as useful as we would like. As a result we've made a 'wrapper' test.
The idea is that a failed test writes to a text log and a master test reads from that text log and generates a global alert. For our purposes this opens a single ticket in our help desk application rather than a whole bunch.
Children tests on failure run a Action Profile that executes an external script like so:
cscript D:\HostMonitor4\TicketGen\shared\WriteLog.vbs "%TestName%"
Contents of this script are:
Dim filename, ArgObj, TestName, objFSO, thisFile
filename = "D:\HostMonitor4\TicketGen\shared\log.txt"
Set ArgObj = WScript.Arguments
TestName = ArgObj(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set thisFile = objFSO.OpenTextFile(filename, 8, True)
'Append the TestName to the file.
thisFile.WriteLine TestName
'Cleanup
thisFile.close
Set objFSO = nothing
The Master test is VBS test that contains the following:
const statusAlive = "Host is alive:"
const statusDead = "No answer:"
const statusUnknown = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk = "Ok:"
const statusBad = "Bad:"
const statusBadContents = "Bad contents:"
FUNCTION PerformTest()
Dim filename, fso,f1,thisFile
Set fso = CreateObject("Scripting.FileSystemObject")
filename = "D:\HostMonitor4\TicketGen\shared\log.txt"
On Error Resume Next
set f1 = fso.OpenTextFile(filename,1)
thisFile = f1.ReadAll
On Error GoTo 0
If thisFile <> "" Then
PerformTest=statusBad&thisFile
f1.Close
Else
PerformTest=statusAlive
f1.Close
End If
END FUNCTION
...........
You can get the results of the failed tests by putting in %REPLY% |
|