corrupted performance counters?

帅比萌擦擦* 提交于 2019-12-06 18:47:42

问题


Preformance counters are EVIL. don't use them.

if(PerformanceCounterCategory.Exists("ILoveYou")  ) // is true
{
    PerformanceCounterCategory.Delete("ILoveYou"); 
    //throws exception The **configuration registry** key is invalid
}

at System.Diagnostics.PerformanceCounterLib.RegisterFiles(String arg0, Boolean unregister)
at System.Diagnostics.PerformanceCounterLib.UnregisterCategory(String categoryName)
at System.Diagnostics.PerformanceCounterCategory.Delete(String categoryName)
at WindowsFormsApplication1.Program.SetupCategory()

all I found is this: http://blogs.msdn.com/b/oanapl/archive/2009/04/24/fix-corrupted-performance-counters.aspx (Using LODCTR /R)

and it doesn't help. as i have no idea what file are they talking about. any1 got any other ideas?

PS I use windows xp SP3 may this be the problem? i understand it is suppose to support performance counters fully unless I cancel the page file.

to make this clear my problemis that im unable to UNINSTALL my counters.


回答1:


My company runs into problems with the performance counters getting corrupt regularly. If it is a problem with the actual counters being corrupt, you can check for corrupted Performance Counters by:

  1. Going to start | run | perfmon
  2. Click OK
  3. Click on the add button on the toolbar in the right panel ("+" sign button)
  4. Ensure that the proformance object drop down menu contains items and not just numbers
If the Counters are numbers or Blank:
  • Locate and Rename these 3 files in %windir%\system32:
    • Perfc009.dat
    • Perfh009.dat
    • Perfi009.dat
  • Insert the Windows XP Install CD
  • Browse to their CD drive and into the I386 Folder (i.e. D:\I386)
  • Locate those same files here
  • Copy and Paste them from the CD back into System32
  • Reboot the computer.
  • This is the best solution we have found for the issue.




    回答2:


    If you have a similar machine you can run lodctr /S:mycounters.ini to export all counters to 'mycounters.ini' and then import them on a broken machine with lodctr /R:mycounters.ini. Keep in mind though, I've only used this procedure on two machines that I knew were almost identical in terms of perf counters. I do not know if there would be issues with machines that do not match.




    回答3:


    For me,

    it was sufficient to re-create all performance counters with

    lodctr /R
    

    from a command-line with administrative rights (according to this, but skipping the manual recreation of the base performance counters)

    When checking the list of performance counters in the registry in

     HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009
    

    it turned out that the content of that key startet with lots of whitespace. There was a list of performance counters with high counter indices at the very end of that key. After calling the command above, the key correctly contained the base performance counters as well (and did not contain the leading whitespace any more).




    回答4:


    Performance counters favor speed over usability and correctness. The performance counters in XP and later Windows versions can easily be broken. It is e.g. a very bad practice to create a new performance counter category on startup of your app and delete it on shutdown. Constant change to the performance counter categories is a sure receipe of getting corrupt performance counters.

    I would create the categories only when it does not yet exist and leave it there until your app is uninstalled. Under what circumtances do you want to delete a performance counter category? The basic answer I can give to you is to not delete performance counter categories unless you need to.

    A good link how to recreate performance counters via lodctr or EXCTRLST is from RedGate. You can download it here.

    Edit1

    First you need to find a tool that does fix your issue. Exctrlst gives you a UI to re enable corrupt preformance counters.

    If that does work you can now check with procmon which registry keys are written during the repair operation and use this as input for your autorepair feature.



    来源:https://stackoverflow.com/questions/10779699/corrupted-performance-counters

    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!