What are some common WMI queries

人盡茶涼 提交于 2019-12-10 21:03:43

问题


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?


回答1:


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.

  • WMI Reference
  • WMI Classes
  • WMI Win32 Classes



回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/1807271/what-are-some-common-wmi-queries

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!