We are running Citrix boxes, and on these Citrix boxes, we are running a legacy program. This is an interim solution until we can migrate away from our legacy program. The problem is that people start more than one instance of the program, and it bogs down the Citrix boxes. I designed a WMI (PowerShell) script to find all iterations of the program running, and look for the top five memory consumers by Working Set of memory. The problem is, it runs in PowerShell interface but won't run when I plug it into the PowerShell Script and try to create a template with it. I need some help troubleshooting my PS script.
Script Arguments: sh ${SCRIPT} 1.1.1.1
Script Body:
function ToArray
{
begin
{
$output = @();
}
process
{
$output += $_;
}
end
{
return ,$output;
}
}
$AR = (gwmi -ComputerName SRV-CTXCS01 Win32_PerfFormattedData_PerfProc_Process | select IDProcess,Name,WorkingSet | ?{($_.name -like "TSAgent2*")} | sort WorkingSet -Descending | Select -First 5) | ToArray
$AB = $AR -split " "
$PID1 = $AB[0].TrimStart("@{IDProcess=")
$PID1 = $PID1.TrimEnd(";")
$PN1= $AB[1].TrimStart("Name=")
$PN1= $PN1.TrimEnd(";")
$PWS1 = $AB[2].TrimStart("WorkingSet=")
$PWS1 = $PWS1.TrimEnd("}")
$PID2 = $AB[3].TrimStart("@{IDProcess=")
$PID2 = $PID2.TrimEnd(";")
$PN2= $AB[4].TrimStart("Name=")
$PN2= $PN2.TrimEnd(";")
$PWS2 = $AB[5].TrimStart("WorkingSet=")
$PWS2 = $PWS2.TrimEnd("}")
Write-Host "Message.ProcessName: Process Name"
Write-Host "Message.Processname:" $PN1
Write-Host "Message.ProcessID: Process PID"
Write-Host "Statistic.ProcessPID:" $PID1
Write-Host "Message.WorkingSet: Working Set"
Write-Host "Statistic.WorkingSet:" $PWS1
#Write-Host " "
Write-Host "Message.ProcessName: Process Name"
Write-Host "Message.Processname:" $PN2
Write-Host "Message.ProcessID: Process PID"
Write-Host "Statistic.ProcessPID:" $PID2
Write-Host "Message.WorkingSet: Working Set"
Write-Host "Statistic.WorkingSet:" $PWS2
From my PowerShell editor, I get this output:
Message.ProcessName: Process Name
Message.Processname: TSAgent2
Message.ProcessID: Process PID
Statistic.ProcessPID: 10832
Message.WorkingSet: Working Set
Statistic.WorkingSet: 686309376
Message.ProcessName: Process Name
Message.Processname: TSAgent2#6
Message.ProcessID: Process PID
Statistic.ProcessPID: 16808
Message.WorkingSet: Working Set
Statistic.WorkingSet: 508747776
But from my Orion editor, I get this:
{"Message":"The request channel timed out while waiting for a reply after 00:00:59.9843804. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.","StackTrace":" at SolarWinds.APM.Common.BusinessLayerFactory.BusinessLayerExceptionHandler(Exception ex)\r\n at SolarWinds.APM.Common.APMBusinessLayerProxy.CallProbes(ComponentBase cmp, ApplicationSettings settings, IList`1 nodeIds, CredentialSet credential, LogSettings customLogSettings)\r\n at SolarWinds.APM.Web.ComponentTestResult.StartTest(ComponentBase cmp, ApplicationSettings appSettings, CredentialSet crs, LogSettings customLogSettings)\r\n at Edit.StartDefineSettings(ComponentBaseEditModel editModel, TestSettingsModel settings)","ExceptionType":"SolarWinds.APM.Common.ApmBusinessLayerException"}
Anyone have any suggestions? Can anyone offer some help?