icinga-powershell-framework/lib/plugins/Invoke-IcingaCheckService.psm1
Lord Hepipud 8b3fcaaa9c Updated Services Provider, Enums and Helper functions
* Added new function to get Service Name for Check output
* Added missing Service State enums
* Updated Service Status Code function to use existing Test-Numeric
* Update Service Check with new Cmdlets
2019-07-24 14:28:53 +02:00

23 lines
851 B
PowerShell

Import-IcingaLib provider\services;
Import-IcingaLib provider\enums;
Import-IcingaLib icinga\plugin;
function Invoke-IcingaCheckService()
{
param(
[string]$Status,
[string]$Service,
[switch]$NoPerfData,
$Verbose
);
$FoundService = Get-IcingaServices -Service $Service;
$ServiceName = Get-IcingaServiceCheckName -ServiceInput $Service -Service $FoundService;
$Status = ConvertTo-ServiceStatusCode -Status $Status;
$StatusRaw = $FoundService.Values.configuration.Status.raw;
$IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName;
$IcingaCheck.CritIfNotMatch($Status) | Out-Null;
exit (New-IcingaCheckResult -Name "Service $Service" -Check $IcingaCheck -NoPerfData $TRUE -Compile);
}