Módulo de origen de datos de espacio libre en los discos lógicos de Windows
Microsoft.Windows.Server.10.0.FreeSpace.Moduletype (DataSourceModuleType)
Supervisar el espacio libre en los discos lógicos de los servidores de Windows
Element properties:
Member Modules:
Overrideable Parameters:
Source Code:
<DataSourceModuleType ID="Microsoft.Windows.Server.10.0.FreeSpace.Moduletype" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="DiskLabel" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="SystemDriveWarningMBytesThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="SystemDriveWarningPercentThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="SystemDriveErrorMBytesThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="SystemDriveErrorPercentThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="NonSystemDriveWarningMBytesThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="NonSystemDriveWarningPercentThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="NonSystemDriveErrorMBytesThreshold" type="xsd:double"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="NonSystemDriveErrorPercentThreshold" type="xsd:double"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Interval" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="SystemDriveWarningMBytesThreshold" Selector="$Config/SystemDriveWarningMBytesThreshold$" ParameterType="double"/>
<OverrideableParameter ID="SystemDriveWarningPercentThreshold" Selector="$Config/SystemDriveWarningPercentThreshold$" ParameterType="double"/>
<OverrideableParameter ID="SystemDriveErrorMBytesThreshold" Selector="$Config/SystemDriveErrorMBytesThreshold$" ParameterType="double"/>
<OverrideableParameter ID="SystemDriveErrorPercentThreshold" Selector="$Config/SystemDriveErrorPercentThreshold$" ParameterType="double"/>
<OverrideableParameter ID="NonSystemDriveWarningMBytesThreshold" Selector="$Config/NonSystemDriveWarningMBytesThreshold$" ParameterType="double"/>
<OverrideableParameter ID="NonSystemDriveWarningPercentThreshold" Selector="$Config/NonSystemDriveWarningPercentThreshold$" ParameterType="double"/>
<OverrideableParameter ID="NonSystemDriveErrorMBytesThreshold" Selector="$Config/NonSystemDriveErrorMBytesThreshold$" ParameterType="double"/>
<OverrideableParameter ID="NonSystemDriveErrorPercentThreshold" Selector="$Config/NonSystemDriveErrorPercentThreshold$" ParameterType="double"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/IntervalSeconds$</Interval>
<SyncTime/>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="PA" TypeID="Microsoft.Windows.Server.10.0.PowerShellPropertyBagProbe">
<ScriptName>Microsoft.Windows.Server.FreeSpace.ps1</ScriptName>
<PSparam>param ($TargetComputer, $DebugFlag, $SysWarningMB, $SysWarningPct, $SysErrorMB, $SysErrorPct, $NonSysWarningMB, $NonSysWarningPct, $NonSysErrorMB, $NonSysErrorPct)</PSparam>
<ScriptBody><Script>
#Copyright (c) Microsoft Corporation. All rights reserved.
#
# Parameters that should be passed to this script
# 0 Computer (FQDN)
# 1 Debug Flag - If True then script can output some trace information to event log.
# 2 System Drive Warning MBytes Threshold
# 3 System Drive Warning Percent Threshold
# 4 System Drive Error MBytes Threshold
# 5 System Drive Error Percent Threshold
# 6 Non System Drive Warning MBytes Threshold
# 7 Non System Drive Warning Percent Threshold
# 8 Non System Drive Error MBytes Threshold
# 9 Non System Drive Error Percent Threshold
$BYTES_IN_MB = 1048576 #=2^20
$DriveHealthyState = 0
$DriveWarningState = 1
$DriveErrorState = 2
Function Main()
{
$g_DebugFlag = Convert-ToBoolean -sBool $DebugFlag
$bBagIsNotEmpty = $false
$IsNotEmpty = $false
$IsNano = Is_NanoServer
$IsVolumeInfoSupported = Is_Win32_Volume_Supported $TargetComputer
$SystemDrive = Get_System_Drive $TargetComputer
$oVolumes = Get-Volumes -IsNano $IsNano -IsVolumeSupported $IsVolumeInfoSupported -TargetComputer $TargetComputer
foreach ($oVolume in $oVolumes)
{
$VolumeId = Get-VolumeId -IsNano $IsNano -IsVolumeSupported $IsVolumeInfoSupported -Volume $oVolume
if ($true -eq $IsNano)
{
$nFreeSpace = $oVolume.SizeRemaining
$nMaxSize = $oVolume.Size
}
else
{
$nFreeSpace = $oVolume.FreeSpace
if ($IsVolumeInfoSupported)
{
$nMaxSize = $oVolume.Capacity
}
else
{
$nMaxSize = $oVolume.Size
}
}
Create-PerfData -VolumeId $VolumeId -nMaxSize $nMaxSize -nFreeSpace $nFreeSpace -SystemDrive $SystemDrive -momAPI $momAPI -bBagIsNotEmpty ([ref]$IsNotEmpty)
if ($false -eq $bBagIsNotEmpty)
{
if ($true -eq $IsNotEmpty)
{
$bBagIsNotEmpty = $true
}
}
}
if ($false -eq $bBagIsNotEmpty)
{
$oBag = $momAPI.CreatePropertyBag()
$oBag.AddValue("IsNotEmpty", "false")
$oBag
}
Unload-Module -ModuleName "Storage"
Unload-Module -ModuleName "CimCmdLets"
}
Function GetDriveHealthState
{
param ($bIsSystem, $dSysWarnMB, $dSysWarnPct, $dSysErrorMB, $dSysErrorPct, $dNonSysWarnMB, $dNonSysWarnPct, $dNonSysErrorMB, $dNonSysErrorPct, $dPctFree, $dMBFree)
$fResult = $DriveHealthyState
If ($bIsSystem)
{
If (($dMBFree -le $dSysErrorMB) -and ($dPctFree -le $dSysErrorPct))
{
$fResult = $DriveErrorState
}
ElseIf (($dMBFree -le $dSysWarnMB) -and ($dPctFree -le $dSysWarnPct))
{
$fResult = $DriveWarningState
}
}
Else
{
If (($dMBFree -le $dNonSysErrorMB) -and ($dPctFree -le $dNonSysErrorPct))
{
$fResult = $DriveErrorState
}
ElseIf (($dMBFree -le $dNonSysWarnMB) -and ($dPctFree -le $dNonSysWarnPct))
{
$fResult = $DriveWarningState
}
}
return $fResult
}
Function Create-PerfData([string]$VolumeId,$nMaxSize,$nFreeSpace,[string]$SystemDrive,$momAPI, [ref]$bBagIsNotEmpty)
{
$ErrorActionPreference="SilentlyContinue"
$error.Clear()
if ($null -eq $momAPI)
{
return
}
if ($nMaxSize -eq $null -or $nMaxSize -eq 0)
{
return
}
if ($nFreeSpace -eq $null)
{
$nFreeSpace = 0
}
$nPctFree = [math]::Round($nFreeSpace / $nMaxSize * 100, 2)
$nMBFree = [math]::Round($nFreeSpace / $BYTES_IN_MB, 0)
if ($VolumeId -ieq $SystemDrive)
{
$bIsSystemDrive = $true
}
else
{
$bIsSystemDrive = $false
}
$State = GetDriveHealthState $bIsSystemDrive $SysWarningMB $SysWarningPct $SysErrorMB $SysErrorPct $NonSysWarningMB $NonSysWarningPct $NonSysErrorMB $NonSysErrorPct $nPctFree $nMBFree
$oBag = $momAPI.CreatePropertyBag()
$oBag.AddValue("IsNotEmpty", "true")
$oBag.AddValue("PerfInstance", $VolumeId)
$oBag.AddValue("DiskState",$State)
if ($error.Count -eq 0)
{
$oBag
$bBagIsNotEmpty.Value = $true
}
}
Main
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>TargetComputer</Name>
<Value>$Config/ComputerName$</Value>
</Parameter>
<Parameter>
<Name>DebugFlag</Name>
<Value>false</Value>
</Parameter>
<Parameter>
<Name>SysWarningMB</Name>
<Value>$Config/SystemDriveWarningMBytesThreshold$</Value>
</Parameter>
<Parameter>
<Name>SysWarningPct</Name>
<Value>$Config/SystemDriveWarningPercentThreshold$</Value>
</Parameter>
<Parameter>
<Name>SysErrorMB</Name>
<Value>$Config/SystemDriveErrorMBytesThreshold$</Value>
</Parameter>
<Parameter>
<Name>SysErrorPct</Name>
<Value>$Config/SystemDriveErrorPercentThreshold$</Value>
</Parameter>
<Parameter>
<Name>NonSysWarningMB</Name>
<Value>$Config/NonSystemDriveWarningMBytesThreshold$</Value>
</Parameter>
<Parameter>
<Name>NonSysWarningPct</Name>
<Value>$Config/NonSystemDriveWarningPercentThreshold$</Value>
</Parameter>
<Parameter>
<Name>NonSysErrorMB</Name>
<Value>$Config/NonSystemDriveErrorMBytesThreshold$</Value>
</Parameter>
<Parameter>
<Name>NonSysErrorPct</Name>
<Value>$Config/NonSystemDriveErrorPercentThreshold$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="EmptyCD" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Boolean">Property[@Name='IsNotEmpty']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Boolean">true</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="InstanceFilter" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='DiskLabel']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">$Config/DiskLabel$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<Composition>
<Node ID="InstanceFilter">
<Node ID="EmptyCD">
<Node ID="PA">
<Node ID="Scheduler"/>
</Node>
</Node>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.BaseData</OutputType>
</DataSourceModuleType>