What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I monitor the average disk transfer time via WMI?

Votes:

0

I would like to read the WMI performance counter AvgDisksecPerTransfer from the WMI Class Win32_PerfRawData_PerfDisk_LogicalDisk in order to monitor the average disk transfer time.

Can I do this with an external script?

custom-script-exe custom-sensor event-log prtg sensor vb vbscript visual-basic windows wmi

Created on Feb 14, 2011 2:37:32 PM by  Daniel Zobel [Product Manager]

Last change on Mar 19, 2015 3:45:30 PM by  Martina Wittmann [Paessler Support]



1 Reply

Accepted Answer

Votes:

0

AvgDiskSecPerTransfer VBScript

Using a visual basic script, you can check the according WMI class and report the results to PRTG. In PRTG, run the script as an EXE/Script Sensor.

Use at Your Own Risk

In the following, we provide a script, ready for your own adaptations. Please note: We provide this information to experienced users "as it is", without any warranty, and we also cannot support you with customizing your EXE/Script sensors. Please see further documentation within the script.

' ********************************************************************************
' PRTG Custom EXE Sensor, VB Demo Script for  calclulating the time, in seconds, 
' of the average disk transfer via WMI
' ********************************************************************************
' created Feb 2011 for PRTG Network Monitor V8 by Paessler Support Team, www.paessler.com
' This script is Open Source and comes without support and warranty

'************ How it works ***************************************************
' This scripts utilizes the Performance Counter "AvgDisksecPerTransfer" from
' the WMI Class "Win32_PerfRawData_PerfDisk_LogicalDisk".
' http://msdn.microsoft.com/en-us/library/aa394307%28v=vs.85%29.aspx.

' "AvgDiskSecPerTransfer" is defined as Type "uint32" and is of CounterType "805438464" which means 
' "PERF_AVERAGE_TIMER" (http://msdn.microsoft.com/en-us/library/ms804010.aspx)
' results are calculated by the formula "((N1 - N0) / F) / (D1 - D0)"
' DefaultScale is set to "3" for this counter. This indicates the power of 10 by which to multiply the counter value 
' before displaying the counter. For example, if Default scale is set to 2, 
' the counter value is multiplied by 100. If Default scale is set to -3, the counter value is divided by 1,000.
' http://msdn.microsoft.com/en-us/library/aa392761%28v=vs.85%29.aspx
' http://msdn.microsoft.com/en-us/library/e8a76594%28v=vs.71%29.aspx


'************ IMPORTANT ***************************************************
' This script stores the values of every reading in a file. Make sure the the script has the necessary
' rights to create this file, and perform read and write operations to the file. 
' Each sensor of this kind must have its own file to store its values.

strFile = "c:\temp\sensor01.txt"

Const ForReading = 1
Const ForWriting = 2

'************ Set Your WMI Credentials here ****************
' Leave User and Password blank for local machine

strComputer = "."
strUser = ""
strPassword = ""


strNamespace = "root/cimv2"

Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer,strNamespace,strUser,strPassword)


strWQL = "SELECT AvgDisksecPerTransfer,AvgDiskSecPerTransfer_Base,Timestamp_Perftime,Frequency_PerfTime FROM Win32_PerfRawData_PerfDisk_LogicalDisk"
strWQL = strWQL +  " WHERE Name = '_Total'"

Set objResultSet = objWMIService.ExecQuery(strWQL)

For Each obj in objResultSet
 
  iAvgDisksecPerTransfer = obj.AvgDisksecPerTransfer
  iAvgDiskSecPerTransfer_Base = obj.AvgDiskSecPerTransfer_Base
  iTimestamp_Perftime = obj.Timestamp_Perftime
  iFrequency_PerfTime = obj.Frequency_PerfTime

Next


Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(strFile) Then
   
   Set objFile = objFSO.OpenTextFile(strFile, ForReading)

   iAvgDisksecPerTransferOld = objFile.Readline
   iAvgDiskSecPerTransfer_BaseOld = objFile.Readline
   iTimestamp_PerftimeOld = objFile.Readline
   iFrequency_PerfTimeOld = objFile.Readline
    
   objFile.Close
   Set objFile = nothing
    
   
   iResult = (iTimestamp_Perftime - iTimestamp_PerftimeOld)
   iResult = iResult / iAvgDiskSecPerTransfer_Base
   iResult = iResult  / (iAvgDisksecPerTransfer - iAvgDisksecPerTransferOld)
   iResult = iResult * 1000
   iResult = Round(iResult,6)
   
   ' ************* IMPORTANT **********
   ' You may have to replace  the decimal symbol. It must be ".", so uncomment the next line if need be.
   strResult = Replace(CStr(iResult),",",".")
   
   wscript.echo StrResult &":Ok"
    
Else
    Set objFile = objFSO.CreateTextFile(strFile)
    Set objFile = nothing
    wscript.echo "0:Ok"
End If


Set objFile = objFSO.OpenTextFile(strFile, ForWriting)

objFile.WriteLine(iAvgDisksecPerTransfer)
objFile.WriteLine(iAvgDiskSecPerTransfer_Base)
objFile.WriteLine(iTimestamp_Perftime)
objFile.WriteLine(iFrequency_PerfTime)


objFile.Close

Created on Feb 14, 2011 2:39:41 PM by  Daniel Zobel [Product Manager]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.