WMI 中的数据库条目如何(以及多久更新一次)?
我们需要为 Windows 客户端计算机设计一个监视应用程序,我正在查找有关 WMI 架构的一些信息。我们当前的计划是使用相当简单的 VBScript 脚本定期查询数据库,将相关信息写入平面文件,以便稍后传输到中央服务器(其中所有繁重的分析和报告工作已经存在于我们的非 Windows 计算机中。
我'我尝试在 MSDN 和整个网络上寻找这个问题的答案,但所有文章似乎都特别“蓬松”——很多“如何使用它”,但很少介绍“它在内部如何工作”,
以 VBScript 为例 。片段如:
set wmi = getObject("winmgmts:\\.\root\cimv2")
set itemCpu = wmi.get("Win32_PerfRawData_PerfOS_Processor.Name='_Total'")
n = itemCpu.PercentProcessorTime
或:
set wmi = getObject("winmgmts:\\.\root\cimv2")
set colMem = wmi.execQuery(
"select AvailableKBytes from Win32_PerfRawData_PerfOS_Memory",,48)
现在,我了解到这些内容会发送到 CIM 数据库并检索相关条目,并且我认为在收集信息之间存在脱节数据库及其提取
从该数据库请求信息,统计数据都会被收集并写入数据库。
+------------+ req/ ========
| Monitoring | resp / \ stats +------------+
| Processes | <-------> < Database > <-------- | Collectors |
| | \ / +------------+
+------------+ ========
\_____________________________/ \_____________________________/
On-demand Always happening
换句话说,无论是否有人 我对更深入地填充数据库的过程感兴趣。例如:
- 我们如何知道 Windows“收集器”将信息添加到数据库的频率和情况?
- Windows内核会在每次任务切换时写入进程信息吗?
- 它每秒都会写入内存信息吗?
- 它是否仅按需更新数据库(当监控应用程序请求信息时)?
这就是我想要找出的东西。
有人有此类信息,或者有关该主题的技术文章或白皮书的链接吗?
We have a requirement to design a monitoring application for our Windows client machines and I'm chasing up some information on the the WMI architecture. Our current plan is to use fairly simple VBScript scripts to periodically query the database, writing relevant information to flat files for later transfer to a central server (where all the heavy lifting of analysis and reporting already exists for our non-Windows machines.
I've tried looking for an answer to this question on MSDN and the net at large, but all the articles seem particularly "fluffy" - lots of "how to use it" but little on "how it works internally".
Take for example a VBScript segment like:
set wmi = getObject("winmgmts:\\.\root\cimv2")
set itemCpu = wmi.get("Win32_PerfRawData_PerfOS_Processor.Name='_Total'")
n = itemCpu.PercentProcessorTime
or:
set wmi = getObject("winmgmts:\\.\root\cimv2")
set colMem = wmi.execQuery(
"select AvailableKBytes from Win32_PerfRawData_PerfOS_Memory",,48)
Now, I understand that these goes out to the CIM database and retrieve the relevant entries, and I think there's a disconnect between the collecting of information into that database and the extraction of it.
In other words, statistics are collected and written to the database by Windows regardless of whether anyone is requesting information from said database. My understanding can best be summed up as:
+------------+ req/ ========
| Monitoring | resp / \ stats +------------+
| Processes | <-------> < Database > <-------- | Collectors |
| | \ / +------------+
+------------+ ========
\_____________________________/ \_____________________________/
On-demand Always happening
But I'm interested in the process whereby the database is populated, in more depth. Things like:
- How can we tell how often, and under what circumstances, information is added to the database by the Windows "collectors"?
- Does the Windows kernel write process information on every task switch?
- Does it write memory information every second?
- Does it only update the database on demand (when a monitoring application requests information)?
That's the sort of stuff I'm trying to find out.
Does anyone have that sort of information, or links to technically-minded articles or whitepapers on the subject?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简而言之,WMI元数据库是实时更新的。例如,查看系统时区类别:
然后更改系统区域设置并再次重新检查时区类别。
UAC(从 Win VISTA 开始)在 WMI 基础结构中发挥着更大的作用:
http://msdn.microsoft。 com/en-us/library/windows/desktop/aa826699(v=VS.85).aspx
这篇教程文章(相当不错)描述了 CIM架构:http://www.wbemsolutions.com/tutorials/CIM/index.html
这篇 MSDN 文章介绍了 MOF:http://msdn.microsoft.com/ en-us/library/windows/desktop/aa823192(v=vs.85).aspx
因此总而言之,对于 CIM 何时使用并没有硬性规定数据库是否被重新填充,这取决于系统当时正在做什么和/或用户做了什么。
In short, the WMI metabase is updated in real time. For example, view systems timezone class:
Then change the systems regional zone setting and re-check the timezone class again.
The UAC (from Win VISTA onwards) plays a greater part in WMI infrastructure:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa826699(v=VS.85).aspx
This turorial article (pretty good) describes the CIM architecture: http://www.wbemsolutions.com/tutorials/CIM/index.html
This MSDN article describes MOF: http://msdn.microsoft.com/en-us/library/windows/desktop/aa823192(v=vs.85).aspx
So in summary, there is no hard and fast rule for when the CIM database is re-populated, it depends on what the system is doing at the time and/or what a user does.
我不确定您需要的信息是否真的在任何地方都有深入记录。
根据我对 WMI 的理解,它完全基于消费者/提供者机制及其负责保持信息最新的提供者的实现。那么您的脚本就是消费者。
我可以向您推荐的一本书是 Craig Tunstall 和 Gwyn Cole 合着的《Developing WMI Solutions》。它大约有 800 页,我认为它对于任何想要使用 WMI 的人来说确实包含了足够多的细节,包括开发消费者应用程序和自定义提供程序。
http://www.amazon.com/Developing-WMI-Solutions-Management-Instrumentation/ dp/0201616130
I'm not sure the information you require is really documented in depth anywhere.
From what I understand of WMI, it is all based around a consumer/provider mechanism and its the implementation of those providers that are responsible for keeping information up-to-date. Your scripts are then consumers.
One book I can recommend to you is "Developing WMI Solutions" by Craig Tunstall and Gwyn Cole. It's about 800 pages and I think it really contains more than enough detail for anyone that wants to work with WMI, including developing consumer applications and custom providers.
http://www.amazon.com/Developing-WMI-Solutions-Management-Instrumentation/dp/0201616130