Tuesday, September 15, 2009

IIS7 64Bit Hang Dump.. The hard way


So I have done so many searches and have not been able to find a half decent way to get a dump when IIS7 running 64bit has hung. DebugDiag even the updated one might run on a 64bit machine but does not seem capable of generating a 64bit crash dump file. The documentation on this subject is pretty poor on the 64b aspect of IIS7 running asp.net. That being said here is how I solved the problem if anyone has a better solution I would love to hear it.


The best solution I have found is to install the debugging tools on the target machine. Then use the code below in a powershell script and run the script in your console session adjust the interval or the time out as needed for your circumstance.


$interval = 2;
$timeout = 15;
$url = 'http://www.mywebsite.com'
$command =
$client = New-Object Net.WebClient;
$client.CachePolicy = New-Object Net.Cache.RequestCachePolicy([Net.Cache.RequestCacheLevel]::NoCacheNoStore);
Write-Host "Begin Monitoring $url";
$elapsed = $null;
$interval = New-Object System.TimeSpan(0,0,0,$interval,0);
do
{
Write-Host "Waiting for next test cycle in $interval"
[System.Threading.Thread]::Sleep($interval);
$started = [System.DateTime]::Now.Ticks;
$client.QueryString['t'] = $started;
$response = $client.DownloadString($url);
$ended = [System.DateTime]::Now.Ticks;
$elapsed = New-Object System.TimeSpan($ended - $started);
Write-Host "$url completed in $elapsed"
}
while ($timeout -gt $elapsed.Seconds)
if($timeout -lt $elapsed.Seconds)
{
$ended = [System.DateTime]::Now;
Write-Host "Dumping All Worker Processes at $ended";
&'C:\Program Files\Debugging Tools for Windows (x64)\dumphangw3wp.cmd'
}

Content of dumphangw3wp.cmd


cscript.exe "C:\Program Files\Debugging Tools for Windows (x64)\ADPlus.vbs" -hang -pn w3wp.exe -o "C:\Dump Files" -quiet

No comments:

Post a Comment