Resolving ‘Performance Counter OS (pdh) call failed with error code PDH_CSTATUS_BAD_COUNTERNAME.’ on SharePoint 2010
I recently came across a frustrating issue when looking at ULS logs for a client with a SharePoint 2010 installation. We were seeing huge numbers of repeated errors stating :
PDH failure on counter \<servername>\Sandboxed Code Process
Pool\\Processes Stopping with error Unknown error (0xc0000bc0)
Unable to create system performance counter <server name>\Sandboxed
Code Process Pool\<counter name>\. The following exception was
thrown: System.ComponentModel.Win32Exception: Unknown error
They were so prevalent they were clogging up the logs and making it impossible to diagnose the other issues we were looking at. (See screenshow below)
To try to resolve the issue, I opened performance monitor on the SharePoint server and look at the counters myself.
I launched the tool (Admin Tools –> Performance Monitor), selected Performance Monitor under the Monitoring Tools folder, then clicked the [+] icon on the toolbar to add counters.
Under the Available Counters list, I found the Sandboxed Code Process Pool counters and added some of them to the Added counters list.
It seemed odd that there were no instances listed in the Instance column, as most other counters have this. Sure enough, once I clicked OK, no instances of those counters were available, only the default % Processor Time counter was showing.
Our diagnostic monitoring was set to monitor events from various services including the Sandboxed Code Service, which were not running on the server at the time.
By navigating to Manage Services on Server in Central Admin and turning on the Sandboxed Code service, we were able to get the messages to disappear.
Since we did not want/need to run the sandboxed code service, we turned it back off. By setting the severity level of the logging for the Sandboxed Code Service to ‘None’, and stopping health logging (we’re using SCOM to monitor SharePoint/FAST) we were able to get the PDH_CSTATUS_BAD_COUNTERNAME and related messages to disappear from our logs.