Bug 59209 - Custom (user defined) Performance Counter is not accessible from another process
Summary: Custom (user defined) Performance Counter is not accessible from another process
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: Interop (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-09-04 13:20 UTC by ivanov.niko.v
Modified: 2017-09-11 13:22 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description ivanov.niko.v 2017-09-04 13:20:04 UTC
I need to create custom performance counter(s) in my application and use it from another application. But i can not to access to custom performance counter form another process. What am I doing wrong? Does Mono supports access to user defines counters from another process?

Process #1 (creating custom performance counters)
var CategoryName = "TestCategory";

            if (PerformanceCounterCategory.Exists(CategoryName))
            {
                Console.WriteLine(string.Format("Category '{0}' already exists", CategoryName));
                PerformanceCounterCategory.Delete(CategoryName);
                Console.WriteLine(string.Format("Category '{0}' has been deleted", CategoryName));
            }

            string CategoryDescription = "Test category description";
            var CCDC = new CounterCreationDataCollection();

            var CounterData = new CounterCreationData
            {
                CounterName = "TestCounter",
                CounterType = PerformanceCounterType.NumberOfItems64,
                CounterHelp = "Test counter description"
            };

            CCDC.Add(CounterData);

			PerformanceCounterCategory.Create(CategoryName, CategoryDescription, PerformanceCounterCategoryType.SingleInstance, CCDC);


Process #2 (access to counters from Process #1)
var categories = PerformanceCounterCategory.GetCategories();
            var CategoryName = "TestCategory";
            categories = PerformanceCounterCategory.GetCategories(".");
                
            var found = categories.FirstOrDefault(c => c.CategoryName == CategoryName); //HERE found is null
            Console.WriteLine("Category '{0}' {1}", CategoryName, found != null ? "exists" : "not found");
                
var CounterName = "TestCounter";
                PerformanceCounter pc = new PerformanceCounter(CategoryName, CounterName, false);
//NEXT LINE PRINT NEW COUNTER PROPERTIES, WITH DIFFERENT COUNTER VALUES FROM PROCESS #1 REGISTERED COUNTERS
                Console.WriteLine("pc.CategoryName={0}, pc.CounterName={1}, pc.CounterType={2}, pc.InstanceName= {3}, pc.MachineName={4}, pc.ReadOnly={5}, pc.CounterHelp={6}, pc.RawValue={7}",                             pc.CategoryName, pc.CounterName, pc.CounterType, pc.InstanceName, pc.MachineName,                             pc.ReadOnly, pc.CounterHelp, pc.RawValue);
Comment 1 ivanov.niko.v 2017-09-04 16:07:40 UTC
I am using Mono 4.6.1 in OpenSUSE.
Comment 2 Marek Safar 2017-09-11 13:22:22 UTC
Performance counter are in shared momo memory but this does not seem to work

Note You need to log in before you can comment on or make changes to this bug.