2019-07-23 09:08:59 -04:00
|
|
|
Import-IcingaLib core\perfcounter;
|
|
|
|
|
Import-IcingaLib icinga\plugin;
|
|
|
|
|
|
2019-07-24 05:44:33 -04:00
|
|
|
function Invoke-IcingaCheckUsedPartitionSpace()
|
2019-07-23 09:08:59 -04:00
|
|
|
{
|
|
|
|
|
param(
|
|
|
|
|
$Warning,
|
|
|
|
|
$Critical,
|
|
|
|
|
[array]$Include = @(),
|
|
|
|
|
[array]$Exclude = @(),
|
|
|
|
|
[switch]$NoPerfData,
|
|
|
|
|
$Verbose
|
|
|
|
|
);
|
|
|
|
|
|
2019-07-24 04:01:34 -04:00
|
|
|
$DiskFree = Get-IcingaDiskPartitions;
|
2019-07-24 09:02:58 -04:00
|
|
|
$DiskPackage = New-IcingaCheckPackage -Name 'Used Partition Space' -OperatorAnd -Verbos $Verbose;
|
2019-07-23 09:08:59 -04:00
|
|
|
|
|
|
|
|
foreach ($Letter in $DiskFree.Keys) {
|
|
|
|
|
if ($Include.Count -ne 0) {
|
|
|
|
|
$Include = $Include.trim(' :/\');
|
|
|
|
|
if (-Not ($Include.Contains($Letter))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 04:01:34 -04:00
|
|
|
|
2019-07-23 09:08:59 -04:00
|
|
|
if ($Exclude.Count -ne 0) {
|
|
|
|
|
$Exclude = $Exclude.trim(' :/\');
|
|
|
|
|
if ($Exclude.Contains($Letter)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 05:44:33 -04:00
|
|
|
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value (100-($DiskFree.([string]::Format($Letter))."Free Space")) -Unit '%';
|
2019-07-23 09:08:59 -04:00
|
|
|
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
|
|
|
|
$DiskPackage.AddCheck($IcingaCheck);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-24 09:02:58 -04:00
|
|
|
exit (New-IcingaCheckResult -Check $DiskPackage -NoPerfData $NoPerfData -Compile);
|
2019-07-23 09:08:59 -04:00
|
|
|
}
|