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 do I create a WMI Custom sensor?

Votes:

0

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 Dec 9, 2020 7:57:24 AM by  Brandy Greger [Paessler Support]



1 Reply

Accepted Answer

Votes:

0

This article applies as of PRTG 22

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 system. PRTG already comes with the most useful WMI counter sensors, but there are many 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 come in.


Step 1: Find the counter you want to monitor

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

  • Browse through the WMI counters and classes in Microsoft's Windows documentation to find the necessary information.
  • Use Google (or your favorite search engine) to find counters. Include keywords like WMI, counter, or class in your search.
  • 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, 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 here: WQL (SQL for WMI)

Note: To monitor correctly, PRTG needs a single numeric 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 with a WHERE clause with this syntax: SELECT countername FROM counterclass WHERE anothercounter = value

This is documented in this 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 system and click the Test! button to make sure WMI is up and running.
  • Open the Advanced tab, select Custom under Query, and enter your query. Also enter the correct namespace (for Windows standard WMI classes it is root\CIMV2). Click the Test! button.
  • If you encounter errors, check the syntax of your query and the namespace.

Read more about the usage of WMI Tester in Are there any testing tools for WMI?.


Step 4: Implement and use the sensor in PRTG

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

  • contains only the (one) query;
  • has a .wql extension to its file name;
  • 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 shows the returned value in the sensor message and does not add a channel for it.

Examples

System Uptime of the target system: 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 numeric 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): narrow down the result list with a WHERE clause.
  • It is important that you copy the .wql file with your query to the system where the probe that monitors the target system is installed. If the file is placed on the target system (or, in the case of a remote probe, on the PRTG core server), PRTG does not show the file in the selection list of the Add Sensor dialog.
  • Always ensure you use the correct namespace in both WMI Tester and in the settings of the sensor.

More

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

Last change on Jan 2, 2023 2:44:35 PM by  Brandy Greger [Paessler Support]




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.