Blog Series: Monitoring using PowerShell: Part Six – Monitoring CSV volumes for space and status

Hi All,

My next couple of blogs will be a series of blogs where I will be explaining on how to use PowerShell for the monitoring of critical infrastructure. I will be releasing a blog every day that will touch on how to monitor specific software components, but also network devices from Ubiquity, third-party API’s and Office365. I will also be showing how you can integrate this monitoring in current RMM packages such as Solarwinds N-Central, Solarwinds RMM MSP and even include the required files to import the  monitoring set directly into your system.


Requirements:

  • Cluster Shared Volume
  • PowerShell v3 or higher

Creating the monitoring sets:

We have a few clients that have shared storage, this shared storage needs to be monitored for size and usage but as Microsoft decided to make the mount points on C:\ClusterStorage its not always easy to do this from your RMM or without logging into the server. To make sure we can monitor the CSV state regarding storage used we use the following script:

Size Monioring:

param(
[string]$MonitorPercent = 5
)
try {
$CSV = Get-ClusterSharedVolume
}catch{
$ScriptError = "Query Failed: $($_.Exception.Message)"
}
foreach($volume in $CSV.SharedVolumeInfo){
$Path        = $volume.FriendlyVolumeName
$Size        = [math]::truncate($volume.Partition.Size / 1024MB)
$FreeSpace   = [math]::truncate($volume.Partition.FreeSpace/ 1024MB)
$UsedSpace   = [math]::truncate($volume.Partition.UsedSpace/ 1024MB)
$PercentFree = [math]::truncate($volume.Partition.PercentFree)
if($PercentFree -le $MonitorPercent){
$Status +=  "$name at path $path is at $percentfree% free`n$UsedSpace GB used of $Size GB"
}
}
if (!$Status) { $Status = “Healthy” }
if (!$ScriptError) { $ScriptError = “Healthy” }

Status Monitoring:

try {
$CSV = Get-ClusterSharedVolume
}catch{
$ScriptError = "Query Failed: $($_.Exception.Message)"
}
foreach($volumes in $CSV){
$Name   = $volumes.name
if($volumes.State -ne "Online"){
$Status += "$name is $($volumes.State)"
}
if (!$Status) { $Status = “Healthy” }
if (!$ScriptError) { $ScriptError = “Healthy” }

And thats how you can monitor the CSV volume state when you’re using shared storage. 🙂

Downloads for RMM packages:

N-Central 11.0+ – CSV Monitoring

One thought on “Blog Series: Monitoring using PowerShell: Part Six – Monitoring CSV volumes for space and status

  1. izetta_izetta

    Hey I know this is off topic but I was wondering if you could blog about how to check the state of roles in a cluster next, like what the current state is.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *