VB.net and WMI class question

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using the following code to get the Disk I/O on various servers. For now I am just retrieving the DiskReadsPerSec to get a feel for it. The return data gives a uint32 for each drive on the server and a total. My questions is what is the time frame that
this represents? Is this at the second that my code polls the drive or is this over the last few seconds or do I need to do multiple runs to get an average.
My intention is to build a graph for each drive so I wonder how often I need to poll the drive to get a acurate value.
<pre class="prettyprint lang-vb Public Shared Function GetDriveIO(ByVal strip As String) As Boolean
Dim oConn As New ConnectionOptions()
Dim lnglist As New List(Of Long)
oConn.Username = mstruser
oConn.Password = mstrpass
oConn.Authority = "DOMAIN"
Dim strNameSpace As String = "\"
strNameSpace += strip PC IP address
strNameSpace += "rootcimv2"
Try
Dim oMs As New System.Management.ManagementScope(strNameSpace, oConn)
Dim oQuery As New System.Management.ObjectQuery("Select * From Win32_PerfFormattedData_Perfdisk_physicaldisk") XP, Server 2000, Server 2003
Dim mgmtObjects As New ManagementObjectSearcher(oMs, oQuery)
For Each item In mgmtObjects.[Get]()
Dim lngCPU As Long
lngCPU = DirectCast(item("DiskReadsPerSec"), UInt32)
System.Diagnostics.Debug.WriteLine(item.ToString & " - " & lngCPU.ToString)
Next
mgmtObjects.Dispose()
Return True
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(strip & " - " & ex.ToString)
End Try
End Function[/code]
<br/>
Thanks,
TyB

View the full article
 
Back
Top