From 57b6676e2055b726826e3f1252c5635bb5a65612 Mon Sep 17 00:00:00 2001 From: Alexander Stoll Date: Tue, 23 Jul 2019 15:08:59 +0200 Subject: [PATCH] Added Invoke-IcingaCheckFreePartition.psm1 --- .../Invoke-IcingaCheckFreePartition.psm1 | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/plugins/Invoke-IcingaCheckFreePartition.psm1 diff --git a/lib/plugins/Invoke-IcingaCheckFreePartition.psm1 b/lib/plugins/Invoke-IcingaCheckFreePartition.psm1 new file mode 100644 index 0000000..36a14bc --- /dev/null +++ b/lib/plugins/Invoke-IcingaCheckFreePartition.psm1 @@ -0,0 +1,39 @@ +Import-IcingaLib core\perfcounter; +Import-IcingaLib icinga\plugin; + +function Invoke-IcingaCheckFreePartition() +{ + param( + $Warning, + $Critical, + [array]$Include = @(), + [array]$Exclude = @(), + [switch]$NoPerfData, + $Verbose + ); + + $DiskFree = Get-IcingaDiskPartitions + $DiskPackage = New-IcingaCheckPackage -Name 'Free Disk Space' -OperatorAnd -Verbos $Verbose; + + foreach ($Letter in $DiskFree.Keys) { + if ($Include.Count -ne 0) { + $Include = $Include.trim(' :/\'); + if (-Not ($Include.Contains($Letter))) { + continue; + } + } + + if ($Exclude.Count -ne 0) { + $Exclude = $Exclude.trim(' :/\'); + if ($Exclude.Contains($Letter)) { + continue; + } + } + + $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value $DiskFree.([string]::Format($Letter))."Free Space" -Unit '%'; + $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; + $DiskPackage.AddCheck($IcingaCheck); + } + + exit (New-IcingaCheckResult -Name 'Free Disk Space' -Check $DiskPackage -NoPerfData $NoPerfData -Compile); +}