Friday, January 21, 2011

A powershell script which will report you the Loded Xenapp servers which are having more than 9000 load.

You can schedule the script on every one hour (as per your environment) useing Windows Scheduler.

"
Add-PSSnapin citrix.xenapp.commands
cls
$log_file="W:\MaxLoad.log"
Clear-Content $log_file

cls
$servers = Get-XAZone | Get-XAServer -OnlineOnly $test = Get-XAServerLoad $servers | where-object {$_.load -gt "9000"}
$a = @{Expression={$_.ServerName};Label="Server Name";width=15}, @{Expression={$_.Load};Label="Load";width=10}, @{Expression={$_.LoadEvaluatorName};Label="LOAD EVALUATOR NAME";width=40}


$test | Format-Table $a >> $log_file
if ($test -ne $null)
{
echo "Sending email"
$smtpServer = "SMTP Server Address"
$msg = new-object Net.Mail.MailMessage
$msg.isBodyhtml = $true
$msg.Priority = [System.Net.Mail.MailPriority]::High
$att = new-object Net.Mail.Attachment($log_file)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "From Address"
$msg.To.Add("To address")
$msg.Subject = "Server(s) Load Reached 9000"
$msg.Body = "List of server(s) that reached the load greater than 9000."
#$msg.Body = Get-Content $log_file
$msg.Attachments.Add($att)
$smtp.Send($msg)
$att.Dispose()
}
"

No comments:

Post a Comment