Tipo di monitoraggio unità VMMServer raggiungibile tramite PowerShell 2.0 per System Center 2012 Virtual Machine Manager
Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerReachableUnitMonitorType (UnitMonitorType)
Questo tipo di monitoraggio consente di rilevare se i servizi remoti di PowerShell 2.0 sono abilitati e disponibili sul server di gestione VMM
Element properties:
Member Modules:
Overrideable Parameters:
Source Code:
<UnitMonitorType ID="Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerReachableUnitMonitorType" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="VMMServerReachable" NoDetection="false"/>
<MonitorTypeState ID="VMMServerNotReachable" NoDetection="false"/>
</MonitorTypeStates>
<Configuration>
<xsd:element name="VMMServer" type="xsd:string"/>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="VMMServer" Selector="$Config/VMMServer$" ParameterType="string"/>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="Probe" TypeID="Microsoft.SystemCenter.VirtualMachineManager.2012.PowerShellProbeActionModuleType">
<Parameters>
<Parameter>
<Name>VMMServer</Name>
<Value>$Config/VMMServer$</Value>
</Parameter>
<Parameter>
<Name>domain</Name>
<Value>$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/Domain$</Value>
</Parameter>
<Parameter>
<Name>username</Name>
<Value>$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/UserName$</Value>
</Parameter>
<Parameter>
<Name>pass</Name>
<Value>$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/Password$</Value>
</Parameter>
</Parameters>
<ScriptBody><Script>
param($VMMServer, $domain, $username, $pass)
$session = $null;
Try
{
$oAPI = New-Object -comObject 'MOM.ScriptAPI'
$pBag = $oAPI.CreatePropertyBag()
$evt = New-Object System.Diagnostics.Eventlog("Application");
$evt.Source = "VMM.2012.ServerReachability";
$errorevent = [System.Diagnostics.EventLogEntryType]::Error;
$infoevent = [System.Diagnostics.EventLogEntryType]::Information;
$evt.WriteEntry("VMMServer Reachable Monitor VMMServer is:" + $VMMServer, $infoevent, 25931);
$error.Clear();
$cred = $null;
if ($domain -AND $username -AND $pass)
{
#Append domain to get domain\username
$domainUser = $domain + "\" + $username;
#Create Cred object
$securePass = ConvertTo-SecureString -AsPlainText $pass -force
$cred = New-Object System.Management.Automation.PSCredential $domainUser, $securePass;
}
# return VMMServerName for AlertMessage DisplayString
$pBag.AddValue('VMMServerName', $VMMServer)
####### Remote Session
if ($cred -ne $null)
{
$session = New-PSSession -ComputerName $VMMServer -Authentication Default -Credential $cred;
if ($error.Count -ne 0)
{
$evt.WriteEntry($error, $errorevent, 25931);
$pBag.AddValue('VMMServer Connection', 'NotReachable')
}
else
{
$vmm = $null;
$vmm = Invoke-Command -Session $session -ArgumentList $VMMServer -ScriptBlock {
$modulePath = get-itemproperty -path "hklm:\software\microsoft\microsoft system center virtual machine manager administrator console\Setup";
Import-Module ($modulePath.InstallPath + "bin\psModules\virtualmachinemanagercore\virtualmachinemanagercore.psd1");
$vmmServer = Get-SCVMMServer -ComputerName $args[0];
$vmmServer } ;
if ($error.Count -ne 0)
{
$evt.WriteEntry($error, $errorevent, 25932);
$pBag.AddValue('VMMServer Connection', 'NotReachable')
}
else
{
if ($vmm -ne $null)
{
$pBag.AddValue('VMMServer Connection', 'Reachable')
}
else
{
$pBag.AddValue('VMMServer Connection', 'NotReachable')
}
}
}
}
else
{
$pBag.AddValue('VMMServer Connection', 'NotReachable')
}
$pBag
}
Finally
{
if ($session -ne $null)
{
$vmm = Invoke-Command -Session $session -ScriptBlock {
if ($vmmServer -ne $null)
{
$vmmServer.Disconnect();
}
};
Remove-PSSession $session;
}
}
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="CDOnhealthy" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='VMMServer Connection']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Reachable</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CDOnCritical" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='VMMServer Connection']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">NotReachable</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="VMMServerReachable">
<Node ID="CDOnhealthy">
<Node ID="Probe">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="VMMServerNotReachable">
<Node ID="CDOnCritical">
<Node ID="Probe">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>