New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


How do I create a WMI Custom Sensor?

Votes:

0

Your Vote:

Up

Down

Are there any tips & tricks?

prtg wmi wmi-custom-sensor wmi-custom-string-sensor wql

Created on Mar 19, 2010 1:54:14 PM by  Volker Uffelmann [Paessler Support]

Last change on Aug 7, 2017 4:35:10 PM by  Gerald Schoch [Paessler Support]



1 Reply

Accepted Answer

Votes:

0

Your Vote:

Up

Down

This article applies to PRTG Network Monitor 19 or later

How to Create a WMI Custom or WMI Custom String Sensor

Windows Management Instrumentation (WMI) is a powerful way to monitor many values on your Windows computer. PRTG already comes with the most useful WMI counter sensors, but there are lots of other counters you might be interested in—especially when you have written your own WMI extensions.

This is where the WMI Custom sensor and the WMI Custom String sensor step in.


Step 1: Find the Counter You Want to Monitor

To monitor a specific counter, you have to determine its namespace, its class, and its name.

  • Microsoft has documented all its WMI counters in its Windows documentation on MSDN. Browse through the classes to determine the necessary information.
  • Use Google (or your favorite search engine) for finding counters, and include keywords like WMI, counter, or class.
  • If you have written your own extension, you already know the necessary information, of course.

Step 2: Create the WMI Query

If you know the class and the name of a specific counter, you put them in an expression of the WMI Query Language (WQL) with this syntax: SELECT countername FROM counterclass

Replace countername and counterclass with your individual data.

A complete reference for WQL can be found on MSDN: WQL (SQL for WMI)

Note: For monitoring correctly, PRTG needs a single number value or string (depending on the sensor type you use) in a single row. If your query returns more than one result, you need to narrow down the result set using a WHERE clause with this syntax: SELECT countername FROM counterclass WHERE anothercounter = value

This is documented in the Microsoft article WHERE Clause.

If you want to use the LIKE operator for more flexibility, also see the article LIKE Operator.


Step 3: Test Your WMI Query in WMI Tester

Test your WQL query with our WMI Tester.

  • Fill in the credentials for the target computer and click the Test! button to make sure WMI is basically up and running.
  • Open the Advanced tab, select Query/Custom, and enter your query. Also enter the correct namespace (for Windows standard WMI classes it is root\CIMV2). Click Test!
  • If you encounter errors, check the syntax of your query and the namespace.

Read more about the usage of WMI Tester in its section of the WMI Tools Overview.


Step 4: Implement and Use the Sensor in PRTG

To use your query in PRTG, you have to save it to a file that

  • contains only the (one) query;
  • has a .wql extension to its filename;
  • is placed in the \Custom Sensors\WMI WQL scripts subfolder of the PRTG program directory.

Make sure you add the correct custom WMI sensor type for the returned value:

  • For integer and float values, add the WMI Custom sensor.
  • For strings, add the WMI Custom String sensor. This sensor type will show the returned value in the sensor message and will not add a channel for it.

Examples

System Uptime of the target computer: SELECT SystemUpTime FROM Win32_PerfFormattedData_PerfOS_System

Average Disk Bytes per Read on Drive D: SELECT AVGDiskBytesPerRead FROM Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name = 'D:'


Important: Provisions

  • The WMI Custom sensor supports only single number values (integers and floats) as result from WQL queries. If your query returns one or more of the following, the sensor will not be able to process the result:
    • String values, such as names: use the WMI Custom String sensor;
    • More than one column (two or more values horizontally in the result table of WMI Tester): you must specify only one counter in the query;
    • More than one row (two or more values vertically in the result table of WMI Tester): you have to narrow down the result list with a WHERE clause.
  • It is important that you copy the WQL file with your query to the computer where the PRTG probe that monitors the target computer is installed. If the file is placed on the target computer (or in case of a remote probe on the PRTG server), PRTG will not show the file in the selection list of the Add Sensor dialog.
  • Always ensure you use the correct namespace in both the WMI Tester and in the PRTG settings of the sensor.

More

Created on Mar 19, 2010 3:37:40 PM by  Volker Uffelmann [Paessler Support]

Last change on May 6, 2019 11:10:23 AM by  Florian Weik [Paessler Support]



Please log in or register to enter your reply.


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.