Has anyone found a way to monitor disk space on CSV volumes on Hyper-V hosts? I am able to check disk space using a PowerShell script, but have not found a way to do it in NPM or APM.
Hi nbissette, same here i am also looking for same info. i found a link where a user has got that implemented and i hope it will be useful for us.
http://thwack.solarwinds.com/message/160055#160055
I just finished implementing this in our environment.There are two steps involved:
1) Configure a node in the cluster to handle remote Powershell scripts. This portion is covered well enough in other places, and I didn't configure it myself, so I'll leave well enough alone :-)
2) Execute your Powershell script. The big trick here is to ensure that the output adheres to APM / SAM's expectations. This is poorly outlined in the documentation. Alluded to, really. Not documented per-se.
Below is the script we are using. Note that I'm NOT a Powershell guy; I have kludged the text output to cause SAM to be happy, but I've also committed several deadly sins of scripting in the meantime. The result ALMOST works; it has one obvious problem. If you can help me fix it, I'd be grateful!
Rundown of what it does:
Anyone think they can help clean this up?
Import-Module FailoverClusters
$a = Get-ClusterSharedVolume "Cluster Disk 1" | select -Expand SharedVolumeInfo | select -Expand Partition | select PercentFree | out-string
$b = [regex]::match($a,'\d\d').Groups[0].Value
Echo "Statistic.CSV1PercentFree:$b"
Echo "Message.CSV1PercentFree:None"
$c = Get-ClusterSharedVolume "Cluster Disk 2" | select -Expand SharedVolumeInfo | select -Expand Partition | select PercentFree | out-string
$d = [regex]::match($c,'\d\d').Groups[0].Value
Echo "Statistic.CSV2PercentFree:$d"
Echo "Message.CSV2PercentFree:None"
if ([int]$b -le 10) {exit 2}
if ([int]$b -le 5) {exit 3}
if ([int]$d -le 10) {exit 2}
if ([int]$d -le 5) {exit 3}
exit 0
Further kludge, but cleaner: If you change this line:
To read like so:
$b = [regex]::match($a,'\d*\d').Groups[0].Value
It will return everything to the left of the decimal point. That should make this script behave the way we want it to, though it's still a messy way to do things. Anyone know how to just tell Powershell to return a better formatted result in the first place?
"{0:N0}" -f will round to the nearest whole number.
You can do something like:
$b = "{0:N0}" -f (Get-ClusterSharedVolume "Cluster Disk 1" | select -Expand SharedVolumeInfo | select -Expand Partition | Select PercentFree).PercentFree
$d = "{0:N0}" -f (Get-ClusterSharedVolume "Cluster Disk 2" | select -Expand SharedVolumeInfo | select -Expand Partition | Select PercentFree).PercentFree
You can also make it a bit more portable by doing:
Get-ClusterSharedVolume | Foreach {
$name = $_.Name
$PercentFree = "{0:N0}" -f (Get-ClusterSharedVolume | Select -Expand SharedVolumeInfo | Select -Expand Partition | Select PercentFree).PercentFree
Echo "Statistic.$name`PercentFree:$PercentFree"
If ([int]$PercentFree -le 10) { exit 2 }
If ([int]$PercentFree -le 5) { exit 3 }
}
Or if you know you have spaces in your CSV names something like:
$i = 1
$name = "CSV$i"
$i++
That first example worked perfectly. I'm using it to replace my current script. Thanks!!
The other two gave me the following error:
Get-ClusterSharedVolume : The pipeline has been stopped.
At line:1 char:24
+ Get-ClusterSharedVolume <<<< | Foreach {
+ CategoryInfo : NotSpecified: (:) [Get-ClusterSharedVolume], ClusterCmdletException
+ FullyQualifiedErrorId : Get-ClusterSharedVolume,Microsoft.FailoverClusters.PowerShell.GetClusterSharedVolumeComm
and
But I'm very satisfied with the first one. It tells me a lot about how things work. Thanks!!