Sha256: eb226279b3552dc11bea7f8720194a0d7bc879e40d0ee5beae6e63a710bdc662

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

#
#   metric-windows-disk-usage.ps1
#
# DESCRIPTION:
#   This plugin collects and outputs Disk Usage metrics in a Graphite acceptable format.
#
# OUTPUT:
#   metric data
#
# PLATFORMS:
#   Windows
#
# DEPENDENCIES:
#   Powershell
#
# USAGE:
#   Powershell.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -NoLogo -File C:\\etc\\sensu\\plugins\\metric-windows-disk-usage.ps1
#
# NOTES:
#
# LICENSE:
#   Copyright 2016 sensu-plugins
#   Released under the same terms as Sensu (the MIT license); see LICENSE for details.
#
$ThisProcess = Get-Process -Id $pid
$ThisProcess.PriorityClass = "BelowNormal"

$AllDisks = Get-WMIObject Win32_LogicalDisk -Filter "DriveType = 3" | ? { $_.DeviceID -notmatch "[ab]:"}

foreach ($ObjDisk in $AllDisks) 
{
  $DeviceId = $ObjDisk.DeviceID -replace ":",""

  $UsedSpace = [System.Math]::Round((($ObjDisk.Size-$ObjDisk.Freespace)/1MB),2)
  $AvailableSpace = [System.Math]::Round(($ObjDisk.Freespace/1MB),2)
  $UsedPercentage = [System.Math]::Round(((($ObjDisk.Size-$ObjDisk.Freespace)/$ObjDisk.Size)*100),2)

  $Path = (hostname).ToLower()

  $Time = [int][double]::Parse((Get-Date -UFormat %s))

  Write-Host "$Path.system.Disk.$DeviceId.UsedMB $UsedSpace $Time"
  Write-Host "$Path.system.Disk.$DeviceId.FreeMB $AvailableSpace $Time"
  Write-Host "$Path.system.Disk.$DeviceId.UsedPercentage $UsedPercentage $Time"
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sensu-plugins-windows-2.1.0 bin/powershell/metric-windows-disk-usage.ps1
sensu-plugins-windows-2.0.0 bin/powershell/metric-windows-disk-usage.ps1
sensu-plugins-windows-1.0.0 bin/powershell/metric-windows-disk-usage.ps1
sensu-plugins-windows-0.1.0 bin/powershell/metric-windows-disk-usage.ps1