I recently wrote the following blog post:
Monitoring Microsoft Exchange Server 2010, 2013 and 2016 services with PowerShell script and task scheduler
http://terenceluk.blogspot.com/2018/03/monitoring-microsoft-exchange-server.html
… demonstrating how to use a script to check for hung or stopped services for Exchange and to restart and send an email notification as a reaction to these events. A few people have reached out to me about using this for Citrix XenApp / XenDesktop environments and the short answer to the question is yes, you can indeed use this script because it universally monitors Windows services.
The following is the modified script that includes the Citrix XenDesktop / XenApp 7.17 Delivery Controller services:
#NAME: service_check.ps1
#AUTHOR: Kevin Olson
#DATE: 4/29/2011
#Machine to be monitored
$Computer = "citrixServer"
#Create an array of all services running
$GetService = get-service -ComputerName $Computer
#Create a subset of the previous array for services you want to monitor
$ServiceArray = "CitrixADIdentityService","CitrixAnalytics","CitrixAppLibrary","CitrixBrokerService","CitrixConfigSyncService","CitrixConfigurationLogging","CitrixConfigurationService","CitrixConnector","CitrixDelegatedAdmin","CitrixEnvTest","CitrixHighAvailabilityService","CitrixHostService","CitrixMachineCreationService","CitrixMonitor","CitrixOrchestration","CitrixPrivilegedService","CitrixStorefront","CitrixTelemetryService","CitrixTrust","XaXdCloudProxy";
#Find any iWFM service that is stopped
foreach ($Service in $GetService)
{
foreach ($srv in $ServiceArray)
{
if ($Service.name -eq $srv)
{
#check if a service is hung
if ($Service.status -eq "StopPending")
{
$servicePID = (gwmi win32_Service | where { $_.Name -eq $srv}).ProcessID
Stop-Process $ServicePID
Start-Service -InputObject (get-Service -ComputerName $Computer -Name $srv)
#email to notify if a service is down
Send-Mailmessage -to administrator@someDomain.com -Subject "$srv is hung on $Computer" -from exchange@contoso.com -Body "The $srv service was found hung." -SmtpServer localhost
}
# check if a service is stopped
elseif ($Service.status -eq "Stopped")
{
#automatically restart the service.
Start-Service -InputObject (get-Service -ComputerName $Computer -Name $srv)
#email to notify if a service is down
Send-Mailmessage -to administrator@someDomain.com -Subject "$srv is stopped on $Computer" -from exchange@contoso.com -Body "The $srv service was found stopped." -SmtpServer localhost
}
}
}
}
As the list of services change through the versions of XenDesktop / XenApp, I am including the following screenshot of the services for version 7.17:
No comments:
Post a Comment