PolyServe Object Discovery

PolyServe.MatrixServer.DiscoverCluster (Discovery)

Element properties:

TargetMicrosoft.Windows.Server.Computer
EnabledTrue
Frequency300
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="PolyServe.MatrixServer.DiscoverCluster" Enabled="true" Target="Windows!Microsoft.Windows.Server.Computer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="PolyServe.MatrixServer.PSObject">
<Property PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
<Property PropertyID="PSClusterName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.Service">
<Property PropertyID="AppName"/>
<Property PropertyID="VirtualIP"/>
<Property PropertyID="PrimaryServer"/>
<Property PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.DeviceMonitorBase">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.Cluster">
<Property PropertyID="Server"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.Node">
<Property PropertyID="NetworkName"/>
<Property PropertyID="PSSoftwareVer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.VHostCIFSService">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.VHostSQLService">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.VHostMSDTCService">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.VHostSSASService">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.VHostCustomService">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.ServiceMonitor">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.MatrixVirtualFileShare">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.MatrixFileShare">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.DeviceMonitor">
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="AppName"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="VirtualIP"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="PrimaryServer"/>
<Property TypeID="PolyServe.MatrixServer.Service" PropertyID="ActiveServer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.FileSystem">
<Property PropertyID="PSLabel"/>
<Property PropertyID="PSSize"/>
<Property PropertyID="PSFree"/>
<Property PropertyID="MountLoc"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="PSClusterName"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="PolyServe.MatrixServer.NetworkInterface">
<Property PropertyID="IPAddress"/>
<Property PropertyID="AdminTraffic"/>
<Property PropertyID="Netmask"/>
<Property PropertyID="Computer"/>
<Property TypeID="PolyServe.MatrixServer.PSObject" PropertyID="ObjectKey"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="PolyServe.MatrixServer.ClusterContainServer"/>
<DiscoveryRelationship TypeID="PolyServe.MatrixServer.ServiceContainServer"/>
<DiscoveryRelationship TypeID="PolyServe.MatrixServer.FileSystemContainServer"/>
<DiscoveryRelationship TypeID="PolyServe.MatrixServer.ClusterContainService"/>
<DiscoveryRelationship TypeID="PolyServe.MatrixServer.ClusterContainFileSystem"/>
<DiscoveryRelationship TypeID="PolyServe.MatrixServer.NodeContainsInterface"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>300</IntervalSeconds>
<SyncTime/>
<ScriptName>PolyServe.MatrixServer.Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script>
Option Explicit

'------------- begin URI mapping info ------------------
dim URI_CLUSTER_PREFIX, URI_STYPE_CLUSTER_TYPE, URI_STYPE_FS, URI_STYPE_VHOST, URI_STYPE_SERVICEMON
dim URI_STYPE_DEVMON, URI_STYPE_SERVER, URI_STYPE_IFACE, URI_STYPE_FILESERVING_VFS
'begin_cat_generated
URI_CLUSTER_PREFIX = "mx://"
URI_STYPE_CLUSTER_TYPE = "mx://"
URI_STYPE_FS = "/storage/filesystem/"
URI_STYPE_VHOST = "/application/standard/"
URI_STYPE_SERVICEMON = "/application/standard/servicemonitor/"
URI_STYPE_DEVMON = "/application/standard/devicemonitor/"
URI_STYPE_SERVER = "/config/server/"
URI_STYPE_IFACE = "/config/server/interface/"
URI_STYPE_FILESERVING_VFS = "/application/fileserving/virtualfileshare/"
'end_cat_generated
'------------- end URI mapping info ------------------

'************
'DEBUG variables
Dim runatcmd, printdebug, arrObjectsCreated()
ReDim arrObjectsCreated(-1)

printdebug = 0 ' set to 1 if you want a file "discovery.out" generated in c:\
runatcmd = 0 'set to 1 if you want to run this script on the cmd line to debug it

'************

Dim oArgs
Set oArgs = WScript.Arguments


Set oArgs = WScript.Arguments
if oArgs.Count &lt; 3 Then
runatcmd = 1
End If

'----
Dim SourceID, ManagedEntityId, TargetComputer
Dim oAPI, oDiscoveryData
'----
Dim oCluster, oServer, clusterName, swVersion
'----
Dim objFSO, objInpStream, infoInpStream, queryInpStream, strNextLine, arrNextLine, queryFSExportXML
Dim serverid, freeSpace, clusterid

Dim arrIPs(), arrInterfaceConfig(), arrInterfaceStatus()
Dim arrServerConfig(), arrFSConfig(), arrMountConfig(), arrMountStatus()
Dim arrServiceConfig(), arrServiceStatus(), arrDeviceConfig(), arrDeviceStatus()
Dim arrVhostStatus(), arrVhostConfig()
ReDim arrInterfaceConfig(-1)
ReDim arrInterfaceStatus(-1)
Redim arrServerConfig(-1)
ReDim arrFSConfig(-1)
ReDim arrMountConfig(-1)
ReDim arrMountStatus(-1)
ReDim arrServiceConfig(-1)
ReDim arrServiceStatus(-1)
ReDim arrDeviceConfig(-1)
ReDim arrDeviceStatus(-1)
ReDim arrVhostStatus(-1)
ReDim arrVhostConfig(-1)

if (runatcmd=0) then
SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)
Set oAPI = CreateObject("MOM.ScriptAPI")
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
else
TargetComputer = "SERVERC.devcluster.tomas.com"
end if

Const ForReading = 1
Dim outStream

Set objFSO = CreateObject("Scripting.FileSystemObject")

if (printdebug) then
Set outStream = objFSO.OpenTextFile("c:\discovery.out", 2, true)'for writing, create=true

Dim objNet
Set objNet = CreateObject("WScript.NetWork")

Dim strInfo
strInfo = "User Name is " &amp; objNet.UserName
debugWrite(strInfo)
strInfo = "Computer Name is " &amp; objNet.ComputerName
debugWrite(strInfo)
strInfo = "Domain Name is " &amp; objNet.UserDomain
debugWrite(strInfo)
end if

'HTTPChannel for production, FSChannel for develop/debug
openHTTPChannel()

'openFSChannel()
'TODO: A Check on objInpStream, infoInpStream validation

buildArrIPs()

'1st the Cluster object
call subProcessCluster(infoInpStream)

Dim objInpIdx
objInpIdx = -1

