3

I'm building a C# monitor app which uses WMI to grab some performance details of a remote computer. What are some good WMI queries to grab helpful stats such as CPU load, RAM usage, HDD free space, etc.

For example, you can get the CPU load from the property "LoadPercentage" with the query "SELECT * FROM Win32_Processor".

What are some other useful properties & queries?

mike
  • 3,146
  • 5
  • 32
  • 46
  • I like querying the system uptime, but that's my Linux bias coming through. –  Nov 27 '09 at 07:41

4 Answers4

3

I think it's a bit complicated recommend a couple of classes in particular because the WMI is extensive and depends on the type of information you wish to obtain.

My recommendation is that you see the following links.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • That's the problem, it is so extensive it is hard to find relevant data. I'm looking for stats such as cpu load / ram usage / hdd free space that just about any computer user will understand. Performance related stats. Or even general info. Computer uptime, network usage, current timezone/clock time on pc. Just anything that is easily interpretable and might be of use in diagnostics or general monitoring. – mike Nov 30 '09 at 03:47
3

Several classes are used for what you are asking for. I think a good place to start is to separate your (mostly) static classes from your performance classes.

Static

  • Computer System - Win32_ComputerSystem
  • Operating System - Win32_OperatingSystem
  • Processor Info - Win32_Processor
  • HDD - Win32_DiskDrive
  • Disk Partitions - Win32_DiskPartition
  • Logical Disks - Win32_LogicalDisk
  • Logical Disk to Partition - Win32_LogicalDiskToPartition
  • Memory - Win32_PhysicalMemory, Win32_PhysicalMemoryArray
  • Network - Win32_NetworkAdapter (this class has a high cpu penalty if called too often), Win32_NetworkAdapterConfiguration

Performance Counters

  • Processor Utilization - Win32_PerfRawData_PerfOS_Processor
  • Memory Utilization - Win32_PerfRawData_PerfOS_Memory
  • Network Utilization - Win32_PerfRawData_Tcpip_NetworkInterface

There are many more, but these will cover what you are asking for.

Xcalibur37
  • 2,305
  • 1
  • 17
  • 20
0

You can Also use Win32_Products.

This gives you all istalled software on the machine. You can use WMI to repair / Uninstall these products. Very useful on Remote Machines.

Derek
  • 8,300
  • 12
  • 56
  • 88
  • This class does have a high performance penalty. Querying the registry keys at `"HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\"` is a good alternative. – kevmar Jan 20 '15 at 21:22
0

You would appreciate http://gallery.technet.microsoft.com/scriptcenter/en-us. It's very nicely organized. I got all the queries for the above stats you mentioned from that website, and basically just copied and pasted.

John Moses
  • 1,283
  • 1
  • 12
  • 18