Tech Off Thread

5 posts

perfmon counters are corrupted

Back to Forum: Tech Off
  • User profile image
    ScanIAm

    Somehow I've corrupted my perfmon counters to the point where they show up as numbers instead of names.  My machine is Win2k and my application was trying to add counters to a catagory when the debugger crashed.  My software is unable to access the correct catagories now and throws an exception whenever I try to access these counters.  Further, if you go into perfmon, there are numbers for catagories and there are no counters under any of the catagories.

    I've tried KB300956, but that did not solve the issue.  Do I have any other options besides a complete reinstall?  I don't expect any hand holding, but KB300956 was a long, drawnout pain in the butt that didn't work.

  • User profile image
    Mike Dimmick

    The recommended way of adding new performance counters is to use lodctr.exe, or the LoadPerfCounterTextStrings API.

    How far did you get with KB300956? I suspect that you've only corrupted the information in the Counter and Help values, so you shouldn't need to restore the DAT files.

    Looking at the DATs, it looks like they're simply copies of the Counter and Help values. Also, it looks like perfd009.dat is the original version of perfc009.dat, and perfi009.dat the original of perfh009.dat (you may not have these files, I'm looking at Windows XP SP2 here). I don't know whether the performance counter APIs actually use these DAT files or the registry values directly.

    So a possible fix would be to load the files up in their entirety and use RegSetValueEx to put the data back into the registry. I'm NOT claiming that this will work. I'm just saying it's a possibility. Use at your own risk.

    If this does work you should leave a note on the KB article feedback indicating that replacing the DATs isn't enough.

    If that doesn't work I think it's reinstall time. You can reinstall without losing your existing settings by following the instructions in KB292175 - How to perform an in-place upgrade of Windows 2000.

  • User profile image
    ScanIAm

    This took me a few days to return to, but I appreciate your help.  KB300956 may actually be the solution, if you know how to expand cab files (I thought I did, but I was wrong).  Turns out, that unless you specify the destination file name, the expanded file is expanded and copied, but it isn't renamed to the correct name. 

    For example, the files were called perfc009.da_ instead of perfc009.dat.  Once I figured this out, I ran a windiff, and you are correct.  The files are duplicates (i.e. perfd009.dat == perfc009.dat and perfi009.dat == perfh009.dat).

    Once I renamed these files and rebooted, I was able to see my performance counters again.  Now, I need to redo the lodctr.exe on each .ini file and reboot again.  I'm sure this will work now that the perfnxxx.dat files are correct.

    I did have a question, though.  You mentioned in your response that there were a few recommended ways to deal with perf counters.  I will take a look at this and I agree with you that setting these up once and only using them from the app is a better way to do this, but the method I was using was through .Net using the CounterCreationData and PerformanceCounterCategories classes.  Shouldn't those work as well?


     

  • User profile image
    ScanIAm

    Given the timespan between comments, I added a second comment instead of editing. 

    I found that while the performance counters were there, the .Net performance counters were missing.  After some hunting, I found this:

    http://blogs.msdn.com/mikedodd/archive/2004/10/17/243799.aspx

    I followed the directions, but I also did a lodctr on:

    aspnet_perf.ini
    aspnet_perf2.ini
    corperfmonsymbols.ini (described above in the link)
    _dataperfcounters.ini
    _Networkingperfcounters.ini

    We'll see if it worked.

    Edit:

    Well, that caused some duplicates.  I'm going to simply follow the directions in the link above and only lodctr the corperfmonsymbols to see if that works.  I'm not too worried about the asp perf symbols at this point.

    Edit:
    That worked.  I'm missing the asp.net perf counters, but it appears that aspnet_perf.ini and aspnet_perf2.ini are identical except for their date.

    After running lodctr aspnet_perf.ini all was well.


    To summarize, follow these steps to restore your counters:

    1) KB300956 this will clear you out.
    2) To fix .Net performance counters Click Here
    3) To fix Asp.Net performance counters, head to your c:\winnt\Microsoft.net\framework\v1.1.4322 path and type:  lodctr aspnet_perf.ini

    I should really write a quick app that does this...

  • User profile image
    Anttu

    ScanIAm said:
    Given the timespan between comments, I added a second comment instead of editing. 

    I found that while the performance counters were there, the .Net performance counters were missing.  After some hunting, I found this:

    http://blogs.msdn.com/mikedodd/archive/2004/10/17/243799.aspx

    I followed the directions, but I also did a lodctr on:

    aspnet_perf.ini
    aspnet_perf2.ini
    corperfmonsymbols.ini (described above in the link)
    _dataperfcounters.ini
    _Networkingperfcounters.ini

    We'll see if it worked.

    Edit:

    Well, that caused some duplicates.  I'm going to simply follow the directions in the link above and only lodctr the corperfmonsymbols to see if that works.  I'm not too worried about the asp perf symbols at this point.

    Edit:
    That worked.  I'm missing the asp.net perf counters, but it appears that aspnet_perf.ini and aspnet_perf2.ini are identical except for their date.

    After running lodctr aspnet_perf.ini all was well.


    To summarize, follow these steps to restore your counters:

    1) KB300956 this will clear you out.
    2) To fix .Net performance counters Click Here
    3) To fix Asp.Net performance counters, head to your c:\winnt\Microsoft.net\framework\v1.1.4322 path and type:  lodctr aspnet_perf.ini

    I should really write a quick app that does this...

    I also had problem with missing performance counter. The ones that were missing was the System and Processor objects. Most of the findings on the net refers to the KB300956. However, that didn't solve my problem, it only removed the .Net, ASP.NET SQLServer etc counters but didn't return my system and processor categories. I also had problem running the lodctrl /R command and after some more searching I found this forum thread (http://www.theeldergeek.com/forum/index.php?showtopic=22486) that suggested a colon at the end of the command, which made the command work for me. So it should be lodctr /R:

     

    After several hours of struggeling I discovered a registry key that was the cause of the error.

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfOS\Performance

    in it there was a Disable Performance Counters value that was set to 1. I changed the value to 0 and rebooted the computer. It worked!!

     

    There's also other PerfXX keys @ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. If you're missing other counters, try look into these or do a registry find for Disable Performance Counters.

     

    Hope this helps someone on the right track!

     

    /Anttu

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.