PRO Deteriorating Virtual Server(2) Health

Citrix.NetScaler.NetscalerDevice.Deteriorating.Virtual.Server.Health.Pro.Monitor2 (UnitMonitor)

Knowledge Base article:

Summary

The load balanced application's virtual server health has dropped below the configured threshold.

Causes

One or more of the Web or Application servers attached to the virtual server may have failed.

Resolutions

Click Implement to dynamically provision new server virtual machines that will be attached to the load balanced virtual server, to improve the overall health of the application. Or, click Dismiss and resolve the state of the failed servers.

Element properties:

TargetCitrix.NeScaler.VirtualServer.Health.PRO.VMMServer
Parent MonitorSystem.Health.PerformanceState
CategoryCustom
EnabledFalse
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeCitrix.NetScaler.TimedScript.TwoStateMonitorType
RemotableTrue
AccessibilityPublic
Alert Message
PRO Deteriorating Virtual Server(2) Health
Source NetScaler Device: {0} and VirtualServerName: {1}
RunAsDefault

Source Code:

<UnitMonitor ID="Citrix.NetScaler.NetscalerDevice.Deteriorating.Virtual.Server.Health.Pro.Monitor2" Accessibility="Public" Enabled="false" Target="Citrix.NeScaler.VirtualServer.Health.PRO.VMMServer" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Citrix.NetScaler.TimedScript.TwoStateMonitorType" ConfirmDelivery="false">
<Category>Custom</Category>
<AlertSettings AlertMessage="Citrix.NetScaler.NetscalerDevice.Deteriorating.Virtual.Server.Health.Pro.Monitor2_AlertMessageResourceID">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Warning</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="CitrixNSPRO!Citrix.NeScaler.PRO.VMMServer"]/IPAddress$</AlertParameter1>
<AlertParameter2>$Data/Context/Property[@Name='VirtualServerName']$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Citrix.NetScaler.NetscalerDevice.Deteriorating.Virtual.Server.Health.Pro.Monitor1.HealthState.Healthy" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Citrix.NetScaler.NetscalerDevice.Deteriorating.Virtual.Server.Health.Pro.Monitor1.HealthState.Unhealthy" MonitorTypeStateID="Error" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>300</IntervalSeconds>
<ScriptName>WebServerHealthPRO.PS1</ScriptName>
<Arguments>$Target/Property[Type="CitrixNSPRO!Citrix.NeScaler.PRO.VMMServer"]/IPAddress$</Arguments>
<ScriptBody><Script>
$TargetComputer = $Args[0];
$NetScalerIPAddress = $Args[1];
$NetScalerUserID = $Args[2];
$NetScalerPassword = $Args[3];
$VirtualServerName = $Args[4];
$Threshold = $Args[5];
$WebServerHttp = "http://";

function Log-Event ($EventType, $EventID, $Description)
{
eventcreate /T $EventType /ID $EventID /L APPLICATION /SO CitrixNSPRO /D $Description;
}


function Load-NetScalerAPIDLL ()
{

$NetScalerStatAPIDLL = $env:ProgramFiles + '\Citrix\NetScaler\SystemCenter\Scripts\NSStat.dll';

$Error.Clear();
$LoadAPIDLL = [Reflection.Assembly]::LoadFile($NetScalerStatAPIDLL);
if ($Error.Count -ne 0)
{
Log-Event Error 4 'WebServerHealth Monitor: NetScaler Stat API DLL load failed.';
return -1;
}
return 0;
}


function Get-LbvserverHealth()
{

$client = new-object NetScaler.API.NSStatServiceEx(($WebServerHttp + $TargetComputer),$NetScalerUserID,$NetScalerPassword);

if(!$client)
{
Log-Event Error 5 'WebServerHealth Monitor: NetScaler client login failed.';
return -1;
}

$loginResult = $client.Login();

if( $loginResult.rc -ne 0)
{
Log-Event Error 5 'WebServerHealth Monitor: NetScaler client login failed.';
return -1;
}

$statlbvserverResult = $client.statlbvserver($VirtualServerName);

if ($statlbvserverResult.rc -ne 0)
{
Log-Event Error 7 'WebServerHealth Monitor: NetScaler Stat Service statlbvserver API failed.';
return -1;
}

$logoutReturn = $client.Logout();

return $statlbvserverResult.list[0].vslbhealth;
}


function Validate-ScriptArguments ()
{

if ($NetScalerIPAddress -ine $TargetComputer)
{
return -1;
}

if (!$NetScalerIPAddress)
{
Log-Event Warning 8 'WebServerHealth Monitor Override: NetScalerIPAddress is empty.';
return -1;
}

if (!$VirtualServerName)
{
Log-Event Warning 9 'WebServerHealth Monitor Override: VirtualServerName is empty.';
return -1;
}

if ($Threshold -le 0)
{
Log-Event Warning 10 'WebServerHealth Monitor Override: Threshold is less than or equal to zero.';
return -1;
}

if (!$NetScalerUserID)
{
Log-Event Warning 11 'WebServerHealth Monitor : NetScaler Authentication Profile not attached to valid RunAS Account.';
return -1;
}

if (!$NetScalerPassword)
{
Log-Event Warning 11 'WebServerHealth Monitor : NetScaler Authentication Profile not attached to valid RunAS Account.';

return -1;
}

return 0;
}


function Main
{
$oAPI = new-object -comobject MOM.ScriptAPI;

$oBag = $oAPI.CreateTypedPropertyBag(3);

$ValidateArgumentResult = Validate-ScriptArguments;

if ($ValidateArgumentResult -lt 0)
{
$oBag.AddValue("State","Unknown");
$oAPI.Return($oBag);
return;
}

$LoadAPIDLLResult = Load-NetScalerAPIDLL;

if ($LoadAPIDLLResult -lt 0)
{
$oBag.AddValue("State","Unknown");
$oAPI.Return($oBag);
return;
}

$VServerHealth = Get-LbvserverHealth;

if ($VServerHealth -lt 0)
{

$oBag.AddValue("State","Unknown");
$oAPI.Return($oBag);
return;
}

$oBag.AddValue("NetScalerSource", $TargetComputer);
$oBag.AddValue("VirtualServerName", $VirtualServerName);
$oBag.AddValue("Health", $VServerHealth);

if ($VServerHealth -lt $Threshold)
{
$oBag.AddValue("State","Unhealthy");
}
else
{
$oBag.AddValue("State","Healthy");
}

$oAPI.Return($oBag);
} Main;</Script></ScriptBody>
<TimeoutSeconds>600</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Unhealthy</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='State']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Healthy</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
<NetScalerIPAddress/>
<UserID>$RunAs[Name="CitrixNSPRO!Citrix.NetScaler.PRO.NS.PrivilegedAccount"]/UserName$</UserID>
<Password>$RunAs[Name="CitrixNSPRO!Citrix.NetScaler.PRO.NS.PrivilegedAccount"]/Password$</Password>
<VirtualServerName/>
<Threshold>50</Threshold>
</Configuration>
</UnitMonitor>