Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't perfmon see instances of my custom performance counter?

Tags:

.net

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.

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);
}
like image 696
spoulson Avatar asked Jul 30 '09 18:07

spoulson


People also ask

How do I add a performance counter in perfmon?

In the navigation pane, expand Monitoring Tools, and then choose Performance Monitor. In the console pane toolbar, choose the Add button. In the Add Counters window, in the Select counters from computer drop-down list, choose the computer that is running Business Central Server.


1 Answers

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.

like image 126
kennbrodhagen Avatar answered Sep 22 '22 15:09

kennbrodhagen