mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
23 lines
917 B
PowerShell
23 lines
917 B
PowerShell
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 = Get-IcingaServicesStatusTranslation -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);
|
|
}
|