For Each strNextLine in objInpStream
objInpIdx=objInpIdx+1
arrNextLine = Split(strNextLine, " ")
if (Ubound(arrNextLine) &gt;= 3) then
select case ucase(arrNextLine(2))
case "CONFIG"
select case ucase(arrNextLine(3))
case "VHOST"
ReDim Preserve arrVhostConfig(UBound(arrVhostConfig)+1)
arrVhostConfig(UBound(arrVhostConfig)) = strNextLine
case "SERVER"
ReDim Preserve arrServerConfig(UBound(arrServerConfig)+1)
arrServerConfig(UBound(arrServerConfig)) = strNextLine
case "FILESYSTEM"
ReDim Preserve arrFSConfig(UBound(arrFSConfig)+1)
arrFSConfig(UBound(arrFSConfig)) = strNextLine
case "MOUNT"
ReDim Preserve arrMountConfig(UBound(arrMountConfig)+1)
arrMountConfig(UBound(arrMountConfig)) = strNextLine
case "IFACE"
ReDim Preserve arrInterfaceConfig(UBound(arrInterfaceConfig)+1)
arrInterfaceConfig(UBound(arrInterfaceConfig)) = strNextLine
case "SERVICE"
ReDim Preserve arrServiceConfig(UBound(arrServiceConfig)+1)
arrServiceConfig(UBound(arrServiceConfig)) = strNextLine
case "DEVICE"
ReDim Preserve arrDeviceConfig(UBound(arrDeviceConfig)+1)
arrDeviceConfig(UBound(arrDeviceConfig)) = strNextLine
case else
end select
case "STATUS"
select case ucase(arrNextLine(3))
case "VHOST"
ReDim Preserve arrVhostStatus(UBound(arrVhostStatus)+1)
arrVhostStatus(UBound(arrVhostStatus)) = strNextLine
case "MOUNT"
ReDim Preserve arrMountStatus(UBound(arrMountStatus)+1)
arrMountStatus(UBound(arrMountStatus)) = strNextLine
case "IFACE"
ReDim Preserve arrInterfaceStatus(UBound(arrInterfaceStatus)+1)
arrInterfaceStatus(UBound(arrInterfaceStatus)) = strNextLine
case "SERVICE"
ReDim Preserve arrServiceStatus(UBound(arrServiceStatus)+1)
arrServiceStatus(UBound(arrServiceStatus)) = strNextLine
case "DEVICE"
ReDim Preserve arrDeviceStatus(UBound(arrDeviceStatus)+1)
arrDeviceStatus(UBound(arrDeviceStatus)) = strNextLine
case else
end select
case else
end select
end if
Next

'--
call subProcessServer(arrServerConfig)
call subProcessNetworkInterface(arrInterfaceConfig, arrInterfaceStatus, TargetComputer)
call subProcessFileSystem(arrFSConfig, arrMountConfig, arrMountStatus, TargetComputer)
call subProcessVhost(arrVhostConfig, arrVhostStatus, TargetComputer)
call subProcessService(arrServiceConfig, arrServiceStatus, arrVhostConfig, TargetComputer)
call subProcessDevice(arrDeviceConfig, arrDeviceStatus, TargetComputer)

if (printdebug) then

For Each strNextLine in arrObjectsCreated
debugWrite(strNextLine)
Next
outStream.Close()

end if

'--
if (runatcmd=0) then
Call oAPI.Return(oDiscoveryData)
end if


'*****************************************************************
'FORMAT:
Sub buildArrIPs()
Dim strComputer, objWMIService, colNetAdapterItems, strAddress, objItem
Dim tmp
strComputer = "."
ReDim arrIPs(0)
arrIPs(0) = "init"
'GATHER a list of the interface addresses
tmp = "winmgmts:\\" + strComputer + "\root\cimv2"
Set objWMIService = GetObject(tmp)
Set colNetAdapterItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colNetAdapterItems
For Each strAddress in objItem.IPAddress
ReDim Preserve arrIPs(UBound(arrIPs)+1)
arrIPs(Ubound(arrIPs)) = strAddress
Next
Next
End Sub
'*****************************************************************


'*****************************************************************
'FORMAT:
Sub openFSChannel()
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists("C:\pulselet.status")) Then
Set objInpStream = objFSO.OpenTextFile("c:\pulselet.status", ForReading)
End If
If (objFSO.FileExists("C:\pulselet.info")) Then
Set infoInpStream = objFSO.OpenTextFile("c:\pulselet.info", ForReading)
End If
End Sub
'*****************************************************************
'*****************************************************************
'FORMAT:
Sub openHTTPChannel()
Dim url
Dim xmlhttp
Dim tempInputString

url = "https://127.0.0.1:6771/cgi-bin/pmxs/pulselet?-C STATUS"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setOption(2) = 13056 'SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xmlhttp.open "GET", url, false

On error resume next
xmlhttp.send ""
If Err.Number &lt;&gt; 0 Then
Call oAPI.Return(oDiscoveryData)
wscript.quit()
End If
on error goto 0

tempInputString = cstr(xmlhttp.ResponseText)
debugWrite(tempInputString)

objInpStream = Split(trim(tempInputString), vbCRLF)

set xmlhttp = Nothing
url = "https://127.0.0.1:6771/cgi-bin/pmxs/pulselet?--info"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setOption(2) = 13056 'SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xmlhttp.open "GET", url, false
xmlhttp.send ""
tempInputString = cstr(xmlhttp.ResponseText)
debugWrite(tempInputString)
infoInpStream = Split(trim(tempInputString), vbCRLF)
set xmlhttp = Nothing
End Sub
'*****************************************************************
'*****************************************************************
'FORMAT:0 5852 {dc235f08-136f-4ddd-9d98-9a4ed7415603} {First Cluster}
'FORMAT:- - VERSION pmxs-3.6.0 105 3 Windows 15.11.145.107
Sub subProcessCluster(inpstream)
Dim arrLine, arrLine2, line
Dim oHealthService, oRel1
Dim objShell, objExecObject

for each line in inpstream
do until (0=1)
arrLine = Split(line, "{")
if (UBound(arrLine) &lt; 2) then exit do
if (InStr(trim(arrLine(0)), "-") = 0) then
clusterid = trim(arrLine(1))
clusterName = trim(arrLine(2))
exit for
end if
exit do
loop
next
for each line in inpstream
do until (0=1)
arrLine = Split(line, " ")
if (UBound(arrLine) &lt; 7) then exit do
if (arrLine(2) = "VERSION") then
swVersion = arrLine(3)
serverid = arrLine(7)
exit for
end if
exit do
loop
next

