Tipo de monitor de unidad VMMServer accesible mediante Powershell 2.0 de System Center 2012 Virtual Machine Manager
Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerReachableUnitMonitorType (UnitMonitorType)
Este tipo de monitor se usa para detectar si la comunicación remota de PowerShell 2.0 está habilitada y disponible en el servidor de administración 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>
</Parameters>
<ScriptBody><Script>
param($VMMServer)
$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();
$domain = "$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/Domain$";
$username = "$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/UserName$";
$pass = "$RunAs[Name="PROV2Library!Microsoft.SystemCenter.VirtualMachineManager.2012.VMMServerConnectionRunAsProfile"]/Password$";
$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\psModulePath\virtualmachinemanagercore\virtualmachinemanagercore.psd1"); Get-SCVMMServer -ComputerName $args[0] } ;
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')
}
}
Remove-PSSession $session;
}
}
else
{
$pBag.AddValue('VMMServer Connection', 'NotReachable')
}
$pBag
</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>