I did all the basics that I normally do when troubleshooting an Application Template that doesn’t seem to be pulling data properly and then I finally got on the server itself and checked for the Performance Counters. I opened PerfMon on that machine and got this lovely error.
Searching around, I found this solution. Now before I reload all the counters from the cache, I wanted to make sure that my Exchange Counters would be returned to their upright position.
Now this is an Exchange 2016 server, so I went to the same (relative) location and looked for similar files.
So then I thought about going through all of the counters that I need to replace and importing them one at a time. Then I thought again. PowerShell to the rescue!
$InstallPath = Get-Item -Path ( Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup -Name MsiInstallPath | Select-Object -ExpandProperty MsiInstallPath ) -ErrorAction SilentlyContinue
$PerfFiles = Get-ChildItem -Path ( Join-Path -Path $InstallPath -ChildPath "\Setup\Perf\*.xml" )
$i = 0; $iCount = $PerfFiles.Count
ForEach ( $PerfFile in $PerfFiles )
$CounterName = ( [xml]( Get-Content -Path $PerfFile.FullName ) ).Category.Name
Write-Progress -Activity "Updating Performance Counters" -CurrentOperation "[$( $i + 1 )/$( $iCount )] $( $CounterName )" -PercentComplete ( ( $i / $iCount ) * 100 )
Write-Host "Removing Performance Counter: $CounterName" -Foreground Red
Remove-PerfCounters -DefinitionFileName $PerfFile.FullName
Write-Host "Adding Performance Counter: $CounterName" -Foreground Green
New-PerfCounters –DefinitionFilename $PerfFile.FullName
Write-Progress -Activity "Updating Performance Counters" -Completed
I have a love/hate relationship with the “Write-Progress” function, but here it seemed worthwhile because of the sheer number of performance counters (254 in my environment).
Please note that this is a lab machine and as such is non-production. I have no idea if these steps would impact service availability. If you have a properly configured Database Availability Group, just fail all your databases to other servers and you should be fine. When in doubt, refer to this page.
After the Exchange Performance Monitors are added back, I ran the lodctr command to rebuild the counters. Then just to be safe, I ran it a second time to make sure that there were no errors.
Since I had no active databases on this server, I rebooted it. You probably don’t need to do that, but… why not, right? All your databases are active and protected on other servers, right?
After a few minutes SolarWinds Server & Application Monitor started reading and recording the metrics!
For an Exchange Admin, there’s nothing more satisfying than knowing that your servers are healthy and your users can access their content – even if it is just a lab environment!
Until next time ramblers!