Kaseya Community

Using PowerShell script thru Agent Procedure to monitor Cluster Shared Volume disk space

  • We're trying to develop a way to monitor disk space on Cluster Shared Volumes. We've got the script below that generates a text file with a list of CSVs and information about them. I'm not an expert on Powershell or Agent Procedures. What would be the best way to run this thru an agent procedure and send an email if it is below a certain threshold?

    I'm thinking somewhere in the loop set a flag variable if the free space is below the threshold. Return the flag to the agent procedure and if it's set, send the email with the text file the script is currently generating as the body.

    $TotalGB = @{Name="Capacity(GB)";expression={[math]::round(($_.Capacity/ 1073741824),2)}}
    $FreeGB = @{Name="FreeSpace(GB)";expression={[math]::round(($_.FreeSpace / 1073741824),2)}}
    $FreePerc = @{Name="Free(%)";expression={[math]::round(((($_.FreeSpace / 1073741824)/($_.Capacity / 1073741824)) * 100),0)}}
    $UsedSpace = @{Name="UsedSpace(GB)";expression={[math]::round((($_.Capacity/ 1073741824) - ($_.FreeSpace / 1073741824)),2)}}
    $ComputerName=$env:ComputerName
    $output = "c:\intrust\" + $ComputerName + "_csv_.log"

    function get-mountpoints {
      $volumes = Get-WmiObject -computer $server win32_volume | Where-object {$_.DriveLetter -eq $null}
      $volumes | Select SystemName, Label, $TotalGB,$UsedSpace, $FreeGB, $FreePerc | Format-Table -AutoSize
    }


    $servers = "localhost"
    foreach ($server in $servers){

      get-mountpoints | out-file $output -Force
    }

    Thanks,

    - Marc

  • We do all our email sending from PowerShell itself. Basically we monitor whatever it is we want to monitor via kaseya.

    Step 1: PowerShell script is run should it be below the threshold.

    Step 2: We then run the same checks again via PowerShell, sometimes with other conditions to be met ie. free space GB and percentage free space.

    Step 3: Once that completes and if the conditions are met within PowerShell it will then send off the email.

  • That sounds like it could be simpler.   Any tips on how to use powershell to parse the output to see if it's below threshold?  Is there an email function built into powershell, or are you using something like Blat?

    Thanks,

    - Marc