if (clusterid = "") then 'it would be very difficult to recover if we don't have a cluster.
Call oAPI.Return(oDiscoveryData)
wscript.quit()
end if

if(StrComp(swVersion,"pmxs-3.6",1)&lt; 0) then 'wrong version, parsing might be different.
Call oAPI.Return(oDiscoveryData)
wscript.quit()
End If

clusterid = Replace(clusterid, "}", "")
clusterName = Replace(clusterName, "}", "")

if (runatcmd=0) then
set oCluster = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.Cluster']$")
call oCluster.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid)
call oCluster.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$", clusterName)
call oCluster.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Cluster']/Server$",serverid)
call oCluster.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", clusterName)
call oDiscoveryData.AddInstance(oCluster)

'get health service to manage the cluster object
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel1.Source = oHealthService
oRel1.Target = oCluster
call oDiscoveryData.AddInstance(oRel1)
end if
End Sub

'*******************************************************************
'FORMAT:0 4776 CONFIG SERVER 15.11.145.107 BENIGN {Windows Server 2003 "R2"} {x86 Service Pack 2 (Build 3790)}
'FORMAT:0 4776 STATUS SERVER 15.11.145.107 UP ENABLED SAN Active
Sub subProcessServer(arrServerConfig)

Dim oHealthService, oRel1, oRel2, objVarServer
Dim strLine, firstSplit, secondSplit, anteNameSplit, serverIP, objNslookup, strNslookup, strDispName
Dim shell, isInvolved

debugWrite("start of the output, #lines: " + cstr(Ubound(arrServerConfig)))

For Each strLine In arrServerConfig
Do Until (0=1)
debugWrite(strLine)

firstSplit = Split(trim(strLine), "{")
If (Ubound(firstSplit) &lt; 1) Then Exit Do 'parse error
anteNameSplit = Split(firstSplit(0), " ")
If (Ubound(anteNameSplit) &lt; 5) Then Exit Do 'parse error

isInvolved = false

For Each serverIP In arrIPs
if (InStr(anteNameSplit(4), serverIP) &gt; 0) then
isInvolved = true
exit for
end if
Next

'Create Server Object
if (runatcmd=0) then

debugWrite("subProcessServer_dbg: creating server: " + anteNameSplit(4))

Set shell = CreateObject("WScript.Shell")
Set objNslookup = shell.Exec("%comspec% /c nslookup " + anteNameSplit(4))

Do While Not objNslookup.StdOut.AtEndOfStream
strNslookup = objNslookup.StdOut.ReadLine()
If not InStr(strNslookup, "Name:") = False Then
Exit Do
End If
Loop

secondSplit = Split(trim(strNslookup), ":")
If (Ubound(secondSplit) &lt; 1) Then
'parse error
strDispName = anteNameSplit(4)

else

strDispName = trim(secondSplit(1))

end if

debugWrite("subProcessServer_dbg: DNS lookup: " + trim(secondSplit(1)))

if (isInvolved = true) then

set oServer = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.Node']$")
call oServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_SERVER + anteNameSplit(4))
call oServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Node']/PSSoftwareVer$",swVersion)
call oServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$",clusterName)
'call oServer.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", TargetComputer)
'call oServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Node']/NetworkName$",TargetComputer)
call oServer.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", strDispName)
call oServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Node']/NetworkName$",anteNameSplit(4))
call oDiscoveryData.AddInstance(oServer)

'Create Cluster-Server Relationship Object
set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ClusterContainServer']$")
oRel1.Source = oCluster
oRel1.Target = oServer
call oDiscoveryData.AddInstance(oRel1)

'Get the health service to monitor the PolyServe node
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
'call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",anteNameSplit(4))
set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel2.Source = oHealthService
oRel2.Target = oServer
call oDiscoveryData.AddInstance(oRel2)

else

set objVarServer = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.Node']$")
call objVarServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_SERVER + anteNameSplit(4))
call objVarServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Node']/PSSoftwareVer$",swVersion)
call objVarServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$",clusterName)
'call oServer.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", TargetComputer)
'call oServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Node']/NetworkName$",TargetComputer)
call objVarServer.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", strDispName)
call objVarServer.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Node']/NetworkName$",anteNameSplit(4))
call oDiscoveryData.AddInstance(objVarServer)

'Create Cluster-Server Relationship Object
set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ClusterContainServer']$")
oRel1.Source = oCluster
oRel1.Target = objVarServer
call oDiscoveryData.AddInstance(oRel1)

'Get the health service to monitor the PolyServe node
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel2.Source = oHealthService
oRel2.Target = objVarServer
call oDiscoveryData.AddInstance(oRel2)

end if

end if

Exit Do
Loop
Next
End Sub
'*****************************************************************

'*****************************************************************
'FORMAT:&lt;number/&gt; &lt;number/&gt; CONFIG VHOST &lt;parameter id="address" typeid="IPAddress"/&gt; &lt;parameter id="severity" typeid="VhostSeverity"/&gt; &lt;parameter id="ability" typeid="Ability"/&gt; &lt;parameter id="data" typeid="QuotedString"/&gt; &lt;parameter id="type" typeid="QuotedString"/&gt; &lt;parameter id="activityConfiguration" typeid="Integer"/&gt; &lt;parameter id="application" typeid="QuotedString"/&gt; VHOST &lt;parameter id="interfaces" typeid="IPAddressSequence"/&gt;
'FORMAT:&lt;number/&gt; &lt;number/&gt; STATUS VHOST &lt;parameter id="address" typeid="IPAddress"/&gt; &lt;parameter id="interface" typeid="IPAddress"/&gt; &lt;parameter id="activity" typeid="Activity"/&gt; &lt;parameter id="lastErrorCode" typeid="Integer"/&gt; &lt;parameter id="lastErrorString" typeid="QuotedString"/&gt;
Sub subProcessVHost(arrVhostConfig, arrVhostStatus, TargetComputer)
Dim VirtualIP, ServiceType, AppName, PrimaryServer, ActiveServer
Dim rexp, rexpRet, arrRexpRet, pattern, ipList, serverIP, isInvolved
Dim configLine, statusLine, oVhost, oHealthService, oRel1, oRel2, oRel3
Dim strNslookup, objNslookup, secondSplit, strDispName
Dim shell

set rexp = new RegExp

For Each configLine In arrVhostConfig
Do Until (1=0)
isInvolved = false

rexp.Global = true
pattern = "\d+\s+\d+\s+CONFIG\s+VHOST\s+(\d+\.\d+\.\d+\.\d+)\s+(\S+)\s+(\S+)\s+\{([^\}]*)\}\s+"
pattern = pattern + "\{([^\}]*)\}\s+(\d+)\s+\{([^}]*)\}\s+\S+\s+(\d+\.\d+\.\d+\.\d+)(\s*.*)$"
rexp.Pattern = pattern

rexpRet = rexp.Replace(configLine, "$1,$5,$7,$8,$9")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) &lt; 4) Then Exit Do 'encountered parsing error
VirtualIP = arrRexpRet(0)
ServiceType = arrRexpRet(1)
AppName = arrRexpRet(2)
PrimaryServer = arrRexpRet(3)
if (arrRexpRet(4) &lt;&gt; "") then
ipList = VirtualIP + arrRexpRet(4)
else
ipList = VirtualIP
end if
For Each serverIP In arrIPs
if (InStr(ipList, serverIP) &gt; 0) then
isInvolved = true
exit for
end if
Next
if (isInvolved = false) then
exit do
end if

pattern = "\d+\s+\d+\s+STATUS\s+VHOST\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\S+).*$"
rexp.Pattern = pattern
ActiveServer = ""

For Each statusLine in arrVhostStatus
Do Until (1 = 0)
rexpRet = rexp.Replace(statusLine,"$1,$2,$3")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) &lt; 2) Then Exit Do 'encountered parsing error
if (arrRexpRet(0) = VirtualIP AND arrRexpRet(2) = "ACTIVE") then
ActiveServer = arrRexpRet(1)
exit for
end if
Exit Do
Loop
Next

select case ServiceType
case "SPACK_CIFS"
set oVhost = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.VHostCIFSService']$")
case "SPACK_SQL2000"
set oVhost = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.VHostSQLService']$")
case "SPACK_MSDTC"
set oVhost = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.VHostMSDTCService']$")
case "SPACK_SSAS"
set oVhost = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.VHostSSASService']$")
case else
set oVhost = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.VHostCustomService']$")
end select

Set shell = CreateObject("WScript.Shell")
Set objNslookup = shell.Exec("%comspec% /c nslookup " + VirtualIP)

debugWrite("subProcessVHost_dbg: VirtualIP is: " + VirtualIP)

Do While Not objNslookup.StdOut.AtEndOfStream
strNslookup = objNslookup.StdOut.ReadLine()
If not InStr(strNslookup, "Name:") = False Then
Exit Do
End If
Loop

debugWrite("subProcessVHost_dbg: strNslookup is: " + strNslookup)

secondSplit = Split(trim(strNslookup), ":")
If (Ubound(secondSplit) &lt; 1) Then
'parse error
debugWrite("subProcessVHost_dbg: parse error secondSplit is: empty")
strDispName = VirtualIP

else

strDispName = trim(secondSplit(1))

end if

debugWrite("subProcessVHost_dbg: strDispName is: " + strDispName)

call oVhost.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_VHOST + VirtualIP)
call oVhost.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Service']/AppName$", AppName)
call oVhost.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Service']/VirtualIP$", VirtualIP)
call oVhost.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", strDispName)
call oVhost.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Service']/PrimaryServer$", PrimaryServer)
call oVhost.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Service']/ActiveServer$", ActiveServer)
call oVhost.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$", clusterName)
call oDiscoveryData.AddInstance(oVhost)

set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ClusterContainService']$")
oRel1.Source = oCluster
oRel1.Target = oVhost
call oDiscoveryData.AddInstance(oRel1)
set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ServiceContainServer']$")
oRel2.Source = oVhost
oRel2.Target = oServer
call oDiscoveryData.AddInstance(oRel2)

'attempt to get the server health service to monitor the virtual host service
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel3 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel3.Source = oHealthService
oRel3.Target = oVhost
call oDiscoveryData.AddInstance(oRel3)

Exit Do
Loop
Next

End Sub
'*****************************************************************

'*****************************************************************
'FORMAT:0 4776 CONFIG FILESYSTEM psd4p1 {fs2} PSFS 5237156 6-6005-08B4-0010-5962-0000-E000-0102-0000 4096 1 5237158;SNAPREADY();QUOTA(2097152,0,1048576,0);VERSION(11);FEATURES(FZBM,QUOTA);ATTRIBUTES()

Sub subProcessFileSystem(arrFSConfig, arrMountConfig, arrMountStatus, TargetComputer)
Dim firstSplit, secondSplit, thirdSplit, anteNameSplit, postNameSplit
Dim psname, pslabel, pssize, diskid, version, features, attributes
Dim mounted, quota, mountOptions, mountType, mountLoc, humanReadableSize
Dim temp, isInvolved, strLine, statLine, strNextLine, rexp
Dim oFileSystem, oHealthService, oRel1, oRel2, oRel3
Dim xmlDoc, x, fsElemList, psNameList

debugWrite("start of the output, #lines: " + cstr(Ubound(arrFSConfig)))

For Each strLine In arrFSConfig
Do Until (0=1)
debugWrite(strLine)

firstSplit = Split(trim(strLine), "{")
If (Ubound(firstSplit) &lt; 1) Then Exit Do 'parse error
secondSplit = Split(trim(firstSplit(1)), "}")
If (Ubound(secondSplit) &lt; 1) Then Exit Do 'parse error
anteNameSplit = Split(firstSplit(0), " ")
If (Ubound(anteNameSplit) &lt; 4) Then Exit Do 'parse error
psname = anteNameSplit(4)
psNameList = psNameList + "," + psname

Exit Do
Loop
Next

'We now have what we need to make the FSEXPORT call
If (psNameList &lt;&gt; "") then
psNameList = Mid(psNameList, 2)
debugWrite(psNameList)
openHTTPFSExportQueryChannel(psNameList)
firstSplit = Split(trim(queryFSExportXML), "&lt;/mxProtocol&gt;")
queryFSExportXML = firstSplit(0) + "&lt;/mxProtocol&gt;"
End If

