mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Splitt into ConvertTo-ServiceStatusCode, to fit project structure, changed Free Space to Used Space
This commit is contained in:
parent
8cae29a79a
commit
802f5b3205
4 changed files with 17 additions and 18 deletions
|
|
@ -13,7 +13,7 @@ function Invoke-IcingaCheckService()
|
||||||
$FoundService = Get-IcingaServices -Service $Service;
|
$FoundService = Get-IcingaServices -Service $Service;
|
||||||
$ServiceName = $FoundService.Values.metadata.ServiceName;
|
$ServiceName = $FoundService.Values.metadata.ServiceName;
|
||||||
$DisplayName = $FoundService.Values.metadata.DisplayName;
|
$DisplayName = $FoundService.Values.metadata.DisplayName;
|
||||||
$Status = Get-IcingaServicesStatusTranslation -Status $Status;
|
$Status = ConvertTo-ServiceStatusCode -Status $Status;
|
||||||
$StatusRaw = $FoundService.Values.configuration.Status.raw;
|
$StatusRaw = $FoundService.Values.configuration.Status.raw;
|
||||||
|
|
||||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Service "{0} ({1})"', $DisplayName, $ServiceName)) -Value $StatusRaw -ObjectExists $FoundService -ValueTranslation $ProviderEnums.ServicesStatus;
|
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Service "{0} ({1})"', $DisplayName, $ServiceName)) -Value $StatusRaw -ObjectExists $FoundService -ValueTranslation $ProviderEnums.ServicesStatus;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Import-IcingaLib core\perfcounter;
|
Import-IcingaLib core\perfcounter;
|
||||||
Import-IcingaLib icinga\plugin;
|
Import-IcingaLib icinga\plugin;
|
||||||
|
|
||||||
function Invoke-IcingaCheckFreePartition()
|
function Invoke-IcingaCheckUsedPartitionSpace()
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
$Warning,
|
$Warning,
|
||||||
|
|
@ -33,7 +33,7 @@ function Invoke-IcingaCheckFreePartition()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value $DiskFree.([string]::Format($Letter))."Free Space" -Unit '%';
|
$IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value (100-($DiskFree.([string]::Format($Letter))."Free Space")) -Unit '%';
|
||||||
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
$IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;
|
||||||
$DiskPackage.AddCheck($IcingaCheck);
|
$DiskPackage.AddCheck($IcingaCheck);
|
||||||
}
|
}
|
||||||
14
lib/provider/services/ConvertTo-ServiceStatusCode.psm1
Normal file
14
lib/provider/services/ConvertTo-ServiceStatusCode.psm1
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
function ConvertTo-ServiceStatusCode()
|
||||||
|
{
|
||||||
|
param (
|
||||||
|
$Status
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($Status -match "^\d+$") {
|
||||||
|
return $Status
|
||||||
|
} else {
|
||||||
|
$Status = $ProviderEnums.ServiceStatus.($Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Status;
|
||||||
|
}
|
||||||
|
|
@ -63,18 +63,3 @@ function Get-IcingaServices()
|
||||||
}
|
}
|
||||||
return $ServiceData;
|
return $ServiceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-IcingaServicesStatusTranslation()
|
|
||||||
{
|
|
||||||
param (
|
|
||||||
$Status
|
|
||||||
)
|
|
||||||
|
|
||||||
if ($Status -match "^\d+$") {
|
|
||||||
return $Status
|
|
||||||
} else {
|
|
||||||
$Status = $ProviderEnums.ServiceStatus.($Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $Status;
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue