Home Directory Plugins Operating Systems Windows check_win_dedup_status.ps1

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

check_win_dedup_status.ps1

Rating
0 votes
Favoured:
0
Current Version
1.0
Last Release Date
2020-12-13
Compatible With
  • Nagios 1.x
  • Nagios 2.x
  • Nagios 3.x
  • Nagios 4.x
  • Nagios XI
Owner
License
GPL
Hits
3185
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Script to check if Windows DeDuplication is enabled for all fixed Disks except C:
and to Summarize the Savings of Windows DeDuplication
Might be helpfull if you are running your calssic windows fileserver with enabled deduplication
should be called via NRPE/NSClient++
##################################################################################
#
# NAME: check_win_dedup_status.ps1
#
# AUTHOR: Peter Luetke-Bexten
# EMAIL: peter.luetke-bexten (at) benteler.com
#
# COMMENT:
# Script to check if Windows DeDuplication is enabled for all fixed Disks except C:
# and to Summarize the Savings of Windows DeDuplication
# Might be helpfull if you are running your calssic windows fileserver with enabled deduplication
# should be called via NRPE/NSClient++
#
# Return Values for NRPE:
# DeDup is enabled for all Volumes - OK (0)
# DeDup on some Volumes not enabled - WARNING (1)
# DeDup is not enabled for any Volume - WARNING (1)
# DeDup Feature is not enabled - UNKNOWN (3)
# Script errors - UNKNOWN (3)
#
# NSCLIENT.ini:
# check_win_dedup_status = cmd /c echo scriptspowershellcheck_win_dedup_status.ps1 ; exit($lastexitcode) | "C:WindowsSystem32WindowsPowerShellv1.0powershell.exe" -noninteractive -noprofile -ExecutionPolicy unrestricted -command -
#
# NRPE Check:
# check_nrpe -H Targethost -p 5666 -t 120 -u -c check_win_dedup_status
#
# CHANGELOG:
# 1.0 20201211 - initial version
#
##################################################################################

# Nagios return States
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2
$returnStateUnknown = 3

# Check DedupFeature
if (!((Get-WindowsFeature -Name FS-Data-Deduplication).InstallState -eq "Installed"))
{
Write-Host "FS-Data-Deduplication Feature is not enabled"
exit $returnStateUnknown
}

if (!(Get-Command Get-DedupStatus -errorAction SilentlyContinue))
{
Write-Host "Get-DedupStatus is not available on this System"
exit $returnStateUnknown
}

# Get local Disk Infos
$DiskswoOS=Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType = ""3""" |
Where-Object {$_.DeviceID -ne ‘C:’} |
Select-Object -Property DeviceID, DriveType, VolumeName,
@{L='FreeSpaceGB';E={"{0:N2}" -f ($_.FreeSpace /1GB)}},
@{L="CapacityGB";E={"{0:N2}" -f ($_.Size/1GB)}}

# Check if there are DataVolumes (every local disk excl. Drive C:)
if ($DiskswoOS -eq $Null)
{
Write-Host "No DataVolumes available"
exit $returnStateUnknown
}

# Get DeDup Status
$DisksDeDup=Get-Dedupstatus | Select-Object -Property Volume,
@{L='FreeSpaceGB';E={"{0:N2}" -f ($_.FreeSpace /1GB)}},
@{L="SavedSpaceGB";E={"{0:N2}" -f ($_.SavedSpace/1GB)}}

# Check if no Deduplication is available for anyo DataVolumes
if ($DisksDeDup -eq $Null)
{
Write-Host "No Deduplication enabled for any of the DataVolumes"
exit $returnStateUnknown
}



# Compare lokal Disk Info with DedupStatus Info
$Comparsion=Compare-Object -ReferenceObject $DiskswoOS -DifferenceObject $DisksDeDup -PassThru

# If DedupStatus differs with lokal Disk Info display the Disk(s) without DDP enabled and also summarize
if ($Comparsion -ne $Null)
{
foreach ($Object in $Comparsion) {
Write-Host "Drive $($Object.DeviceID) has no DeDuplication enabled"
}
$SavingsTotalGB = 0
foreach ($Object in $DisksDeDup) {
$SavingsTotalGB += $($Object.SavedSpaceGB)
}
Write-Host "Warning - not all Drives have DeDup enabled| 'DedDup Savings Total GB'=$($SavingsTotalGB)"
exit $returnStateWarning
}

# If DedupStatus has same Volumes as lokal Disk printout the DeDup Savings per Volume
if ($Comparsion -eq $Null)
{
$SavingsTotalGB = 0
foreach ($Object in $DisksDeDup) {
$SavingsTotalGB += $($Object.SavedSpaceGB)
}
Write-Host "OK - DeDup Savings Total $($SavingsTotalGB) GB| 'DedDup Savings Total GB'=$($SavingsTotalGB)"
exit $returnStateOK
}

# if we are here, something went wrong
exit $returnStateCritical