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

Creating Custom WMI Sensors For Dummies

Votes:

1

Is there a tool to create WMI queries easily, so I can use them PRTG's WMI Custom Sensor?

custom-script-exe custom-sensor wmi wql

Created on Sep 30, 2011 4:38:07 PM

Last change on Mar 16, 2015 5:08:55 PM by  Martina Wittmann [Paessler Support]



2 Replies

Accepted Answer

Votes:

1

Note: This post is based on information submitted by our Knowledge Base user "Dean". Thanks, Dean!

Creating a WMI Custom Sensor Without Scripting Knowledge

Our query will take the form:

SELECT [Property] FROM [Class] WHERE Name='[Instance]'

Now we just have to figure out what Property, Class and Instance is. This is easier than you think. In terms of Windows Performance Monitor Property=Counter, Class=Object and Instance=Instance. Or, in the PerfMon GUI language:

SELECT [Counter] FROM [Object] WHERE Name='[Instance]'

Use a Tool

There is a nice little tool for that called WMI Explorer. Once you see the list of Classes and Objects you'll immediately recognize the corresponding Perfmon counters and Objects.

For example, to monitor the Averge Delivery Time to local mailboxes on an exchange server named MyMailServer we can easily come up with:

SELECT AverageDeliveryTime 
FROM Win32_PerfFormattedData_MSExchangeIS_MSExchangeISMailbox 
WHERE Name='First Storage Group-Mailbox Store (MyMailServer)'

Some Counters do not have an instance. This shows up as <<Instance_00>> in WMI Explorer. In these cases you can drop the WHERE clause. For example, to get Active User Count:

SELECT ActiveUserCount 
FROM Win32_PerfFormattedData_MSExchangeMTA_MSExchangeMTA

The only thing left to do is save your query with the WQL extension and save it in the \Custom Sensors\WMI WQL scripts sub folder of your PRTG program directory.

Voila! Instant WMI Custom Sensor.

Created on Oct 4, 2011 8:39:27 AM by  Daniel Zobel [Product Manager]



Votes:

1

Another nice tool is the WMI Code Generator by Rob van der Woude.


It can produce a script in various languages like:

  • Batch
  • C#
  • Java
  • Perl
  • Ruby
  • Powershell
  • VBScript and more...


Download WMI Code Generator from Rob's website.

Created on Oct 4, 2011 11:11:03 AM

Last change on Oct 4, 2011 11:51:02 AM 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.