Windows 正在收集有关群集共享卷的信息

Windows 正在收集有关群集共享卷的信息,windows,powershell,windows-server-2008-r2,hyper-v,Windows,Powershell,Windows Server 2008 R2,Hyper V,我想让我们的监控软件(Nagios)启动一个powershell脚本,该脚本检查ClusterSharedVolume并在一个文本字符串中返回所有卷的状态。如果任何卷的可用空间少于%5,我希望触发严重警告 这是迄今为止的代码: # Import Cluster Shared Volumes module to Powershell Import-Module FailoverClusters # Flush object $objs = @() # Gather info from the

我想让我们的监控软件(Nagios)启动一个powershell脚本,该脚本检查ClusterSharedVolume并在一个文本字符串中返回所有卷的状态。如果任何卷的可用空间少于%5,我希望触发严重警告

这是迄今为止的代码:

# Import Cluster Shared Volumes module to Powershell
Import-Module FailoverClusters

# Flush object
$objs = @()

# Gather info from the ClusterSharedVolume
$csvs = Get-ClusterSharedVolume
foreach ( $csv in $csvs )
{
    $csvinfos = $csv | select -Property Name -ExpandProperty SharedVolumeInfo
        $new_obj = $objs | select  Name,Path,
        @{ Name = ($csv.Name) },
        @{ Path = ($csvinfo.FriendlyVolumeName) },
        @{ Label = "Size(GB)" ; Expression = { "{0:N1}" -f ($csvinfo.Partition.Size / 1GB) } },   
        @{ Label = "FreeSpace(GB)" ; Expression = { "{0:N1}" -f ($csvinfo.Partition.FreeSpace / 1GB) } },    
        @{ Label = "UsedSpace(GB)" ; Expression = { "{0:N1}" -f ($csvinfo.Partition.UsedSpace / 1GB) } },    
        @{ Label = "PercentFree" ; Expression = { "{0:N2}" -f ($csvinfo.Partition.PercentFree) } }

$objs += $new_obj
}

$objs
我知道我这里有一些基本的错误。。。我的脚本只是返回适当数量的对象,但都是一样的。 请注意:)

您没有在任何地方定义“$csvinfos”,只有“$csvinfos”