'=========================== Create Instances for All Physical Processor =========================
Function CreateAllPhysicalProcessorInstances()
Call LogDebugString("Entering CreateAllPhysicalProcessorInstances", INFO_LEVEL_FUNCTION)
Dim oObjectItem, colInstances, iResult
CreateAllPhysicalProcessorInstances = -1
'Getting Physical Processor's instance
iResult = GetWMIObjectCollection(IBMSD_NAMESPACE, "IBMPSG_Processor", colInstances)
'If (iResult > 0) and (hwLicense <> "None") Then
If (iResult > 0) Then
For Each oObjectItem in colInstances
CreateOnePhysicalProcessorInstance(oObjectItem)
Next
'ElseIf (iResult > 0) and (hwLicense = "None") Then
' CreateNonLicensedProcessor()
Else
Call LogDebugString("Can not get PhysicalProcessor collection instance", WARNING_LEVEL)
End If
CreateAllPhysicalProcessorInstances = 1
End Function
Function CreateNonLicensedProcessor()
Call LogDebugString("Entering CreateNonLicensedProcessor", INFO_LEVEL_FUNCTION)
CreateNonLicensedProcessor = -1
Dim oTargetInstance
Set oTargetInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.SystemX.PhysicalProcessor']$")
sSocketLocation = "Unknown"
sProcessorName = "Unknown"
sDataWidth = "Unknown"
sClockSpeed = "Unknown"
sNumOfCores = "Unknown"
ON ERROR RESUME NEXT ' Skip errors below, some of which may not always exist
sSocketLocation = CStr(oObjectItem.DeviceID)
sProcessorName = CStr(oObjectItem.Name)
sDataWidth = CStr(oObjectItem.DataWidth)
sClockSpeed = CStr(oObjectItem.CurrentClockSpeed)
sNumOfCores = CStr(oObjectItem.NumberOfEnabledCores)
ON ERROR GOTO 0 ' Break on errors here on.
Function GetProcessorInteralID(ByVal targetStr)
'This function will add a space between the last letter and the first Arabic numeral if there is no initial space between them.
'Input->Output
'CPU12->CPU 12
'Cpu 12->Cpu 12
'C P U1->C P U 1
'c p u 1->c p u 1
GetProcessorInteralID = "Unknown"
Dim iRet, re, patten, matches, matchValue, match, strTemp, strNewTemp
Dim oMatch
Dim oMatches
patten = "^\D+\d+$"
Set re = New RegExp
re.IgnoreCase = False
re.Pattern = patten
If (re.Test(targetStr)) Then
'The target string starts with letter and end with Arabic numeral
re.Pattern = "[a-zA-Z][0-9]"
If (re.Test(targetStr)) Then
'There is no initial space between them
re.Pattern = "[0-9]+"
Set oMatches = re.Execute(targetStr)
For Each oMatch In oMatches
strTemp = oMatch.Value
WScript.echo strTemp
strNewTemp = " " + strTemp
targetStr = Replace(targetStr, strTemp, strNewTemp)
Next
End If
End If
GetProcessorInteralID = targetStr
End Function