mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
* 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
23 lines
851 B
PowerShell
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);
|
|
}
|