Added Icinga_ProviderServices, adjusted Invoke-IcingaCheckService accordingly

This commit is contained in:
Alexander Stoll 2019-07-24 10:01:34 +02:00
parent 57b6676e20
commit e2c8933c9a
3 changed files with 32 additions and 2 deletions

View file

@ -12,8 +12,9 @@ function Invoke-IcingaCheckFreePartition()
$Verbose
);
$DiskFree = Get-IcingaDiskPartitions
$DiskFree = Get-IcingaDiskPartitions;
$DiskPackage = New-IcingaCheckPackage -Name 'Free Disk Space' -OperatorAnd -Verbos $Verbose;
[array]$CheckedPartitions;
foreach ($Letter in $DiskFree.Keys) {
if ($Include.Count -ne 0) {
@ -23,6 +24,8 @@ function Invoke-IcingaCheckFreePartition()
}
}
$CheckedPartitions+=$Letter
if ($Exclude.Count -ne 0) {
$Exclude = $Exclude.trim(' :/\');
if ($Exclude.Contains($Letter)) {

View file

@ -0,0 +1,23 @@
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.ServiceStatus;
$IcingaCheck.CritIfNotMatch($Status) | Out-Null;
exit (New-IcingaCheckResult -Name "Service $Service" -Check $IcingaCheck -NoPerfData $TRUE -Compile);
}

View file

@ -4,7 +4,11 @@ function Get-IcingaServices()
[array]$Service
)
$ServiceInformation = Get-Service -Name $Service;
$ServiceInformation = Get-Service -Name $Service -ErrorAction SilentlyContinue;
if ($null -eq $ServiceInformation) {
return $null;
}
[hashtable]$ServiceData = @{};