Errors when accessing performance counters


Description

By default, the Sitecore's HealthMonitor agent periodically logs values of performance counters to Sitecore's log files. The exact performance counters to log are configured in the web.config file. However, the HealthMonitor agent may throw various exceptions if it is unable to access some of the counters. 

These exceptions may be caused by different circumstances. Some of them may be caused by Sitecore, while others are caused by the environment settings or the .NET Framework.

If you do not want Sitecore to log performance counters values, you can safely ignore such error messages. Otherwise, try the following solutions.

Solution 1

Error message: 

WARN Counter category 'Sitecore.XXX' does not exist on this server. Using temporary internal counter for 'YYY'
Possible solution:

Some Sitecore-specific performance counters are not installed on the server.

Install the counters according to the solution section of the following article:
http://sdn.sitecore.net/faq/administration/sitecore log filling up with warnings.aspx

Updated: The zip-file was updated so that it no longer installs counters that are not in use.

For Sitecore 7.5 and later:
Please use the attached xml counters[Sitecore7.5].zip file with the sitecorecounters tool.

Solution 2

Error messages:

Option #1:

WARN Counter category '.net CLR Memory' does not exist on this server. Using temporary internal counter for 'XXX'.
ERROR Instance Name is not available
 
Exception: System.InvalidOperationException
Message: Category does not exist.
Source: System
at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category)
at System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(String categoryName, String machineName)
at Sitecore.Diagnostics.PerformanceCounters.PerformanceCounter.GetInstanceName(String categoryName, String counterName)
at Sitecore.Diagnostics.PerformanceCounters.PerformanceCounter.get_InstanceName()

Option #2:

WARN Cannot resolve Instance name for the counter. Category: .net CLR Memory, Counter name: XXX
ERROR Exception in alarm clock event subscriber.
 
Exception: Sitecore.Diagnostics.PerformanceCounters.InstanceNameIsNotAvailableException
Message: Exception of type 'Sitecore.Diagnostics.PerformanceCounters.InstanceNameIsNotAvailableException' was thrown.
Source: Sitecore.Kernel
at Sitecore.Diagnostics.PerformanceCounters.PerformanceCounter.get_InstanceName()
at Sitecore.Pipelines.HealthMonitor.HealthMonitor.LogCounterStatus(PipelineArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Services.AlarmClock.Heartbeat_Beat(Object sender, EventArgs e)

Option #3:

WARN  Cannot resolve Instance name for the counter. Category: .net CLR Memory, Counter name: XXX
ERROR Instance Name is not available
 
Exception: Sitecore.Diagnostics.PerformanceCounters.InstanceNameIsNotAvailableException
Message: Exception of type 'Sitecore.Diagnostics.PerformanceCounters.InstanceNameIsNotAvailableException' was thrown.
Source: Sitecore.Kernel at Sitecore.Diagnostics.PerformanceCounters.PerformanceCounter.get_InstanceName()

Option #4 (for Sitecore 6.6.0 Update-5 and later):

WARN  Counter 'XXX' does not exist on this server.
or
WARN  Counter category 'YYY' does not exist on this server.

Possible solution: 

It is possible that .NET performance counters are not loaded correctly, so try to reload them: 

  1. Start an administrator command prompt.
  2. Run unlodctr .NETFramework.
  3. Run lodctr %WINDIR%\Microsoft.NET\Framework\<Framework_ver>\CORPerfMonSymbols.ini 
    where <Framework_ver> is the directory of the .NET Framework version which contains the CORPerfMonSymbols.ini file. It should be either v4.0.xxx or v2.0.xxx if 4.0 is not installed.
  4. Restart IIS.

Solution 3

Error messages:

Option #1:

Exception: System.UnauthorizedAccessException 
Message: Access to the registry key 'Global' is denied. 
Source: mscorlib 
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) 
at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity)
at Microsoft.Win32.RegistryKey.GetValue(String name) 
at System.Diagnostics.PerformanceMonitor.GetData(String item) 
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item) 
at System.Diagnostics.PerformanceCounterLib.get_CategoryTable() 
at System.Diagnostics.PerformanceCounterLib.CategoryExists(String machine, String category)
at System.Diagnostics.PerformanceCounterCategory.Exists(String categoryName, String machineName)

Option #2 (for Sitecore 6.6.0 Update-5 and later):

WARN Sitecore has no necessary permissions for reading/creating counters

Possible solution: 
A Sitecore application pool user has to be a member of the system “Performance Monitor Users” group to have access to the performance counters.

Adding the user to this group and restarting IIS should resolve the problem.