CollabNet has a bug with LDAP and httpd. After a few days of use the httpd process will take up 100% of the cpu resources on the system and cause SVN to lock up. Restarting this manually is a PITA, and restarting it every N number of minutes is not acceptable. After a bit of thinking I came up with this band-aid to the problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
$PIDname = "httpd" $ServiceToKill = "CollabNetSubversionServer" $count = 0 $PIDmaxUsage = 90 $usage = Get-Process $PIDname | select-object cpu #Detect if returned object is an array if ($usage -is [system.array]){ foreach ($i in $usage) { $var = $usage[$count] if ($var.cpu -gt $PIDmaxUsage) { write-host "CPU TOO HIGH! Current usage: "$var.cpu" Restarting service" #restart service try {Restart-Service $ServiceToKill} catch {Write-host "Restart failed"} } else { write-host "Process ID: $PIDname|$count is below $PIDmaxUsage. Current Usage:"$var.cpu"" } $count += 1 } } else { $var = $usage if ($var.cpu -gt $PIDmaxUsage) { write-host "CPU TOO HIGH! Current usage: "$var.cpu" Restarting service" #restart service try {Restart-Service $ServiceToKill} catch {Write-host "Restart failed"} } else { write-host "Process ID: $PIDname|$count is below $PIDmaxUsage. Current Usage:"$var.cpu"" } } |
In short what this does is monitor a PID name ($PIDname) if it goes over $PIDmaxUsage it will begin the process of restarting the service that pertains to that process. You will notice that I check if the returned value is an array, this is because more than one httpd process can exist you can remove this if needed but it will check through each element of the array and restart the service pertaining to it if its over $PIDmaxUsage. If there isnt an array it will just restart the single process.
Obviously I would rather an actual fix from CollabNet as this seems to be an issue others are also having but at least for now its a band-aid that is working well. Hope that helps!