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

Recent Articles

Automating with PowerShell: making stolen tokens useless with Global Secure Access

Last week I watched Merill Fernando talk to Alex Pavlovsky and Marilee Tuscak from the Entra team about something I’d kinda put under the “needs a GSA licence” branch and i’d check it out later, turns out that like most people, I half-assed the documentation and it turns out it doesn’t. There’s two features that come with any P1 license; Compliant network check and Source IP Restoration. So BP, P1, or even frontline worker licenses already have this.

CIPP ❤️ #IntuneForMSPs

We’re Joining #IntuneForMSPs 🎉

Being invited by Microsoft to join a global initiative is a big moment for us, and we want to be clear about why it matters. #IntuneForMSPs is Microsoft’s program to help MSPs deliver Microsoft 365, Intune, and Copilot services at scale, and CIPP is now part of it, bringing the largest MSP community in the channel directly to Microsoft.

The return of CyberDrain CTF

CyberDrain CTF returns! (and so do I!)

It’s been since september that I actually picked up a digital pen equivalent and wrote anything down. This was due to me being busy with life but also my side projects like CIPP. I’m trying to get back into the game of scripting and blogging about these scripts. There’s still so much to automate and so little time, right? ;)