为什么perfmon无法看到我的自定义性能计数器的实例? [英] Why can't perfmon see instances of my custom performance counter?

查看:47
本文介绍了为什么perfmon无法看到我的自定义性能计数器的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为应用程序创建一些自定义性能计数器.我编写了一个简单的C#工具来创建类别和计数器.例如,下面的代码片段基本上就是我正在运行的代码.然后,我运行一个单独的应用程序,该应用程序不断刷新计数器的原始值.在运行的同时,计数器和虚拟实例可以在perfmon中本地看到.

I'm creating some custom performance counters for an application. I wrote a simple C# tool to create the categories and counters. For example, the code snippet below is basically what I'm running. Then, I run a separate app that endlessly refreshes the raw value of the counter. While that runs, the counter and dummy instance are seen locally in perfmon.

我遇到的问题是,当从另一台服务器远程查看时,我们使用的监视系统无法在我创建的多实例计数器中看到实例.当使用perfmon浏览计数器时,我可以看到类别和计数器,但是实例"框显示为灰色,我什至不能选择所有实例",也不能单击添加".使用其他访问方法,例如 [typeperf] [1] 也会遇到类似的问题.

The problem I'm having is that the monitoring system we use can't see the instances in the multi-instance counter I've created when viewing remotely from another server. When using perfmon to browse the counters, I can see the category and counters, but the instances box is grayed out and I can't even select "All instances", nor can I click "Add". Using other access methods, like [typeperf][1] exhibit similar issues.

我不确定这是服务器还是代码问题.这只能在我需要的生产环境中重现.在我的台式机和开发服务器上,它运行良好.我是所有服务器上的本地管理员.

I'm not sure if this is a server or code issue. This is only reproducible in the production environment where I need it. On my desktop and development servers, it works great. I'm a local admin on all servers.

CounterCreationDataCollection collection = new CounterCreationDataCollection();

var category_name = "My Application";
var counter_name = "My counter name";
CounterCreationData ccd = new CounterCreationData();
ccd.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
ccd.CounterName = counter_name;
ccd.CounterHelp = counter_name;
collection.Add(ccd);

PerformanceCounterCategory.Create(category_name, category_name, PerformanceCounterCategoryType.MultiInstance, collection);

然后,在一个单独的应用程序中,我运行它来生成虚拟实例数据:

Then, in a separate app, I run this to generate dummy instance data:

var pc = new PerformanceCounter(category_name, counter_name, instance_name, false);
while (true) {
   pc.RawValue = 0;
   Thread.Sleep(1000);
}

推荐答案

您的程序是否是在Windows 2008 R2或其他64位Windows OS上运行的32位程序?如果是这样,您可能要检查服务"Performance Counter DLL Host"是否正在运行.此服务使64位和远程进程能够查询32位进程提供的计数器.

Does your program happen to be a 32-bit program running on Windows 2008 R2 or another 64 bit windows OS? If so you may want to check that the service "Performance Counter DLL Host" is running. This service enables 64-bit and remote processes to query counters provided by 32-bit processes.

这篇关于为什么perfmon无法看到我的自定义性能计数器的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