With Director 7.7, you have the capability of configuring policies and conditions that will alert you when the configured threshold is breached in a XenDesktop 7.7 environment. This post will help you configure your proactive alerts and notifications using the POSH cmdlets.

Configuring the Notification Subscription

Let’s assume that you are a XenDesktop admin and you are trying to understand the usage of your XenDesktop deployment. You need to be proactively alerted when the number of concurrent sessions crosses a threshold value.

Before you even get to configuring alerts and notifications, you need to configure your notification subscription. For this you first need to add an SMTP exchange server which can be later used to send emails  when there is an alert.

The Set-MonitorNotificationEmailServerConfiguration POSH cmdlet will help you in configuring the SMTP server.

Here is a sample script that can help you get it done.

asnp Citrix.Monitor.*

PS C:\Users\administrator.BANDIT> Set-MonitorNotificationEmailServerConfiguration -ProtocolType SMTP -ServerName NameOfTheSMTPServerOrIPAddress -PortNumber PortNumber -SenderEmailAddress EmailAddressFromWhichDirectorShouldSendAnEmailWhenThereIsAnAlert -RequiresAuthentication 0
ProtocolType : SMTP
ServerName : NameOfTheSMTPServerOrIPAddress
PortNumber : PortNumber 
SenderEmailAddress : EmailAddressFromWhichDirectorShouldSendAnEmailWhenThereIsAnAlert
RequiresAuthentication : False
Credential :

PS C:\Users\administrator.BANDIT> Set-MonitorNotificationEmailServerConfiguration -ProtocolType SMTP -ServerName NameOfTheSMTPServerOrIPAddress -PortNumber PortNumber -SenderEmailAddress EmailAddressFromWhichDirectorShouldSendAnEmailWhenThereIsAnAlert -RequiresAuthentication 1 -Credential “SenderEmailAddressUserNameAsPerYourExchangeServerOrAD
ProtocolType : SMTP
ServerName : NameOfTheSMTPServerOrIPAddress
PortNumber : PortNumber 
SenderEmailAddress : EmailAddressFromWhichDirectorShouldSendAnEmailWhenThereIsAnAlert
RequiresAuthentication : False
Credential : System.Management.Automation.PSCredential

In case your SMTP server does not require authentication, you can set the

-RequiresAuthentication flag to false.

PS C:\Users\administrator.BANDIT> Set-MonitorNotificationEmailServerConfiguration -ProtocolType SMTP -ServerName NameOfTheSMTPServerOrIPAddress -PortNumber PortNumber -SenderEmailAddress EmailAddressFromWhichDirectorShouldSendAnEmailWhenThereIsAnAlert -RequiresAuthentication 0
ProtocolType : SMTP
ServerName : NameOfTheSMTPServerOrIPAddress
PortNumber : PortNumber 
SenderEmailAddress : EmailAddressFromWhichDirectorShouldSendAnEmailWhenThereIsAnAlert
RequiresAuthentication : False
Credential :

Director also supports multiple protocols to connect with your SMTP server. They include SMTP, SMTP-SSL and SMTP-TSL

Note: Please do not configure more than one SMTP server.

Note: You cannot remove a SMTP configuration but what you can do is edit it and change its value.

A sample script

Here is a sample script that will help us in creating a policy with an alert rule, parameters, conditions and email recipients. We will break each part of the script to understand more about it.

asnp Citrix.Monitor.*

# Add Parameters

$timeSpan = New-TimeSpan -Seconds 30

$alertThreshold = 1

$alarmThreshold = 2

# Add Target UID’s

$targetIds = @()

$targetIds += “0e406be1-1647-4a97-845c-7601ae1d8883”

# Add email addresses

$emailaddress = @()

$emailaddress += “batman@gotham.com”

# Create new policy

$policy = New-MonitorNotificationPolicy -Name “MyTestPolicy” -Description “Policy created to test new cmdlets” -Enabled $true

Add-MonitorNotificationPolicyCondition -Uid $policy.Uid -ConditionType SessionsConcurrentCount -AlertThreshold $alertThreshold -AlarmThreshold $alarmThreshold  -AlertRenotification $timeSpan -AlarmRenotification $timeSpan

Add-MonitorNotificationPolicyCondition -Uid $policy.Uid -ConditionType SessionsPeakconnectedCount -AlertThreshold $alertThreshold -AlarmThreshold $alarmThreshold -AlertRenotification $timeSpan -AlarmRenotification $timeSpan

Add-MonitorNotificationPolicyTargets -Uid $policy.Uid -Scope “My Test Targets” -TargetKind DesktopGroup -TargetIds $targetIds

Add-MonitorNotificationPolicyEmailAddresses -Uid $policy.Uid -EmailAddresses $emailaddress -EmailCultureName “en-US”

$policy = Get-MonitorNotificationPolicy -Uid $policy.Uid

