mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Changed Invoke-IcingaCheckService.psm1 to support multiple inputs
This commit is contained in:
parent
d7fdeba915
commit
95ea8cf28f
1 changed files with 22 additions and 2 deletions
|
|
@ -5,10 +5,28 @@ Import-IcingaLib icinga\plugin;
|
||||||
function Invoke-IcingaCheckService()
|
function Invoke-IcingaCheckService()
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
|
[array]$Service,
|
||||||
[string]$Status,
|
[string]$Status,
|
||||||
[string]$Service
|
[int]$Verbose
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$ServicesPackage = New-IcingaCheckPackage -Name 'Services' -OperatorAnd -Verbose $Verbose;
|
||||||
|
|
||||||
|
if ($Service.Count -ne 1) {
|
||||||
|
foreach ($services in $Service) {
|
||||||
|
$IcingaCheck = $null;
|
||||||
|
|
||||||
|
$FoundService = Get-IcingaServices -Service $services;
|
||||||
|
$ServiceName = Get-IcingaServiceCheckName -ServiceInput $services -Service $FoundService;
|
||||||
|
$ConvertedStatus = ConvertTo-ServiceStatusCode -Status $Status;
|
||||||
|
$StatusRaw = $FoundService.Values.configuration.Status.raw;
|
||||||
|
|
||||||
|
$IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName;
|
||||||
|
$IcingaCheck.CritIfNotMatch($ConvertedStatus) | Out-Null;
|
||||||
|
$ServicesPackage.AddCheck($IcingaCheck)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
$FoundService = Get-IcingaServices -Service $Service;
|
$FoundService = Get-IcingaServices -Service $Service;
|
||||||
$ServiceName = Get-IcingaServiceCheckName -ServiceInput $Service -Service $FoundService;
|
$ServiceName = Get-IcingaServiceCheckName -ServiceInput $Service -Service $FoundService;
|
||||||
$Status = ConvertTo-ServiceStatusCode -Status $Status;
|
$Status = ConvertTo-ServiceStatusCode -Status $Status;
|
||||||
|
|
@ -16,6 +34,8 @@ function Invoke-IcingaCheckService()
|
||||||
|
|
||||||
$IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName;
|
$IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName;
|
||||||
$IcingaCheck.CritIfNotMatch($Status) | Out-Null;
|
$IcingaCheck.CritIfNotMatch($Status) | Out-Null;
|
||||||
|
$ServicesPackage.AddCheck($IcingaCheck);
|
||||||
|
|
||||||
exit (New-IcingaCheckResult -Check $IcingaCheck -NoPerfData $TRUE -Compile);
|
}
|
||||||
|
exit (New-IcingaCheckResult -Name 'Services' -Check $ServicesPackage -NoPerfData $TRUE -Compile);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue