Microsoft® WMI Overview
Common Tasks
previous next
XRatel Knowledge Base knowledge base
WMI Architecture | Common Tasks | References

Common Tasks


01. CPU Usage Monitoring

CPU usage can be monitored through the LoadPercentage counter in the Win32_Processor class. This counterreturns the load capacity of the processor, averaged to the last second. You can take more information about this in WMI Reference - Win32_Processor Class.


02. Memory Usage Monitoring

In order to monitor memory usage, you can use the FreePhysicalMemory and FreeVirtualMemory counters in the Win32_OperatingSystem class.

FreePhysicalMemory gives you the number of kilobytes of physical memory which are currently available for use. FreeVirtualMemory, in turn, gives you the number of kilobytes of virtual memory currently available, i.e., the amount of free physical memory plus the free space in paging files.

If you wish a higher (or lesser) amount of detail about the free physical memory, you can use the Win32_PerfFormattedData_PerfOS_Memory class. It provides the AvailableBytes, AvailableKBytes and AvailableMBytes counters, which indicate the amount of free physical memory in bytes, kilobytes and megabytes, respectively. Note that this class requires Windows XP for clients and Windows 2003 Server for servers. You can take this information and others in WMI Reference - Win32_PerfFormattedData_PerfOS_Memory class

To view a complete information abou this, you can visit: WMI Reference - Win32_OperatingSystem Class.


03. Disk Usage Monitoring

You can monitor disk usage using the
Win32_PerfFormattedData_PerfDisk_LogicalDisk class. There are instances of this class for monitoring individual partitions, as well as a "_Total" instance, that aggregates data from all disk partitions at the same time. You can identify instances using the Name counter, which is either "_Total" or a disk letter (C:, D:, etc.).

Among the counters provided by the class, FreeMegabytes and PercentFreeSpace are particularly useful. The former gives you the amount of free space in the logical disk in megabytes. The latter gives you the ratio of free space on the logical disk unit to the total amount of usable space in it.

The page WMI Reference - Win32_PerfFormattedData_PerfDisk_LogicalDisk Class have more information about this class.

Note that Windows 2000, Windows NT 4.0 and Windows 95/98/ME do not provide the above class. On these systems, you might use the Win32_PerfRawData_PerfDisk_LogicalDisk class with the same properties. More information about this class can be found in:
WMI Reference - Win32_PerfRawData_PerfDisk_LogicalDisk


04. Temperature Monitoring

To obtain the temperature of any sensor you can use the property CurrentReading of the class Win32_TemperatureProbe.

If you want to get de maximum temperature read from the sensor, you can use the propertie MaxReadable. To get the minimum value obtained from the sensor, try MinReadable.

Another important's properties are: LowerThresholdCritical, LowerThresholdFatal and LowerThresholdNonCritical. They indicates the lower values for the critical, fatal and normal values respectively.

More information about the Win32_TemperatureProbe class can be obtained in WMI Reference - Win32_TemperatureProbe Class.


05. Fan Monitoring

WMI can monitor fan devices in a computer with the class Win32_Fan. If you want to measure the actual speed of a fan device you can access the the property DesiredSpeed.

To get the actual status of the object you can read the property Availability of the same class. It returns a unsigned int value. To get a string, you can read the variable Status.

Some extra information about Win32_Fan can be obtained on WMI Reference - Win32_Fan Class.


06. Network Adapters Monitoring

WMI offers support to monitoring network adapters in the class Win32_NetworkAdapter of the object. You can obtain the status of the connection using the NetConnectionStatus property of this class. Note that both properties return a unsigned int value. The current status of the object can be read in a string format using the variable Status.

The property AdapterTypeID returns the type of the Adapter, i.e., Ethernet 802.3, Wireless,but in a unsigned int value. The variable AdapterType return the same information, but in a string format.

This class have two important properties that can return the network adress and the Media Access Control(MAC). They are respectively NetworkAdress and MACAddress.

Another importants properties that can monitor speed are MaxSpeed and Speed. The first returns the maximum speed for the network adapter. The second returns the current bandwidth usage. Both returns the value in bits per second.

The page WMI Reference - Win32_NetworkAdapter Class have more information about the Win32_NetworkAdapter class.


07. Printers Monitoring

In the class W32_Printer you can get the current status of the printer reading the property Availability or the property Status. The difference between both is the type of each one returns: unsigned integer for the first and string for the second.

To see the share name of a printer, read the property ShareName.

The printer state can be obtained using the variable ExtendedPrinterStatus, wich returns a unsigned integer.

Other important information about the printer is the error message. This state can be obtained using ExtendedDetectedErrorState, who returns a unsigned integer. The same information can be found in a string array format using ErrorInformation.

In some cases is important to know all job sheets available on a printer. To take this information, read the property AvailableJobSheets.

In the page WMI Reference - Win32_Printer Class you can take more information.


08. Processes Monitoring

To monitor processes you can use the
Win32_PerfFormattedData_PerfProc_Process class.

Reading the property IDProcess you can obtain the unique identifier of a process. This ID is created when the process initiate and is eliminated when it terminates.

To count how many threads a process is runnig you can monitor the variable ThreadCount.

In this class, the propertie PageFileBytes returns the total number of page file used by a process in bytes.

To get the current amount of bytes used in the working set of a process, you can monitor the attribute WorkingSet.

If you want to know the percentage of the processor used by a process, read the property PercentProcessorTime.

To get complete information about this class, you can visit WMI Reference - Win32_PerfFormattedData_PerfProc_Process Class

It is important to say that this class is only available in Windows XP and Windows Server 2003. To read these information in Windows 2000 Server and Windows 2000 Professional too, you can look the same properties in Win32_PerfRawData_PerfProc_Process class. More information about this class can be found in WMI Reference - Win32_PerfRawData_PerfProc_Process Class.


09. Registry Monitoring

WMI offers a class to help you get information from the registry. This class is Win32_Registry.

A interesting property of this class is CurrentSize. It returns the current total size of the registry.

A complete information of this class can be found in WMI Reference - Win32_Registry.


10. Users Monitoring

To obtain the current network login information, you can look for the property Caption in the class Win32_NetworkLoginProfile. The ID of the user can be found reading UserId.

The number of times the user enters a bad password can be found in BadPasswordCount.

Note that this class is available only in Windows NT Workstation 4.0 SP4, Windows NT Server 4.0 SP4 and later.
A lot of information can be obtained in the page: WMI Reference - Win32_NetworkLoginProfile Class

previous top next

 
©2005-2008 XRatel Software. All rights reserved.