AKN569757

Monitor_AKN569757 (UnitMonitor)

Front End Server memory size is below recommended values

Knowledge Base article:

External

http://go.microsoft.com/fwlink/?LinkId=322021

Element properties:

TargetMicrosoft.KnowledgeServices.Lync.2010.CsServer
Parent MonitorSystem.Health.ConfigurationState
CategoryAlert
EnabledTrue
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.KnowledgeServices.Library.PowerShellMonitorEx
RemotableTrue
AccessibilityPublic
Alert Message
Lync2013: Lync Front End Server memory size below recommended values
<Details>
<Content>Advisor has detected that this Front End server memory size is below recommended published values. If you use less powerful server resources, you may experience functionality problems or poor performance. Note that these hardware requirements are higher than those of previous versions of Lync Server, primarily because in Lync Server 2013, all Front End Servers run SQL Server. Please see following KB articles for more information.</Content>
<CollectedInformation>
<Info>
<Name>Total Memory(GB)</Name>
<Value>{0}</Value>
</Info>
</CollectedInformation>
</Details>
RunAsDefault
CommentSupportTopic=TBD;VersionNumber=1.0.0.0;

Source Code:

<UnitMonitor ID="Monitor_AKN569757" Comment="SupportTopic=TBD;VersionNumber=1.0.0.0;" Accessibility="Public" Enabled="true" Target="MicrosoftKnowledgeServicesLyncLibrary!Microsoft.KnowledgeServices.Lync.2010.CsServer" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="KnowledgeServicesLibrary!Microsoft.KnowledgeServices.Library.PowerShellMonitorEx" ConfirmDelivery="true">
<Category>Alert</Category>
<AlertSettings AlertMessage="MonitorMessagefec9b20675944abdaf0cb2b71a14ac18">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='TotalMemory']$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>AKN569757.ps1</ScriptName>
<Parameters/>
<ScriptBody><Script>
[ScriptBlock]$mainScriptBlock = {

$ErrorActionPreference = "Stop"

# Set up the arguments
$scriptargs = new-object psobject

# Set up the output
$global:scriptoutput = new-object psobject
$scriptoutput | add-member NoteProperty "HasIssue" $false
$scriptoutput | add-member NoteProperty "TotalMemory" ""
#-----------------------------------------------------
# Environment
#-----------------------------------------------------
$script:lyncPath = ""
if (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPath = Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1"
$script:lyncPSVer = 2013
}
elseif (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPath = Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1"
$script:lyncPSVer = 2010
}
$ScriptEnv = New-Object psobject
$ScriptEnv | Add-Member NoteProperty "RuntimeError" $false
$ScriptEnv | Add-Member NoteProperty "HasIssue" $false
$ScriptEnv | add-member ScriptMethod "ImportLyncPSModule" -value {
$m = Get-Module -Name Lync
if ($m -eq $null)
{
Import-Module $script:lyncPath -ErrorAction:SilentlyContinue
}
}
$ScriptEnv | Add-Member ScriptMethod "IsCMSMaster" -Value {
Try
{
$cmsStatus = Get-CsManagementStoreReplicationStatus -CentralManagementStoreStatus
$agentHostFqdn = [System.Net.Dns]::GetHostByName([System.Net.Dns]::GetHostName()).HostName
return $cmsStatus.ActiveMasterFqdn -ieq $agentHostFqdn
}
Catch [Microsoft.Rtc.Management.ADConnect.CannotGetDomainInfoException]
{
}
Catch [Microsoft.Rtc.Common.Data.SqlConnectionException]
{
}
Catch [System.Data.SqlClient.SqlException]
{
}
return $false
}

#-----------------------------------------------------
# MAIN CODE SECTION
#-----------------------------------------------------
$scriptenv | Add-Member NoteProperty "TotalMemory" ""

function IsFrontEndServer()
{
$result = $false
$edgeServices = @(Get-Service | Where-Object { $_.DisplayName -like "*edge*" })
if($edgeServices.Count -eq 0)
{
$agentHostFqdn = [System.Net.Dns]::GetHostByName([System.Net.Dns]::GetHostName()).HostName
$fes = @(Get-CsService -UserServer)
$pools = @(Get-CsPool)
foreach($pool in $pools)
{
$fePool = $fes | Where-Object { $_.PoolFqdn -ieq $pool.Identity }
if($fePool -ine $null)
{
if($pool.Computers -contains $agentHostFqdn)
{
$result = $true
break
}
}
}
}
return $result
}

function TestTotalMemory()
{
$os = Get-WmiObject -Class Win32_ComputerSystem
$memory = [Math]::Round($os.TotalPhysicalMemory/1GB)
$memory = [int]$memory
if($memory -lt 32)
{
[string]$mem += $memory.ToString()
$scriptenv.TotalMemory = $mem
$scriptenv.HasIssue = $true
}
}

# Main Function
function AdvisorRule($scriptargs, $scriptoutput)
{
trap [Exception]
{
$scriptenv.RuntimeError = $true
continue
}

if (($script:lyncPath -ne "") -and ($script:lyncPSVer -eq 2013))
{
$scriptenv.ImportLyncPSModule()

$scriptoutput.HasIssue = $false

if((IsFrontEndServer))
{
TestTotalMemory
}

if($scriptenv.HasIssue -eq $true -and $scriptenv.RuntimeError -eq $false)
{
$scriptoutput.HasIssue = $true
$scriptoutput.TotalMemory = $scriptenv.TotalMemory
}
}
}

AdvisorRule $scriptargs $scriptoutput

}

