Detect httpd high CPU usage and restart it (CollabNet SVN fix) – Powershell

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:

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!

0 comments… add one

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.