3. Accessing Data for Electric Power, Temperature, and Processor Utilization
Express5800/R110i-1, T110i-S, T110i Maintenance Guide
219
Chapter 3 Appendix
Processor utilization
3.1.3
The utilization rate of all logical processors is given by using the
Win32_PerfFormattedData_PerfOS_Processor class that Windows OS provides.
The following is the sample file (named as Proc.vbs) created by using Visual Basic Script. This script outputs
the processor utilization rate every 30 seconds.
' Start Script
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!¥¥" & strComputer & "¥root¥cimv2")
set objRefresher = CreateObject("WbemScripting.Swbemrefresher")
Set objProcessor = objRefresher.AddEnum _
(objWMIService, "Win32_PerfFormattedData_PerfOS_Processor").objectSet
objRefresher.Refresh
Dim first
first = true
Do
For each intProcessorUse in objProcessor
If first Then
If intProcessorUse.Name = "_Total" Then
first = false
End If
else
Wscript.Echo "Proc" & intProcessorUse.Name & " : " & _
"PercentProcessorTime=" & _
intProcessorUse.PercentProcessorTime
End If
Next
Wscript.Sleep 30*1000 'sleep 30 * 1000ms
objRefresher.Refresh
Loop
' End Script
Command
example
C:¥VBS> cscript //nologo Proc.vbs
Result
Proc0 : PercentProcessorTime=0
Proc1 : PercentProcessorTime=0
Proc2 : PercentProcessorTime=0
Proc3 : PercentProcessorTime=0
Proc4 : PercentProcessorTime=76
Proc5 : PercentProcessorTime=0
Proc6 : PercentProcessorTime=0
Proc7 : PercentProcessorTime=0
Proc_Total : PercentProcessorTime=9
Proc 0
to
Proc 7
show the utilization rate of each processor while
Proc_Total
shows the total processor
utilization rate.