#PSTip Monitoring Cluster Shared Volume (CSV) availability

Recently, I was troubleshooting an issue related to CSVs going offline randomly. In that process, I had to detect when a CSV goes offline and then analyse a few log files to find the root cause.

For monitoring CSV availability, I used the WMI events. Here is what I did.

$query = "Select * from __instanceModificationEvent WITHIN 1 WHERE TargetInstance ISA 'MSCluster_Resource' AND TargetInstance.Type='Physical Disk' AND TargetInstance.IsClusterSharedVolume='True' AND TargetInstance.State=3"
Register-WmiEvent -Namespace root\mscluster -Query $query -Action {
    Write-Host "CSV volume $($event.SourceEventArgs.NewEvent.TargetInstance.Name) went offline"
}

In the WMI query, I used an intrinsic event registration for the MSCluster_Resource Failover Cluster WMI class. So, whenever an instance of this class gets modified, we get notified. If you want to try bringing the CSV online, you can insert the following line of code into the -Action script block.

Start-ClusterResource -Name $event.SourceEventArgs.NewEvent.TargetInstance.Name
Share on: