mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Added Invoke-IcingaCheckFreePartition.psm1
This commit is contained in:
parent
0ef518ef19
commit
57b6676e20
1 changed files with 39 additions and 0 deletions
39
lib/plugins/Invoke-IcingaCheckFreePartition.psm1
Normal file
39
lib/plugins/Invoke-IcingaCheckFreePartition.psm1
Normal file
|
|
@ -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);
|
||||
}
|
||||
Loading…
Reference in a new issue