Troubleshooting “Data Collector Set or Dependencies Already in Use” Error in Windows Server 2008 Perfmon


11 views

When working with Performance Monitor (perfmon) on Windows Server 2008, you might encounter the frustrating error message: "The Data Collector Set or one of its dependencies is already in use.". This typically occurs when attempting to start a newly created Data Collector Set (DCS).

From my experience troubleshooting similar issues, these are the most frequent scenarios:

  • Another instance of perfmon is running the same DCS
  • The DCS was improperly terminated in a previous session
  • System resources are locked by another performance monitoring tool
  • Permission issues with the output location

Before diving into solutions, let's verify the exact state of your performance monitoring:

logman query -ets

This command will list all running Event Trace Sessions. Look for any entries that might be using your target DCS.

If you identify a stuck session, use this PowerShell command to terminate it:

Stop-PerfCollectorSet -Name "YourCollectorSetName" -Force

Alternatively, the command-line approach:

logman stop "YourCollectorSetName" -ets
logman delete "YourCollectorSetName"

In persistent cases, you might need to clean up registry entries:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI\Autologger]
"YourCollectorSetName"=-

Warning: Always back up your registry before making changes.

Here's a complete PowerShell script I've used to handle this issue:

function Reset-PerfmonSessions {
    param(
        [string]$CollectorSetName
    )
    
    try {
        # Stop if running
        logman stop $CollectorSetName -ErrorAction SilentlyContinue
        
        # Delete existing
        logman delete $CollectorSetName -ErrorAction SilentlyContinue
        
        # Clean up potential registry residue
        $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger"
        if (Test-Path "$regPath\$CollectorSetName") {
            Remove-Item -Path "$regPath\$CollectorSetName" -Force
        }
        
        # Restart the service for good measure
        Restart-Service -Name "pla" -Force
        
        return $true
    }
    catch {
        Write-Error $_.Exception.Message
        return $false
    }
}

To avoid this issue in the future:

  • Always properly stop DCS through perfmon UI or logman stop
  • Implement unique naming for your collector sets
  • Consider adding error handling to your monitoring scripts

When working with Performance Monitor (Perfmon) on Windows Server 2008, you might encounter the frustrating error: "The Data Collector Set or one of its dependencies is already in use.". This typically occurs when attempting to start a newly created Data Collector Set (DCS).

The issue often manifests in environments with:

  • Identically configured virtual machines (where it works on one but not another)
  • Previously terminated DCS sessions that didn't clean up properly
  • Conflicting performance counters
  • Permission issues with the Performance Log Users group

Before diving deep, try these PowerShell commands to check active collectors:

# List all running data collector sets
Get-WmiObject -Namespace "root\cimv2" -Class "Win32_PerfFormattedData" | 
Where-Object {$_.Name -like "*YourCollectorSetName*"}

# Alternative method using logman
logman query -ets

Here's a step-by-step method to resolve the issue:

1. Force Stop All Running Collectors

# PowerShell command to stop all running collectors
Get-WmiObject -Namespace "root\cimv2" -Class "Win32_PerfFormattedData" | 
ForEach-Object {
    if ($_.Name -match "YourCollectorSetName") {
        $_.Stop()
    }
}

# Alternative using logman
logman stop "YourCollectorSetName" -ets
logman delete "YourCollectorSetName"

2. Reset Performance Counters

# Rebuild performance counters
lodctr /r

# For more thorough reset
unlodctr /q
lodctr /q

3. Check for File Locks

The DCS might be locked due to output files. Check with:

# PowerShell to find locked files
$handleExe = "$env:SystemRoot\System32\handle.exe"
if (Test-Path $handleExe) {
    & $handleExe -a "YourCollectorSetName"
} else {
    Write-Warning "Handle.exe not found in System32"
}

For recurring issues, create this PowerShell script:

# Perfmon DCS Cleanup Script
$collectorName = "YourCollectorSetName"

try {
    # Stop if running
    logman stop $collectorName -ets -ErrorAction SilentlyContinue
    
    # Delete existing
    logman delete $collectorName -ErrorAction SilentlyContinue
    
    # Recreate with proper permissions
    $user = "$env:USERDOMAIN\$env:USERNAME"
    logman create counter $collectorName -o "C:\PerfLogs\$collectorName.blg" -f bin -si 15 --v -c "\Processor(_Total)\% Processor Time" "\Memory\Available MBytes" -u $user
    
    # Start fresh
    logman start $collectorName
    
    Write-Host "Successfully reset $collectorName" -ForegroundColor Green
} catch {
    Write-Error "Failed to reset collector: $_"
}

If the issue persists, examine these areas:

  • Windows Event Viewer logs (Application and System)
  • Resource Monitor for handle conflicts
  • Process Explorer for detailed process information

To avoid future occurrences:

# Scheduled task to clean up stale collectors
$action = New-ScheduledTaskAction -Execute "logman.exe" -Argument "stop YourCollectorSetName -ets"
$trigger = New-ScheduledTaskTrigger -AtLogOn
Register-ScheduledTask -TaskName "PerfmonCleanup" -Action $action -Trigger $trigger -RunLevel Highest