mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added Icinga_ProviderServices, adjusted Invoke-IcingaCheckService accordingly
This commit is contained in:
parent
57b6676e20
commit
e2c8933c9a
3 changed files with 32 additions and 2 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
23
lib/plugins/Invoke-IcingaCheckService.psm1
Normal file
23
lib/plugins/Invoke-IcingaCheckService.psm1
Normal 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);
|
||||
}
|
||||
|
|
@ -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 = @{};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue