icinga-powershell-framework/lib/plugins/Invoke-IcingaCheckService.psm1

24 lines
909 B
PowerShell
Raw Normal View History

Import-IcingaLib provider\services;
Import-IcingaLib icinga\plugin;
function Invoke-IcingaCheckService()
{
param(
[string]$Status,
[string]$Service,
[switch]$NoPerfData,
$Verbose
);
$FoundService = Get-IcingaServices -Service $Service;
$ServiceName = $FoundService.Values.metadata.ServiceName;
$DisplayName = $FoundService.Values.metadata.DisplayName;
$Status = ConvertTo-ServiceStatusCode -Status $Status;
$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.CritIfNotMatch($Status) | Out-Null;
exit (New-IcingaCheckResult -Name "Service $Service" -Check $IcingaCheck -NoPerfData $TRUE -Compile);
}