Database Management
Rebuild Windows or SQL Performance Counters for SQL Sentry monitoring
How to Rebuild Windows/SQL Performance Counters
First published date
Last published date
Overview
The performance counters for a target have become corrupt or otherwise unviewable. You will know this happens when you see errors about missing counters.
Product section
Cause
Counters are notoriously fragile and sometimes break on their own during regular patching, restarts, or updates.
Resolution
Identify the missing counter(s). The error typically mentions it, or the Dashboard metric will not be visible. The following options will help you troubleshoot and/or rebuild the performance counter(s). (Note that the changes below may break monitoring for other monitoring applications and require server restarts. Please read all steps before you begin the process.)
Scripts are not supported under any SolarWinds support program or service. Scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.
SQL Counters
Note: If this pertains to a named SQL instance, replace all references to MSSQLSERVER with MSSQL$<InstanceName>.
Option 1 (SQL):
- Make sure the "Remote Procedure Call (RPC)" and "Windows Management Instrumentation" services are running on the target(s) and Monitoring Service host(s)
- Restart of the Remote Registry service on the target(s)
- Then restart the SQL Sentry Monitoring Service(s) themselves.
Option 2 (SQL):
If you cannot see and load the missing counter(s) in Perfmon (check locally and remotely from the server hosting the monitoring service).
- If they’re not there, check the following path in the Registry (regedit.exe) for the “Disable Performance Counter” value: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Performance.
- If this value is present and is set to 1, change it to 0.
- Restart the Remote Registry service on the target server.
- Restart the SQL Sentry Monitoring service(s).
If you can see and load the counter(s) in Perfmon, and a restart of the Remote Registry service does not resolve the issue, and the “Disable Performance Counter” value is not present, then the counters could be corrupted, and you may need to rebuild them using the following steps (keep in mind that the rebuild is restoring from what is already in the machine so if the original is corrupted this process will not fix the counter):
- Open Command Prompt as Administrator.
- Change paths to the SQL SERVER Binn directory path.
- Example: cd C:\Program Files\Microsoft SQL Server\MSSQLSERVER\MSSQL\Binn
- Run “unlodctr MSSQLSERVER” (if named instance, use the relevant instance name).
- For SSAS, use “unlodctr MSSQLServerOLAPService”.
- Run “lodctr perf-MSSQLSERVERsqlctr.ini” (if named instance, use the relevant .ini file from the Binn).
- For SSAS, use “lodctr perf-MSSQLServerOLAPServicemsmdctr.ini”
- Restart the Remote Registry service.
- Restart the Performance Logs and Alerts service.
- Restart SQL Sentry Monitoring service(s).
Option 3 (SQL\ Windows):
If the specific counter(s) are still unavailable and the above steps do not work, please run through the steps to rebuild the Windows and SQL counters.
Windows Counters
If you continue to have issues even after reloading the SQL Server counter(s), particularly missing Windows counter(s), follow the options below to troubleshoot and rebuild the entire performance counter library.
Option 1 (Windows):
- Make sure the "Remote Procedure Call (RPC)" and "Windows Management Instrumentation" services are running on the target(s) and Monitoring Service host(s)
- Restart of the Remote Registry service on the target server(s)
- Then restart the SQL Sentry Monitoring Service(s) themselves.
Option 2 (Windows):
If you cannot see and load the missing counter(s) in Perfmon (check locally and remotely from the server hosting the monitoring service).
- If the SQL Sentry Client mentions the System, Memory, and Page File counters specifically, check the following path in the Registry (regedit.exe) for the “Disable Performance Counter” value: HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/PerfOS/Performance.
- If this value is present and is set to 1, change it to 0.
- Restart the Remote Registry service on the target server.
- Restart the SQL Sentry Monitoring service(s).
- If the SQL Sentry client mentions the Physical Disk counter specifically, check the following path in the Registry (regedit.exe) for the “Disable Performance Counter” value: HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/PerfDisk/Performance
- If this value is present and is set to 1, change it to 0.
- Restart the Remote Registry service on the target server.
- Restart the SQL Sentry Monitoring service(s).
- In general check the following path in the Registry (regedit.exe) for the “Disable Performance Counter” value:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib
-
- If this value is present and is set to 1, change it to 0.
- Restart the Remote Registry service on the target server.
- Restart the SQL Sentry Monitoring service(s).
If you can see and load the counter(s) in Perfmon, and a restart of the Remote Registry service does not resolve the issue, and the “Disable Performance Counter” value is not present, then the counters could be corrupted, and you may need to rebuild them using the following steps (keep in mind that the rebuild is restoring from what is already in the machine so if the original is corrupted this process will not fix the counter):
NOTE: If you get an error when running the rebuild counters command, you can just run it again.
- Open Command Prompt as Administrator.
- Change path to C:\Windows\System32.
- Run the command: lodctr /R
- Change path to C:\Windows\syswow64
- Run the command: lodctr /R
- Restart the Remote Registry service on the target.
- Restart the SQL Sentry Monitoring service(s).
If the specific counter(s) are still unavailable and the above steps do not work, please run through the options to rebuild the Windows and SQL counters.
Option 4 (Windows):
If the specific counter(s) can be viewed locally but not remotely, and the above steps did not work, please try the following:
Note: This command must be run on the target machine, and a reboot is required (the shutdown command will take care of this).
- winmgmt /resyncperf
- shutdown /r /t 0
Option 5 (Windows):
Rebuilding the Windows Management Instrumentation (WMI) repository can help resolve issues related to WMI corruption. Here are the steps to do it:
- Open Command Prompt as Administrator.
- Run the following command to check if the repository is consistent:
- If the repository is consistent, you will see a message indicating it is consistent. If not, proceed to the next step.
- winmgmt /verifyrepository
- Run this command to attempt to salvage the repository. (This command tries to repair the repository without losing any data. If it fails, you may need to reset the repository.)
- winmgmt /salvagerepository
- If salvaging doesn’t work, reset the repository with this command: (This command will reset the WMI repository to its default state.)
- winmgmt /resetrepository
- Restart the target server after running the above commands to apply the changes.
- Restart the SQL Sentry Monitoring service(s).
If all the above options have failed to restore the SQL or Windows counter(s), please contact Microsoft for additional assistance.
References: