我想在 Windows 上的 ColdFusion 中使用 WMI 或 Java 来获取性能数据
我正在滚动自己的简单的基于 Web 的 perfmon,我对通过 sql 查询使用的一些数据(例如 cpu 使用情况)不满意。我能够很好地获取内存使用情况...我将附上屏幕截图,以便您可以看到我的主/主页/仪表板页面当前的内容。
我目前正在使用 webcharts3d,我喜欢能够使用 ajax、更新图表,并且我有一个动态更新的仪表板。是的,当然我只需要获得几个性能计数器,因此我希望拥有一个基于 Web 的性能仪表板,因此我不会杀死服务器。
DECLARE @CPU_BUSY int, @IDLE int
SELECT @CPU_BUSY = @@CPU_BUSY, @IDLE = @@IDLE WAITFOR DELAY '000:00:01'
SELECT (@@CPU_BUSY - @CPU_BUSY)/((@@IDLE - @IDLE + @@CPU_BUSY - @CPU_BUSY) *1.00) *100 AS 'CPU'
我得到的结果都是 0.0000,所以要么查询是错误的,要么我的 CPU 活动很少。当我使用 Windows 任务管理器时。
这是我正在使用的用于收集内存的代码,我不主张任何这些代码的功劳,我在某个地方找到了它。
<cfscript>
jRuntime = CreateObject("java","java.lang.Runtime").getRuntime();
memory = StructNew();
memory.freeAllocated = jRuntime.freeMemory() / 1024^2;
memory.allocated = jRuntime.totalMemory() / 1024^2;
memory.used = memory.allocated - memory.freeAllocated;
memory.percentUsedAllo = (memory.used / memory.allocated) * 100;
</cfscript>
系统管理员 http://a.imageshack.us/img826/2575/sysadminscreenshot.png
所以我正在寻找更多的 wmi 或 java 或脚本来获取 cpu 使用情况,也许还有任何其他重要的服务器统计信息。
I am rolling my own simple web-based perfmon, I am not happy with some of the data I can get like cpu usage, which i use via a sql query. I am able to get memory usage just fine...I will attach a screenshot, so you can see what I currently have for my main/home/dashboard page.
I am currently using webcharts3d, which i am loving being able to use ajax, update the chart, and i have a dynamically updating dashboard. Yes of course I have to get only a few performance counter's so in my desire to have a web-based performance dashboard i do not kill the server.
DECLARE @CPU_BUSY int, @IDLE int
SELECT @CPU_BUSY = @@CPU_BUSY, @IDLE = @@IDLE WAITFOR DELAY '000:00:01'
SELECT (@@CPU_BUSY - @CPU_BUSY)/((@@IDLE - @IDLE + @@CPU_BUSY - @CPU_BUSY) *1.00) *100 AS 'CPU'
And all i get in results is 0.0000, so either the query is wrong, or i have very little cpu activity going on. Where as when I use my windows task manager.
Here is the code for gathering memory I am using, I do not claim credit for any of this code, I found it somewhere.
<cfscript>
jRuntime = CreateObject("java","java.lang.Runtime").getRuntime();
memory = StructNew();
memory.freeAllocated = jRuntime.freeMemory() / 1024^2;
memory.allocated = jRuntime.totalMemory() / 1024^2;
memory.used = memory.allocated - memory.freeAllocated;
memory.percentUsedAllo = (memory.used / memory.allocated) * 100;
</cfscript>
SysAdmin http://a.imageshack.us/img826/2575/sysadminscreenshot.png
So I am looking for more wmi or java or scripts to get cpu usage, and perhaps any other important server stat.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如何使用名为 GetMetricData 的 Coldfusion 内置函数。它可以帮助您像 Coldfusion Admin 一样监控服务器性能。我已经用 cfchart 栏完成了。如果您想与 Web3Dcharts 集成,您可以。
http://ppshein.wordpress.com/2010/08 /04/getmetricdata-for-server-monitor/
How about using Coldfusion built-in function called, GetMetricData. It can help you to monitor your server performance like Coldfusion Admin. I've done it with bar of cfchart. If you wanna integrate with Web3Dcharts, you can.
http://ppshein.wordpress.com/2010/08/04/getmetricdata-for-server-monitor/
另一个解决方案:
然后使用可靠性和性能监视器(即 perfmon),为 CPU(总计)创建一个计数器 - 它应该位于 Windows 计数器的长列表中。
您可以将此数据保存到文件或数据库中。如果将其保存到数据库,则可以使用 CF 查询该数据并获得相当准确的性能信息。当然,您可以随着时间的推移将其显示在图表上,我认为这是一个巨大的好处。
完成此操作后,您可以在 CF admin 中启用性能监控,然后您将可以在 perfmon 中获取 CF 性能指标。
我们已经在包含 10 多台机器的 CF 集群中成功实施了该解决方案,它提供了给定时间点和历史记录下的服务器性能的绝佳信息。
Another solution:
Then using the Reliability and Performance Monitor (i.e. perfmon), create a counter for CPU (Total) - it should be in the long list of Windows counters.
You can save this data to file or to a database. If you save it to a database you can then use CF to query that data and get pretty accurate performance info. You can of course display this on a graph over time which is a massive benefit in my opinion.
When you have that done you can then enable performance monitoring in CF admin, and you will then have CF performance metrics available to pick up in perfmon.
We have successfully implemented this solution across a CF cluster of 10+ machines and it gives a an excellent idea of server performance at a given point in time and historically.
CfTracker 可能有您需要的代码,并且由于它使用 Apache 许可证,您可以简单地从中获取任何相关内容一旦你适当地归因,它就会发生。
如果您可以更进一步,与 Dave Boyet 讨论如何组合您的两个工具,那就更好了 - 或者至少在共同点上进行合作。
为了更直接地回答您的问题,这里有一个 博客文章解释如何使用 ColdFusion 中的 WMI。
CfTracker probably has the code you need, and since it uses the Apache License you can simply grab any relevant stuff from it, once you attribute appropriately.
It would be even better if you could go a step further and talk to Dave Boyet about combining your two tools - or at least collaborating on the common bits.
To more directly answer your question, here's a blog article explaining how to use WMI from ColdFusion.