Function Test-NeedPSRemoting
{
$script:lyncPSVer = 0
if (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2013\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPSVer = 2013
}
elseif (Join-Path $Env:CommonProgramFiles "\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1" | Test-Path)
{
$script:lyncPSVer = 2010
}
$PSCLRVersion = [System.String]::Format("{0}.{1}", $PSVersionTable.CLRVersion.Major, $PSVersionTable.CLRVersion.Minor)
if (($PSCLRVersion -ieq "2.0") -and ($script:lyncPSVer -ieq 2013))
{
return $true
}
return $false
}

if ((Test-NeedPSRemoting))
{
[bool]$script:psRemotingEnabled = $false
# Enable PowerShell Remoting need elevated BUILTIN\Administrators privilege
$winRMService = (Get-Service WinRM -ErrorAction SilentlyContinue)
if ($winRMService -ne $null)
{
if ($winRMService.Status -ieq [System.ServiceProcess.ServiceControllerStatus]::Stopped)
{
$winRMService.Start()
$winRMService.WaitForStatus([System.ServiceProcess.ServiceControllerStatus]::Running, [System.TimeSpan]::FromSeconds(15))
}
$psSessionConfiguration = (Get-PSSessionConfiguration -Name "Microsoft.PowerShell" -ErrorAction SilentlyContinue)
if ($psSessionConfiguration.Permission.Contains("BUILTIN\Administrators AccessAllowed"))
{
$script:psRemotingEnabled = $true
}
}

# Call remote PS session when PSRemoting is enabled.
if ($script:psRemotingEnabled -eq $true)
{
$session = New-PSSession
Invoke-Command -Session $session -ScriptBlock $mainScriptBlock
$global:scriptoutput = Invoke-Command -Session $session -ScriptBlock {$global:scriptoutput}
Remove-PSSession -Session $session
}
}
else
{
&amp; $mainScriptBlock
}

# set the output
$mom = new-object -comobject "MOM.ScriptAPI"
$bag = $mom.CreatePropertyBag()

if ($scriptoutput.HasIssue -ne $null)
{
$bag.AddValue("HasIssue", $scriptoutput.HasIssue)
}

if ($scriptoutput.TotalMemory -ne $null)
{
$bag.AddValue("TotalMemory", $scriptoutput.TotalMemory)
}

$bag

</Script></ScriptBody>
<SnapIns/>
<TimeoutSeconds>300</TimeoutSeconds>
<Schedule>14400</Schedule>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<Not>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='HasIssue']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</Not>
</SuccessExpression>
</Configuration>
</UnitMonitor>