'load the list of mount points into fsElemList
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.loadXML(queryFSExportXML)
set fsElemList = xmlDoc.getElementsByTagName("exportedFs")


For Each strLine In arrFSConfig
Do Until (0=1)
debugWrite(strLine)

firstSplit = Split(trim(strLine), "{")
If (Ubound(firstSplit) &lt; 1) Then Exit Do 'parse error
secondSplit = Split(trim(firstSplit(1)), "}")
If (Ubound(secondSplit) &lt; 1) Then Exit Do 'parse error
anteNameSplit = Split(firstSplit(0), " ")
If (Ubound(anteNameSplit) &lt; 4) Then Exit Do 'parse error
postNameSplit = Split(secondSplit(1), " ")
If (Ubound(postNameSplit) &lt; 6) Then Exit Do 'parse error
thirdSplit = Split(postNameSplit(6), ";")
pslabel = secondSplit(0)
psname = anteNameSplit(4)
pssize = postNameSplit(2)
diskid = postNameSplit(3)

if (pssize &lt; 1024) then
humanReadableSize = cstr(pssize) + " Kb"
else if ((pssize/1024) &lt; 1024) then
humanReadableSize = cstr(FormatNumber((pssize/1024),2)) + " Mb"
else if ((pssize/(1024*1024)) &lt; 1024) then
humanReadableSize = cstr(FormatNumber((pssize/(1024*1024)),2)) + " Gb"
else if ((pssize/(1024*1024*1024)) &lt; 1024) then
humanReadableSize = cstr(FormatNumber((pssize/(1024*1024*1024)),2)) + " Tb"
else
humanReadableSize = pssize
end if
end if
end if
end if

'Hit!
'create file system object
if (runatcmd=0) then
set oFileSystem = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.FileSystem']$")
call oFileSystem.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_FS + psname)
call oFileSystem.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", pslabel)
call oFileSystem.AddProperty("$MPElement[Name='PolyServe.MatrixServer.FileSystem']/PSLabel$", psname)
call oFileSystem.AddProperty("$MPElement[Name='PolyServe.MatrixServer.FileSystem']/PSSize$", humanReadableSize)
call oFileSystem.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$", clusterName)
end if

mounted = false
For Each statLine In arrMountStatus
Do Until (1 = 0)
firstSplit = Split(trim(statLine), " ")
If (Ubound(firstSplit) &lt; 5) Then Exit Do 'parse error
For Each temp in arrIPs
if (firstSplit(4) = temp) then
isInvolved = true
end if
Next
if (isInvolved And firstSplit(5) = psname) then
mounted = true
exit for
else
exit do
end if
Exit Do
Loop
Next

set rexp = new regexp
rexp.Pattern = "\s"
rexp.Global = true

if (mounted = true) then
isInvolved = false
For Each statLine In arrMountConfig
Do Until (1 = 0)
firstSplit = Split(trim(statLine), " ")
If (Ubound(firstSplit) &lt; 5) Then Exit Do 'parse error
For Each temp in arrIPs
if (firstSplit(4) = temp) then
isInvolved = true
end if
Next
if (isInvolved And firstSplit(5) = psname) then
'get drive or mount location
x = locateMountInFSXML(psname, fsElemList)
call oFileSystem.AddProperty("$MPElement[Name='PolyServe.MatrixServer.FileSystem']/MountLoc$", x)
call oFileSystem.AddProperty("$MPElement[Name='PolyServe.MatrixServer.FileSystem']/PSFree$", freeSpace)
exit for
else
exit do
end if
exit do
loop
next

end if

if (runatcmd=0) then
call oDiscoveryData.AddInstance(oFileSystem)
end if

'create references
if (runatcmd=0) then
set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ClusterContainFileSystem']$")
oRel1.Source = oCluster
oRel1.Target = oFileSystem
call oDiscoveryData.AddInstance(oRel1)

set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.FileSystemContainServer']$")
oRel2.Source = oFileSystem
oRel2.Target = oServer
call oDiscoveryData.AddInstance(oRel2)

'get the server health service to monitor the file systems
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel3 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel3.Source = oHealthService
oRel3.Target = oFileSystem
call oDiscoveryData.AddInstance(oRel3)
end if
Exit Do
Loop
Next
End Sub
'*****************************************************************

'*****************************************************************
'FORMAT: 0 4776 CONFIG IFACE 15.11.145.107 15.11.145.107 255.255.254.0 PAN
'FORMAT: 0 4776 STATUS IFACE 15.11.145.107 15.11.145.107 UP ENABLED ACTIVE

Sub subProcessNetworkInterface(arrConfig, arrStatus, TargetComputer)

Dim arrLine, word, temp, index, strNextLine, statusNextLine
Dim displayName, ipaddr, adminTraffic, netmask, serverIP, isInvolved
Dim oInterface, oHealthService, oRel1, oRel2, strAddress

For Each strNextLine In arrConfig
Do Until (1 = 0)
arrLine = Split(trim(strNextLine), " ")
if (Ubound(arrLine) &lt; 5) then exit do 'parse error, not much point if we can't get ipaddr
isInvolved = false
'For Each word in arrLine
For index = 0 to UBound(arrLine)
word = arrLine(index)
If (index = 4) Then
serverIP = word
For Each strAddress in arrIPs
if (serverIP = strAddress) then
isInvolved = true
exit for
end if
Next
if (isInvolved = false) then
exit do
end if
ElseIf (index = 5) Then
ipaddr = word
ElseIf (index = 6) Then
netmask = word
ElseIf (index = 7) Then
debugWrite(word)'debug
if (word = "PAN") then
adminTraffic = "Allowed"
else
if (word = "NOPAN") then
adminTraffic = "Discouraged"
else
if (word = "EXPAN") then
adminTraffic = "Excluded"
else exit do 'parse error
end if
end if
end if
End If
Next

'create object
if (runatcmd=0) then
set oInterface = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.NetworkInterface']$")
call oInterface.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_IFACE + ipaddr)
call oInterface.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", ipaddr)
call oInterface.AddProperty("$MPElement[Name='PolyServe.MatrixServer.NetworkInterface']/IPAddress$", ipaddr)
call oInterface.AddProperty("$MPElement[Name='PolyServe.MatrixServer.NetworkInterface']/Netmask$", netmask)
call oInterface.AddProperty("$MPElement[Name='PolyServe.MatrixServer.NetworkInterface']/AdminTraffic$", adminTraffic)
call oInterface.AddProperty("$MPElement[Name='PolyServe.MatrixServer.NetworkInterface']/Computer$", TargetComputer)
call oDiscoveryData.AddInstance(oInterface)

'create references
set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.NodeContainsInterface']$")
oRel1.Source = oServer
oRel1.Target = oInterface
call oDiscoveryData.AddInstance(oRel1)

'get the server health service to monitor the interfaces
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel2.Source = oHealthService
oRel2.Target = oInterface
call oDiscoveryData.AddInstance(oRel2)
end if

Exit Do
Loop
Next

End Sub
'*****************************************************************

Function ParseTypeFromServiceConfigLine(arrServiceConfig, targetIP, targetName)

Dim pattern
Dim rexp
Dim rexpRet
Dim serviceMon
Dim arrRexpRet
Dim stype
Dim result
result = targetIP 'default if this whole thing fails

set rexp = new regexp
rexp.Global = false

pattern = "\d+\s+\d+\s+CONFIG\s+SERVICE\s+(\d+\.\d+\.\d+\.\d+)\s+\{([^}]*)\}\s+(\S+)(\s*.*)$"
rexp.Pattern = pattern

for each serviceMon in arrServiceConfig
do
rexpRet = rexp.Replace(serviceMon, "$1,$2,$3 ")

arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) &lt; 2) Then Exit Do 'encountered parsing error

if (arrRexpRet(1)=targetName and arrrexpRet(0)=targetIP) then
'lose any tabs
stype = replace(arrRexpRet(2), vbTab, "")
result = stype + " - " + trim(targetIP) + ":" + targetName
exit for
end if

exit do
loop
next

ParseTypeFromServiceConfigLine = result

End Function

'*****************************************************************
'FORMAT:&lt;number/&gt; &lt;number/&gt; CONFIG SERVICE &lt;parameter id="vhostAddress" typeid="IPAddress"/&gt; &lt;parameter id="id" typeid="QuotedString"/&gt; &lt;parameter id="type" typeid="String"/&gt; &lt;parameter id="probeFrequency" typeid="Integer"/&gt; &lt;parameter id="probeTimeout" typeid="Integer"/&gt; &lt;parameter id="scriptParameters" typeid="QuotedString"/&gt; &lt;parameter id="probeSeverity" typeid="String"/&gt; &lt;parameter id="eventSeverity" typeid="String"/&gt; &lt;parameter id="scriptOrdering" typeid="ScriptOrdering"/&gt; &lt;parameter id="recoveryScript" typeid="QuotedString"/&gt; &lt;parameter id="recoveryScriptTimeout" typeid="Integer"/&gt; &lt;parameter id="startScript" typeid="QuotedString"/&gt; &lt;parameter id="startScriptTimeout" typeid="Integer"/&gt; &lt;parameter id="stopScript" typeid="QuotedString"/&gt; &lt;parameter id="stopScriptTimeout" typeid="Integer"/&gt; &lt;parameter id="servicePriority" typeid="Integer"/&gt; &lt;parameter id="maintenanceState" typeid="MaintenanceState"/&gt; &lt;parameter id="probeType" typeid="ProbeType"/&gt;
'FORMAT:&lt;number/&gt; &lt;number/&gt; STATUS SERVICE &lt;parameter id="vhostAddress" typeid="IPAddress"/&gt; &lt;parameter id="id" typeid="QuotedString"/&gt; &lt;parameter id="serverAddress" typeid="IPAddress"/&gt; &lt;parameter id="operationalState" typeid="OperationalState"/&gt; &lt;parameter id="ability" typeid="Ability"/&gt; &lt;parameter id="activity" typeid="Activity"/&gt; &lt;parameter id="lastErrorCode" typeid="Integer"/&gt; &lt;parameter id="lastError" typeid="QuotedString"/&gt; &lt;parameter id="lastEventErrorCode" typeid="Integer"/&gt; &lt;parameter id="lastEventError" typeid="QuotedString"/&gt;
Sub subProcessService(arrServiceConfig, arrServiceStatus, arrVhostConfig, TargetComputer)
Dim rexp, rexpRet, arrRexpRet, pattern, isInvolved, serverIP, statusLine
Dim VirtualIP, ServiceName, AppName, startIPIndex
Dim configLine, configLineSplit, ServiceType
Dim oService, oHealthService
Dim oRel1, oRel2, oRel3, strType
Dim vhost, vhostIP(), vhostApp()

ReDim vhostIP(Ubound(arrVhostConfig)+1)
ReDim vhostApp(Ubound(arrVhostConfig)+1)

set rexp = new regexp
rexp.Global = false

pattern = "\d+\s+\d+\s+CONFIG\s+VHOST\s+(\d+\.\d+\.\d+\.\d+)\s+\S+\s+\S+\s+\{[^\}]*\}\s+"
pattern = pattern + "\{[^\}]*\}\s+\d+\s+\{([^}]*)\}.*$"
rexp.Pattern = pattern

startIPIndex = 0
for each vhost in arrVhostConfig
do
rexpRet = rexp.Replace(vhost, "$1,$2")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) &lt; 1) Then Exit Do 'encountered parsing error
vhostIP(startIPIndex) = arrRexpRet(0)
vhostApp(startIPIndex) = arrRexpRet(1)
startIPIndex = startIPIndex + 1
exit do
loop
next

for each statusLine in arrServiceStatus
do until (0 = 1)
isInvolved = false
startIPIndex = InStr(1, statusLine, "}")
for each serverIP in arrIPs
if (InStr(startIPIndex, statusLine, serverIP) &gt; 0) then
isInvolved = true
exit for
end if
next
if (isInvolved = false) then exit do
pattern = "\d+\s+\d+\s+STATUS\s+SERVICE\s+([\d\.]+)\s+\{([^\}]*)\}.*$"
rexp.Pattern = pattern

rexpRet = rexp.Replace(statusLine, "$1,$2")
arrRexpRet = Split(rexpRet, ",")
if (Ubound(arrRexpRet) &lt; 1) then exit do 'parse error
VirtualIP = arrRexpRet(0)
ServiceName = arrRexpRet(1)

' now look for ServiceName in arrServiceConfig
' once found, populate the ServiceType with the info from arrServiceConfig
' 0 6916 CONFIG SERVICE 10.10.14.126 {share1} SPACK_CIFS
' 0 6916 CONFIG VHOST 10.10.14.126 NOFAILBACK ENABLED {cpr14cifs2} {SPACK_CIFS} 0 {cifs1}
ServiceType = ""
For Each configLine In arrServiceConfig
Do

if (InStr(configLine, ServiceName) &gt; 0) then

debugWrite("subProcessService_dbg: inside if stmt, ServiceName found in configLine")

configLineSplit = Split(configLine)

If (UBound(configLineSplit) &lt; 7) Then Exit Do 'encountered parsing error
ServiceType = configLineSplit(6)

debugWrite("subProcessService_dbg: inside if stmt, ServiceType populated")

exit for

end if

exit do
loop
next

startIPIndex = 0
for each vhost in vhostIP
if (vhost = VirtualIP) then
AppName = vhostApp(startIPIndex)
exit for
end if
startIPIndex = startIPIndex + 1
next

'grab the type from the arrServiceStatus for it
strType = ParseTypeFromServiceConfigLine(arrServiceConfig, VirtualIP, ServiceName)

select case ServiceType
case "SPACK_CIFS"
set oService = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.MatrixVirtualFileShare']$")
call oService.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_FILESERVING_VFS + VirtualIP + ":" + ServiceName)
case else
set oService = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.ServiceMonitor']$")
call oService.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_SERVICEMON + VirtualIP + ":" + ServiceName)
end select

call oService.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", strType)
call oService.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Service']/AppName$", AppName)
call oService.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$", clusterName)
call oDiscoveryData.AddInstance(oService)

'create references
set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ServiceContainServer']$")
oRel1.Source = oService
oRel1.Target = oServer
call oDiscoveryData.AddInstance(oRel1)

set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ClusterContainService']$")
oRel2.Source = oCluster
oRel2.Target = oService
call oDiscoveryData.AddInstance(oRel2)

'get the server health service to monitor the service
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel3 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel3.Source = oHealthService
oRel3.Target = oService
call oDiscoveryData.AddInstance(oRel3)

exit do
loop
next

End Sub
'*****************************************************************
'*****************************************************************
'FORMAT:&lt;number/&gt; &lt;number/&gt; CONFIG DEVICE &lt;parameter id="id" typeid="QuotedString"/&gt; &lt;parameter id="type" typeid="String"/&gt; &lt;parameter id="probeFrequency" typeid="Integer"/&gt; &lt;parameter id="probeTimeout" typeid="Integer"/&gt; &lt;parameter id="scriptParameters" typeid="QuotedString"/&gt; &lt;parameter id="probeSeverity" typeid="ProbeSeverity"/&gt; &lt;parameter id="eventSeverity" typeid="EventSeverity"/&gt; &lt;parameter id="scriptOrdering" typeid="ScriptOrdering"/&gt; &lt;parameter id="recoveryScript" typeid="QuotedString"/&gt; &lt;parameter id="recoveryScriptTimeout" typeid="Integer"/&gt; &lt;parameter id="startScript" typeid="QuotedString"/&gt; &lt;parameter id="startScriptTimeout" typeid="Integer"/&gt; &lt;parameter id="stopScript" typeid="QuotedString"/&gt; &lt;parameter id="stopScriptTimeout" typeid="Integer"/&gt; &lt;parameter id="serverAddresses" typeid="QuotedString"/&gt; &lt;parameter id="allHosts" typeid="QuotedString"/&gt; &lt;parameter id="vhostAddresses" typeid="QuotedString"/&gt; &lt;parameter id="maintenanceState" typeid="String"/&gt; &lt;parameter id="activityType" typeid="Integer"/&gt; &lt;parameter id="probeType" typeid="ProbeType"/&gt; &lt;parameter id="application" typeid="QuotedString"/&gt;
'FORMAT:&lt;number/&gt; &lt;number/&gt; STATUS DEVICE &lt;parameter id="id" typeid="QuotedString"/&gt; &lt;parameter id="serverAddress" typeid="IPAddress"/&gt; &lt;parameter id="operationalState" typeid="OperationalState"/&gt; &lt;parameter id="ability" typeid="Ability"/&gt; &lt;parameter id="activity" typeid="Activity"/&gt; &lt;parameter id="lastErrorCode" typeid="Integer"/&gt; &lt;parameter id="lastError" typeid="QuotedString"/&gt; &lt;parameter id="lastEventErrorCode" typeid="Integer"/&gt; &lt;parameter id="lastEventError" typeid="QuotedString"/&gt;
Sub subProcessDevice(arrDeviceConfig, arrDeviceStatus, TargetComputer)
Dim ServiceType, AppName, devName
Dim rexp, rexpRet, arrRexpRet, pattern, serverIP, isInvolved
Dim configLine, statusLine, oDevMon, oHealthService, oRel1, oRel2, oRel3

set rexp = new RegExp

For Each configLine In arrDeviceConfig
Do Until (1=0)
isInvolved = false

For Each serverIP In arrIPs
if (InStr(configLine, serverIP) &gt; 0) then
isInvolved = true
exit for
end if
Next
if (isInvolved = false) then
exit do
end if

rexp.Global = true
pattern = "\d+\s+\d+\s+CONFIG\s+DEVICE\s+\{([^\}]*)\}\s+(\S+)\s+(\S+)\s+(\S+)\s+"
pattern = pattern + "\{[^\}]*\}[^\{]*\{[^\}]*\}[^\{]*\{[^\}]*\}[^\{]*\{[^\}]*\}[^\{]*\{[^\}]*\}[^\{]*\{[^\}]*\}[^\{]*\{[^\}]*\}[^\{]*\{([^\}]*)\}.*$"
rexp.Pattern = pattern

rexpRet = rexp.Replace(configLine, "$1,$2,$5")
arrRexpRet = Split(rexpRet, ",")
if (Ubound(arrRexpRet) &lt; 2) then exit do 'parse error
devName = arrRexpRet(0)
ServiceType = arrRexpRet(1)
AppName = arrRexpRet(2)

select case ServiceType
case "SPACK_CIFS"
set oDevMon = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.MatrixFileShare']$")
case else 'non Matrix File Share
set oDevMon = oDiscoveryData.CreateClassInstance("$MPElement[Name='PolyServe.MatrixServer.DeviceMonitor']$")
end select

