mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Expanded upon lib/provider/services to support translated status values in Invoke-IcingaCheckService.psm1
This commit is contained in:
parent
e2c8933c9a
commit
a5ab649f80
3 changed files with 28 additions and 2 deletions
|
|
@ -13,10 +13,10 @@ function Invoke-IcingaCheckService()
|
|||
$FoundService = Get-IcingaServices -Service $Service;
|
||||
$ServiceName = $FoundService.Values.metadata.ServiceName;
|
||||
$DisplayName = $FoundService.Values.metadata.DisplayName;
|
||||
# $Status = Get-IcingaServicesStatusTranslation -Status $Status;
|
||||
$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.ServiceStatus;
|
||||
$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);
|
||||
|
|
|
|||
|
|
@ -471,6 +471,15 @@
|
|||
62= 'TPF';
|
||||
}
|
||||
|
||||
<##################################################################################################
|
||||
################# /lib/provider/Services ###########################################################
|
||||
##################################################################################################>
|
||||
|
||||
[hashtable]$ServiceStatus = @{
|
||||
'Stopped' = 1;
|
||||
'Running' = 4;
|
||||
}
|
||||
|
||||
[hashtable]$ProviderEnums = @{
|
||||
#/lib/provider/bios
|
||||
BiosCharacteristics = $BiosCharacteristics;
|
||||
|
|
@ -493,6 +502,8 @@
|
|||
WindowsOSProductSuite = $WindowsOSProductSuite;
|
||||
WindowsProductType = $WindowsProductType;
|
||||
WindowsOSType = $WindowsOSType;
|
||||
#/lib/provider/services
|
||||
ServiceStatus = $ServiceStatus;
|
||||
}
|
||||
|
||||
Export-ModuleMember -Variable @('ProviderEnums');
|
||||
|
|
@ -63,3 +63,18 @@ function Get-IcingaServices()
|
|||
}
|
||||
return $ServiceData;
|
||||
}
|
||||
|
||||
function Get-IcingaServicesStatusTranslation()
|
||||
{
|
||||
param (
|
||||
$Status
|
||||
)
|
||||
|
||||
if ($Status -match "^\d+$") {
|
||||
return $Status
|
||||
} else {
|
||||
$Status = $ProviderEnums.ServiceStatus.($Status);
|
||||
}
|
||||
|
||||
return $Status;
|
||||
}
|
||||
Loading…
Reference in a new issue