Monitoring Your Windows Server Metrics with WMI

In past posts, we’ve talked about how you can create a Windows WMI custom monitor and automatically upload values into them. But now you may be wondering how to gather all the, well, valuable, value that is needed to effectively monitor your systems.

In this article, Monitis provides a list of WMI queries that can be used in your script to get the data you need.

WMI Query Structure

Each WMI query is made in three phases as follows:

  1. Connecting to WMI on a local or remote computer
  2. Executing the query
  3. Reading the returned data




The query language is WMI Query Language (WQL) and is a subset of SQL.  A sample script to gather WMI data looks like the following:

computer = "."
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + computer + "\root\cimv2")
Set oRes = oWMI.ExecQuery("select PercentDiskTime from Win32_PerfFormattedData_PerfDisk_PhysicalDisk where Name = '0 C:'")
For each oEntry in oRes
wscript.echo oEntry.PercentDiskTime


You can find a similar structure in the scripts describing how to create custom monitors and feed them with data.

Since WMI data is highly dependent on your system configuration (such as disk partitions or network adapter names), consider the sample queries in this article just as a sample, and be sure to verify how the data are structured on your particular system.

From here, you can verify your queries using WMI Explorer by clicking on the following link:

CPU Monitoring

select PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor where Name = '_Total'

“PercentProcessorTime,” as appears above, is the percentage of the time the processor is busy doing non-idle threads.

Physical Disk monitoring

select PercentDiskTime from Win32_PerfFormattedData_PerfDisk_PhysicalDisk where Name = '0 C:'

“PercentDiskTime,” as appears above, is the percentage of the time the selected physical disk is busy servicing read or write requests.

Memory monitoring

select AvailableBytes from Win32_PerfFormattedData_PerfOS_Memory

“AvailableBytes,” also featured above, is the amount of memory immediately available for allocation to a process or for system use.

Memory swap monitoring

select PagesPersec from Win32_PerfFormattedData_PerfOS_Memory

Is the current rate (“PagesPersec”) at which memory pages are read from or written to disk to resolve hard page faults. A high rate of memory operations involving disk swap are symptoms of memory shortage and affects system performance.

Free space on disks monitoring

select FreeSpace from Win32_LogicalDisk where DeviceID = 'C:'

“FreeSpace” is the available storage space in bytes on the specified logical disk.

Network monitoring

select BytesReceivedPersec, BytesSentPersec from Win32_PerfFormattedData_Tcpip_NetworkInterface where Name = 'D-Link DFE-538TX 10_100 Adapter'

“BytesReceivedPersec” and “BytesSentPersec” are the current transmission rates for the specified adapter.

TCP/IP re-transmissions

select SegmentsRetransmittedPersec from Win32_PerfFormattedData_Tcpip_TCPv4

“SegmentsRetransmittedPersec” is the current rate of TCP/IP segments re-transmission. It gives you an idea of how well your network connection is performing.

Server monitoring

select FilesOpen, ServerSessions from Win32_PerfFormattedData_PerfNet_Server

“FilesOpen” is the current number of files opened by users over the network.  “ServerSession” is the current number of users connected to the server.

TCP/IP Connections monitoring

select ConnectionsEstablished from Win32_PerfFormattedData_Tcpip_TCPv4

“ConnectionEstablished,” seen in the code above, is the current number of Established connections, inbound and outbound.

Terminal server monitoring

select ActiveSessions from Win32_PerfFormattedData_LocalSessionManager_TerminalServices

“ActiveSessions” is the number of currently active sessions connected to your Terminal Server.

Keep the link to this instructional post handy. It will help you determine what you need to query in WML, and what you find out as you’re monitoring your systems and servers may just keep you stay more competitive and efficient in your business.