Stop IntelliTrace write action
Microsoft.SystemCenter.IntelliTraceProfiling.StopIntelliTrace.WriteAction (WriteActionModuleType)
Stop IntelliTrace profiling for an IIS application pool
Element properties: Member Modules:
Overrideable Parameters:
Source Code: <WriteActionModuleType ID="Microsoft.SystemCenter.IntelliTraceProfiling.StopIntelliTrace.WriteAction" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IISApplicationPath" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:unsignedInt"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IISApplicationPath" Selector="$Config/IISApplicationPath$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PA" TypeID="Microsoft.SystemCenter.IntelliTraceProfiling.GetApplicationPool.ProbeActionType">
<IISApplicationPath>$Config/IISApplicationPath$</IISApplicationPath>
</ProbeAction>
<WriteAction ID="WA2" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>StopIntelliTrace.ps1</ScriptName>
<ScriptBody><Script>
param($intelliTraceInstallPath, $applicationPoolName)
$ErrorActionPreference = "Stop"
Import-Module "$($intelliTraceInstallPath)\Microsoft.VisualStudio.IntelliTrace.PowerShell.dll"
$traceStatus = Get-IntelliTraceCollectionStatus | Where-Object {$_.OutputPath -ne $null -and $_.CollectionPlanPath -ne $null -and $_.ApplicationPool -eq $applicationPoolName} | Select-Object -First 1
try
{
$lock = [System.IO.File]::Open( [System.IO.Path]::Combine($traceDirectory, ".lock") , [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None)
}
catch [System.IO.IOException]
{
throw "IntelliTrace cannot stop right now. The collect snapshot operation is currently running for the selected application pool. Wait for collection to complete, and then try to stop IntelliTrace again."
exit 1
}
try
{
Stop-IntelliTraceCollection $applicationPoolName -Confirm:$false
Start-Sleep -Seconds 5
}
finally
{
if($traceStatus -ne $null)
{
try
{
$traceDirectory = [System.IO.Path]::GetDirectoryName($traceStatus.OutputPath)
Remove-Item $traceDirectory -Force -Recurse
}
catch {}
}
$lock.Close()
}
</Script> </ScriptBody>
<Parameters>
<Parameter>
<Name>IntelliTraceInstallPath</Name>
<Value>$Data/Property[@Name='IntelliTraceInstallPath']$</Value>
</Parameter>
<Parameter>
<Name>ApplicationPoolName</Name>
<Value>$Data/Property[@Name='ApplicationPoolName']$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA2">
<Node ID="PA"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>