Kev Hunter
Kev Hunter

Reputation: 2625

How can I add a performance counter to a category i have already created

I have created a PerformanceCounterCategory like below

var category = PerformanceCounterCategory.Create("MyCat", "Cat Help",
    PerformanceCounterCategoryType.SingleInstance, "MyCounter", "Counter Help);

How can I add a new counter to the category to monitor another item?
I cannot find the api for it.

Upvotes: 26

Views: 5379

Answers (2)

kay.one
kay.one

Reputation: 7692

I did a research on this a while back and it doesn't seem to be possible to add counters to an existing category, what you would have to do it to recreate the same category with addition of the new counter.

Upvotes: 33

Vasu Balakrishnan
Vasu Balakrishnan

Reputation: 1771

PerformanceCounter lCounter = new PerformanceCounter(Category, CounterName, 
                                                     false);
lCounter.MachineName = ".";

Upvotes: -4

Related Questions