S2D 2016: Fonte de Dados de Eventos de Alertas WMI de Falhas

Microsoft.Windows.Server.10.0.Storage.StorageSpacesDirect.FaultWmiAlertEventDataSource (DataSourceModuleType)

Fonte de dados de eventos de alertas WMI de falhas.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsSystem.PrivilegedMonitoringAccount
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
WmiEventProviderDS DataSource Microsoft.Windows.WmiEventProvider Default
PA ProbeAction Microsoft.Windows.PowerShellPropertyBagProbe Default
CD ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
PollIntervalint$Config/PollInterval$Intervalo de Sondagem (s)Intervalo de sondagem de consulta de eventos WMI.
TimeoutSecondsint$Config/TimeoutSeconds$Tempo Limite (s)

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.Server.10.0.Storage.StorageSpacesDirect.FaultWmiAlertEventDataSource" Accessibility="Internal" RunAs="System!System.PrivilegedMonitoringAccount" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InstanceType" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetInstanceUniqueID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetInstanceObjectID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PollInterval" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="WQLQuery" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetId" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="PollInterval" Selector="$Config/PollInterval$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="WmiEventProviderDS" TypeID="Windows!Microsoft.Windows.WmiEventProvider">
<NameSpace>\\$Config/ComputerName$\root\Microsoft\Windows\Storage</NameSpace>
<Query>$Config/WQLQuery$</Query>
<PollInterval>$Config/PollInterval$</PollInterval>
</DataSource>
<ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>GetFaultsScript.ps1</ScriptName>
<ScriptBody><Script>
Param($InstanceType, $SourceUniqueId, $SourceObjectId, $TargetId)
$SCRIPT_NAME = "GetFaultsScript.ps1"
#Storage Monitoring Event Ids
$GenericInformationEvent = 8671;
$GenericFailureEvent = 8672;
$CredentialNullCode = 8702;

$errorActionPreference = 'Stop'
$ITEM_DATA_TYPE = "Item"
$LIST_DATA_TYPE = "List"

$momAPI = New-Object -comObject 'MOM.ScriptAPI'

$errEvent = [System.Diagnostics.EventLogEntryType]::Error;
$infoEvent = [System.Diagnostics.EventLogEntryType]::Information;
$warningEvent = [System.Diagnostics.EventLogEntryType]::Warning;

$script:traceMsg = "";

#Adds tracemessage to $Script
Function AddTraceMessage
{
param($message)
$timeStamp = (get-date -format "HH:mm:ss:fff");
$script:traceMsg = $script:traceMsg + "`n[" + $timeStamp + "] " + $message;
}

#instanceType
#SSS - StorageSubSystem
#V - Volume
#FS - FileShare
Function Get-Faults
{
param($instanceType, $UniqueID)
Set-Variable -Name "f"
switch ($instanceType)
{
"SSS" {$f = Get-StorageSubSystem -UniqueID $UniqueID | Debug-StorageSubSystem}
"V" {$f = Get-Volume -UniqueID $UniqueID | Debug-Volume}
"FS" {$f = Get-FileShare -UniqueID $UniqueID | Debug-FileShare}
default {Throw [System.NotSupportedException ] "Type of storage instance is not supported";}
}
return $f;
}

Try
{
$error.Clear()
AddTraceMessage -message "Storage monitoring script $SCRIPT_NAME started."
AddTraceMessage -message "InstanceType = $InstanceType."
AddTraceMessage -message "SourceUniqueId = $SourceUniqueId."
AddTraceMessage -message "TargetId = $TargetId."

$stringIdList = @()
$faults = @(Get-Faults -instanceType $InstanceType -UniqueID $SourceUniqueId)
if(($faults -ne $null) -and ($faults.Count -ge 0))
{
foreach($fault in $faults)
{
$faultId = $fault.FaultId;

$propertyBag = $momAPI.CreatePropertyBag()
$propertyBag.AddValue("FaultId", $fault.FaultId);
$propertyBag.AddValue("FaultingObjectDescription", $fault.FaultingObjectDescription);

$propertyBag.AddValue("Reason", $fault.Reason);
$propertyBag.AddValue("RecommendedActions", $fault.RecommendedActions -join "`n");
#$propertyBag.AddValue("CompositeAlertId", $faultId + ":" + $SourceUniqueId);
$propertyBag.AddValue("CompositeAlertId", $faultId + ":" + $SourceObjectId);
$propertyBag.AddValue("SourceUniqueId", $SourceUniqueId);
$propertyBag.AddValue("SourceObjectId", $SourceObjectId);
$propertyBag.AddValue("TargetId", $TargetId);
$propertyBag.AddValue("DataType", $ITEM_DATA_TYPE); #required in condition detection for generate/close alerts

$stringIdList += $fault.FaultId;

$alertSeverity = 1;
if($fault.PerceivedSeverity -eq 2)
{
$alertSeverity = 0 #Information
}
elseif(($fault.PerceivedSeverity -eq 3) -or ($fault.PerceivedSeverity -eq 4))
{
$alertSeverity = 1 #Warning
}
elseif(($fault.PerceivedSeverity -ge 5))
{
$alertSeverity = 2 #Warning
}
$propertyBag.AddValue("Severity", $alertSeverity);

AddTraceMessage -message "fault $faultId has been proccessed"
$propertyBag
}


}
else
{
AddTraceMessage -message "faults were not found"
}
$propertyBag = $momAPI.CreatePropertyBag()
$joinedIdList = $stringIdList -join ','
$propertyBag.AddValue("FaultId", $joinedIdList);
$propertyBag.AddValue("SourceUniqueId", $SourceUniqueId);
$propertyBag.AddValue("SourceObjectId", $SourceObjectId);
$propertyBag.AddValue("TargetId", $TargetId);
$propertyBag.AddValue("DataType", $LIST_DATA_TYPE); #required in condition detection for generate/close alerts
AddTraceMessage -message "joined id list $joinedIdList"
$propertyBag

}
Catch
{
AddTraceMessage -message $_.Exception.Message
}
finally
{
if ($error -ne $null -and $error.Count -gt 0 -and $error[0] -ne $null)
{
$momAPI.LogScriptEvent($SCRIPT_NAME, $GenericFailureEvent, 1, $error[0].ToString());
}

if ($script:traceMsg -ne $null)
{
$momAPI.LogScriptEvent($SCRIPT_NAME, $GenericInformationEvent, 0, $script:traceMsg);
}
}</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>InstanceType</Name>
<Value>$Config/InstanceType$</Value>
</Parameter>
<Parameter>
<Name>SourceUniqueId</Name>
<Value>$Data/Property[@Name='SourceUniqueId']$</Value>
</Parameter>
<Parameter>
<Name>SourceObjectId</Name>
<Value>$Data/Property[@Name='SourceObjectId']$</Value>
</Parameter>
<Parameter>
<Name>TargetId</Name>
<Value>$Config/TargetId$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</ProbeAction>
<ConditionDetection ID="CD" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='SourceUniqueId']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>$Config/TargetInstanceUniqueID$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<Composition>
<Node ID="CD">
<Node ID="PA">
<Node ID="WmiEventProviderDS"/>
</Node>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>