$policy

Configuring recipient email addresses

Since you are done configuring the SMTP exchange server, you now need to configure the recipients of the email.

Using the Add-MonitorNotificationPolicyEmailAddresses  cmdlet you can specify the recipients of the email notification and choose the locale too.

$emailaddress = @()

$emailaddress += “batman@gotham.com”

Add-MonitorNotificationPolicyEmailAddresses -Uid $policy.Uid -EmailAddresses $emailaddress -EmailCultureName “en-US”

Configuring targets and target values

Since you are done creating a notification subscription in the previous step, let’s focus on creating a policy. The first thing that we need to do is specify a target. A target is nothing but the entity on which the alert rule will be applied on. For e.g.:- If my rule is “Alert me when the Peak Connected Session hits 100 on all the machines in my delivery group xyz”; then here delivery group xyz is the target.

To specify a target and target value, you have to use the cmdlet:

Add-MonitorNotificationPolicyTargets

Let’s suppose that you want to set the session concurrent alert on a delivery group for RDS machines. You will have to get the DG unique identifier and supply it as a value to the Add-MonitorNotificationPolicyTargets cmdlet.

How can you get it?

Use the get-brokerDesktopGroup cmdlet and you will find the unique identifier under UUID

So now we have set the target value of the delivery group on which we want to target our alert rule.

Next, we have to specify the target and target type. Here, we can use the Add-MonitorNotificationPolicyTargets and specify the target type as “RDSWorker”

$targetIds = @()

$targetIds += “0e406be1-1647-4a97-845c-7601ae1d8883”

Add-MonitorNotificationPolicyTargets -Uid $policy.Uid -Scope “My Test Targets” -TargetKind DesktopGroup -TargetIds $targetIds

We can specify the target type as RDSWorker, or a SITE or a DesktopGroup.

In general, alert policies can be targeted at three different scopes.

  1. Site – Will apply to all the machines in the entire site and the alert threshold will be applied on the aggregate value of all the machines included.
  2. Desktop Group – Will apply to all the machines in the entire delivery group and the alert threshold will be applied on the aggregate value of all the machines included.
  3. RDS Worker – Will apply to all the machines in the delivery group but the alert threshold value will be applied to individual machines.

Configuring conditions and parameters

Now you are done selecting a target. We earlier wanted to set a alert rule policy for session concurrent policy. Similar to session concurrent condition there are other conditions for which policies can be set.

Alert Type Condition checked
Peak Connected Sessions Detected when an instantaneous (one minute samples) number of peak connected sessions for  the entire site of a particular delivery group exceeds a configured count threshold.
Peak Disconnect Sessions Detected when an instantaneous (one minute samples) number of peak disconnected sessions for the entire site of a particular delivery group exceeds a configured count threshold.
Peak Concurrent Sessions Detected when an instantaneous (one minute samples) number of peak concurrent (total) sessions for the entire site of a particular delivery group exceeds a configured count threshold.
Connection Failure Count Detected when the number of connections in a configurable time period fail across the entire site of a particular delivery group exceeds a configured count threshold.
Connection Failure Rate Detected when the ratio of connection failures to connection attempts in a configurable time period across the entire site of a particular delivery group exceeds a configured percentage threshold.
Failed Desktop OS Machines Detected when an instantaneous (one minute samples) number of desktop OS machines in a failure state for the entire site of a particular delivery group exceeds a configured count threshold.
Failed Server OS Machines Detected when an instantaneous (one minute samples) number of Server OS machines in a failure state for the entire site of a particular delivery group exceeds a configured count threshold.
Average Logon Duration Detected when the average session logon time in a configurable time period across the entire

site or for a particular delivery group execeeds a configured duration threshold.

RDS Load Evaluator Index Detected when a configured load index value is sustained for 5 minutes

Now we need to define the conditions and parameters for the policy.

Using the Add-MonitorNotificationPolicyCondition we can add the alarm threshold, alert threshold, the alert re-notification time, the alarm re-notification time and the period.

Add-MonitorNotificationPolicyCondition -Uid $policy.Uid -ConditionType SessionsConcurrentCount -AlertThreshold $alertThreshold -AlarmThreshold $alarmThreshold  -AlertRenotification $timeSpan -AlarmRenotification $timeSpan

  • AlertThreshold – Threshold value at which the warning notification will be triggered
  • AlarmThreshold – Threshold value at which the critical notification will be triggered
  • AlertRenotification – Duration after which the warning notification will be re-triggered
  • AlarmRenotification – Duration after which the critical notification will be re-triggered
  • Period – Window in which the alert threshold condition, warning or critical, is checked

The New-MonitorNotificationPolicy cmdlet will help you in creating a new policy.

Now you are all set to go!

That’s all folks!

All of this will help you create a new policy, set parameters for conditions, manage policy and alerts and most importantly monitor your  deployment effectively.