<form class=“ipsForm ipsForm_vertical” accept-charset=“utf-8” action=“Citrix Secure Sign In” enctype=“multipart/form-data” method=“post” data-action=“add” data-controller=“citrix.front.topic.createtopicform” data-swapid=“ctx-forums-topic-form” data-ipsform=“”>
Hi there…I am trying to monitor few process . I have a PowerShell script mentioned below, but trying to update the output to get high CPU usage (over 25% threshold) for processes for certain time period (over 15 minutes). Is there a way to monitor processes for certain that time period and send email alert if it stays for long period of time ? Pls advice me ?
[pre]
$Output = ‘C:\temp\Result.txt’
$ServerList = Get-Content ‘C:\temp\Servername.txt’
$ScriptBLock = {
$CPUPercent = @{
Label = ‘CPUUsed’
Expression = {
$SecsUsed = (New-Timespan -Start $.StartTime).TotalSeconds
[Math]::Round($.CPU * 10 / $SecsUsed)
}
}
$MemUsage = @{
Label =‘RAM(MB)’
Expression = {
[Math]::Round(($_.WS / 1MB),2)
}
}
Get-Process | Select-Object -Property Name, CPU, $CPUPercent, $MemUsage,
Description |
Sort-Object -Property CPUUsed -Descending |
Select-Object -First 15 | Format-Table -AutoSize
}
foreach ($ServerNames in $ServerList) {
“CPU & Memory Usage in $serverNames” | Out-File $Output -Append
Invoke-Command -ScriptBlock $ScriptBLock -ComputerName $ServerNames |
Out-File $Output -Append
}
[/pre]