none
PerformanceCounter category reset on install? RRS feed

  • Question

  • Hello,

    I have two windows services in separate assemblies. They are writing data to a performance counters of the same (custom) category, but different names.

    However, if I install the first service and then install the second one, only the names defined in the second service are displayed under the counter category. Isn't this supported scenario? Does the installer code removes all registered names in the custom category?

    Any way to get both services write into the same counter category or do I need to create separate category for each service?

     

    Thanks,

    Jan

    Friday, June 18, 2010 11:33 PM

Answers

  •  

    I see, you are using PerformanceCounterInstaller. PerformanceCounterInstaller will create a new performance category when installing, and delete the category when uninstalling, that's why the second category overwrite the first one.

    As far as I know, we cannot add/remove new counter to/from an existing category, so you may consider creating different categories for the two services.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Jan Kučera Tuesday, June 22, 2010 10:22 AM
    Tuesday, June 22, 2010 6:49 AM

All replies

  • Hi,

    It sounds to me that you delete and create new category when install service, so only the latter category displayed.

    In the InitializeComponent method of ProjectInstaller class, you may check whether a category is existing, if so, just set category name to existing category name, to let the second windows service use same counter category with the first service.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, June 21, 2010 4:01 AM
  • Hi, thanks for your reply!

    Well basically in both constructors of installator class of the services there is

    PerformanceCounterInstaller serviceCounterInstaller = new PerformanceCounterInstaller
    {
          CategoryName = "MyCategory",
          CategoryType = PerformanceCategoryType.MultiInstance
    }
    serviceCounterInstall.Counters.Add(new CounterCreationData("CounterName", ...));

     

    So you suggest me that I should not use the PerformanceCounterInstaller if I find out that the category already exists? How do I add/remove the individual counters then?

    Also, if I uninstall one service, it takes the category away too, can I somehow detect that the category is still being used by other services and not remove it?

    Thanks,

    Jan

    Monday, June 21, 2010 5:15 PM
  •  

    I see, you are using PerformanceCounterInstaller. PerformanceCounterInstaller will create a new performance category when installing, and delete the category when uninstalling, that's why the second category overwrite the first one.

    As far as I know, we cannot add/remove new counter to/from an existing category, so you may consider creating different categories for the two services.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Jan Kučera Tuesday, June 22, 2010 10:22 AM
    Tuesday, June 22, 2010 6:49 AM