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