call oDevMon.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/ObjectKey$", URI_CLUSTER_PREFIX + clusterid + URI_STYPE_DEVMON + devName)
call oDevMon.AddProperty("$MPElement[Name='PolyServe.MatrixServer.Service']/AppName$", AppName)
call oDevMon.AddProperty("$MPElement[Name='PolyServe.MatrixServer.PSObject']/PSClusterName$", clusterName)
call oDevMon.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", devName)
call oDiscoveryData.AddInstance(oDevMon)

set oRel1 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ClusterContainService']$")
oRel1.Source = oCluster
oRel1.Target = oDevMon
call oDiscoveryData.AddInstance(oRel1)
set oRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='PolyServe.MatrixServer.ServiceContainServer']$")
oRel2.Source = oDevMon
oRel2.Target = oServer
call oDiscoveryData.AddInstance(oRel2)

'attempt to get the server health service to monitor the device monitor
set oHealthService = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
call oHealthService.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$",TargetComputer)
set oRel3 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oRel3.Source = oHealthService
oRel3.Target = oDevMon
call oDiscoveryData.AddInstance(oRel3)

Exit Do
Loop
Next

End Sub
'*****************************************************************



'*****************************************************************
'FORMAT:
Sub openFSQueryChannel(FSName)
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists("C:\pulselet.query")) Then
Set queryInpStream = objFSO.OpenTextFile("c:\pulselet.query", ForReading)
'grab only lines with IPs for this server
End If
End Sub
'*****************************************************************

'*****************************************************************
'FORMAT:
Sub openHTTPQueryChannel(FSName)
Dim url
Dim xmlhttp

url = "https://127.0.0.1:6771/cgi-bin/pmxs/pulselet?--command=QUERY " + FSName + " {ALL_SERVERS}"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setOption(2) = 13056 'SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xmlhttp.open "GET", url, false
xmlhttp.send ""
queryInpStream = Split(trim(xmlhttp.responseText), vbCRLF)
End Sub
'*****************************************************************

'*****************************************************************
'FORMAT:
Sub openHTTPFSExportQueryChannel(FSNames)
Dim url
Dim xmlhttp
url = "https://127.0.0.1:6771/cgi-bin/pmxs/fsexportinfo?-f" + FSNames + "&amp;-R&amp;--summary"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.setOption(2) = 13056 'SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
xmlhttp.open "GET", url, false
xmlhttp.send ""
queryFSExportXML = xmlhttp.responseText
End Sub
'*****************************************************************

'*****************************************************************
'FORMAT:
Function debugWrite(text)
if (printdebug) then
outStream.WriteLine(text)
end if
End Function
'*****************************************************************
'*****************************************************************

'*****************************************************************
'FORMAT:
Function locateMountInFSXML(psname, fsElemList)
Dim x, resultStr, fso, drv, strNode, strLoc, shell, firstSplit, exec, tmpStr, firstMtPointStr

'first find the correct child node
resultStr = ""
for each x in fsElemList
if (x.getAttribute("psDevice")=psname) then
'hit!
'any number of fsExportMountPoint child nodes.
For Each strNode In x.childNodes
strLoc = strNode.getAttribute("location")
if (InStr(lcase(strLoc), "matrix~1\conf\mounts") = 0) and _
(InStr(lcase(strLoc), "matrixserver\conf\mounts") = 0) and _
(InStr(lcase(strLoc), "hpclus~1\conf\mounts") = 0) and _
(InStr(lcase(strLoc), "hp clustered file system\conf\mounts") = 0) then
if (resultStr = "") then
resultstr = strLoc
else
resultstr = resultStr + "; " + strLoc
end if
end if
Next

x = 0

'debugWrite("locateMountInFSXML_dbg: resultStr is: " + resultStr)

if (resultStr &lt;&gt; "") then
firstMtPointStr = Split(resultStr, ";")
'whack off the last slash
if (Right(firstMtPointStr(0),1)="\") then
firstMtPointStr(0) = Left(firstMtPointStr(0), Len(firstMtPointStr(0))-1)
end if

set shell = WScript.CreateObject("WScript.Shell")
if not IsNull(shell) then
set exec = shell.Exec("fsutil volume diskfree """ &amp; firstMtPointStr(0) &amp; """")

if not IsNull(exec) then
tmpStr = exec.StdOut.ReadAll()
firstSplit = Split(trim(tmpStr), vbCR)

if ubound(firstSplit) &gt; 0 then
tmpStr = Split(firstSplit(0), ":")

if IsNumeric(tmpStr(1)) then
x=int(tmpStr(1))
end if
end if
end if

end if

end if

if (x &lt; 1024) then
freeSpace = cstr(x) + " Bytes"
elseif ((x/1024) &lt; 1024) then
freeSpace = cstr(FormatNumber((x/1024),2)) + " Kb"
elseif ((x/(1024*1024)) &lt; 1024) then
freeSpace = cstr(FormatNumber((x/(1024*1024)),2)) + " Tb"
elseif ((x/(1024*1024*1024)) &lt; 1024) then
freeSpace = cstr(FormatNumber((x/(1024*1024*1024)),2)) + " Gb"
elseif ((x/(1024*1024*1024)) &lt; 1024) then
freeSpace = cstr(FormatNumber((x/(1024*1024*1024)),2)) + " Tb"
else
freeSpace = x
end if

if(resultStr = "") then
'for unmounted fs don't show free space
freeSpace = ""
end if

Exit for
end if
next

locateMountInFSXML = resultStr
End Function
'*****************************************************************
'*****************************************************************

'*****************************************************************
sub subTest(obje)
if (runatcmd=0) then
Dim oService
set oService = oDiscoveryData.CreateClassInstance("{1184B98A-11A0-BC54-8164-4B843E4EF154}")
call oService.AddProperty("{36145AFD-12EC-8684-24AE-F3F7152AFC05}", obje)
call oService.AddProperty("{2AEF736E-5F6A-DF9A-3741-D54B400B962E}", obje)
call oDiscoveryData.AddInstance(oService)
end if
End Sub
'*****************************************************************
'*****************************************************************
</Script></ScriptBody>
<TimeoutSeconds>290</TimeoutSeconds>
</DataSource>
</Discovery>