'------------- 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 < 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
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 " & objNet.UserName
debugWrite(strInfo)
strInfo = "Computer Name is " & objNet.ComputerName
debugWrite(strInfo)
strInfo = "Domain Name is " & 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) >= 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
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
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) < 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) < 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)< 0) then 'wrong version, parsing might be different.
Call oAPI.Return(oDiscoveryData)
wscript.quit()
End If
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) < 1) Then Exit Do 'parse error
anteNameSplit = Split(firstSplit(0), " ")
If (Ubound(anteNameSplit) < 5) Then Exit Do 'parse error
isInvolved = false
For Each serverIP In arrIPs
if (InStr(anteNameSplit(4), serverIP) > 0) then
isInvolved = true
exit for
end if
Next
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) < 1) Then
'parse error
strDispName = anteNameSplit(4)
else
strDispName = trim(secondSplit(1))
end if
debugWrite("subProcessServer_dbg: DNS lookup: " + trim(secondSplit(1)))
'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)
'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
'*****************************************************************
rexpRet = rexp.Replace(configLine, "$1,$5,$7,$8,$9")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) < 4) Then Exit Do 'encountered parsing error
VirtualIP = arrRexpRet(0)
ServiceType = arrRexpRet(1)
AppName = arrRexpRet(2)
PrimaryServer = arrRexpRet(3)
if (arrRexpRet(4) <> "") then
ipList = VirtualIP + arrRexpRet(4)
else
ipList = VirtualIP
end if
For Each serverIP In arrIPs
if (InStr(ipList, serverIP) > 0) then
isInvolved = true
exit for
end if
Next
if (isInvolved = false) then
exit do
end if
For Each statusLine in arrVhostStatus
Do Until (1 = 0)
rexpRet = rexp.Replace(statusLine,"$1,$2,$3")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) < 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) < 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)
'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
'*****************************************************************
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) < 1) Then Exit Do 'parse error
secondSplit = Split(trim(firstSplit(1)), "}")
If (Ubound(secondSplit) < 1) Then Exit Do 'parse error
anteNameSplit = Split(firstSplit(0), " ")
If (Ubound(anteNameSplit) < 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 <> "") then
psNameList = Mid(psNameList, 2)
debugWrite(psNameList)
openHTTPFSExportQueryChannel(psNameList)
firstSplit = Split(trim(queryFSExportXML), "</mxProtocol>")
queryFSExportXML = firstSplit(0) + "</mxProtocol>"
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) < 1) Then Exit Do 'parse error
secondSplit = Split(trim(firstSplit(1)), "}")
If (Ubound(secondSplit) < 1) Then Exit Do 'parse error
anteNameSplit = Split(firstSplit(0), " ")
If (Ubound(anteNameSplit) < 4) Then Exit Do 'parse error
postNameSplit = Split(secondSplit(1), " ")
If (Ubound(postNameSplit) < 6) Then Exit Do 'parse error
thirdSplit = Split(postNameSplit(6), ";")
pslabel = secondSplit(0)
psname = anteNameSplit(4)
pssize = postNameSplit(2)
diskid = postNameSplit(3)
if (pssize < 1024) then
humanReadableSize = cstr(pssize) + " Kb"
else if ((pssize/1024) < 1024) then
humanReadableSize = cstr(FormatNumber((pssize/1024),2)) + " Mb"
else if ((pssize/(1024*1024)) < 1024) then
humanReadableSize = cstr(FormatNumber((pssize/(1024*1024)),2)) + " Gb"
else if ((pssize/(1024*1024*1024)) < 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) < 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) < 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)
'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) < 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
'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
for each serviceMon in arrServiceConfig
do
rexpRet = rexp.Replace(serviceMon, "$1,$2,$3 ")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) < 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
startIPIndex = 0
for each vhost in arrVhostConfig
do
rexpRet = rexp.Replace(vhost, "$1,$2")
arrRexpRet = Split(rexpRet, ",")
If (UBound(arrRexpRet) < 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) > 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) < 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) > 0) then
debugWrite("subProcessService_dbg: inside if stmt, ServiceName found in configLine")
configLineSplit = Split(configLine)
If (UBound(configLineSplit) < 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
'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)
For Each configLine In arrDeviceConfig
Do Until (1=0)
isInvolved = false
For Each serverIP In arrIPs
if (InStr(configLine, serverIP) > 0) then
isInvolved = true
exit for
end if
Next
if (isInvolved = false) then
exit do
end if
rexpRet = rexp.Replace(configLine, "$1,$2,$5")
arrRexpRet = Split(rexpRet, ",")
if (Ubound(arrRexpRet) < 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
'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 + "&-R&--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 <> "") 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 """ & firstMtPointStr(0) & """")
if not IsNull(exec) then
tmpStr = exec.StdOut.ReadAll()
firstSplit = Split(trim(tmpStr), vbCR)
if ubound(firstSplit) > 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 < 1024) then
freeSpace = cstr(x) + " Bytes"
elseif ((x/1024) < 1024) then
freeSpace = cstr(FormatNumber((x/1024),2)) + " Kb"
elseif ((x/(1024*1024)) < 1024) then
freeSpace = cstr(FormatNumber((x/(1024*1024)),2)) + " Tb"
elseif ((x/(1024*1024*1024)) < 1024) then
freeSpace = cstr(FormatNumber((x/(1024*1024*1024)),2)) + " Gb"
elseif ((x/(1024*1024*1024)) < 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>