Icinga / icinga-powershell-hyperv

A collection of Hyper-V plugins for the Icinga Powershell Framework
GNU General Public License v2.0
6 stars 0 forks source link

Wrong unneeded services detection #45

Closed LioZha closed 2 years ago

LioZha commented 3 years ago

On all my Hyper-V hosts (Windows 2019 v.1809 build: 17763.2114) Hyper-V Guest services all are in "Stopped" state, this is familiar behavior. Services startup type is: "Manual (triggered start)" and exit code exists and is eq 1077. This triggers CRITICAL output of pulgin.

$GetServices          = Get-IcingaServices -Service @(
    'vmcompute',
    'vmicguestinterface',
    'vmicheartbeat',
    'vmickvpexchange',
    'vmicrdv',
    'vmicshutdown',
    'vmictimesync',
    'vmicvmsession',
    'vmicvss',
    'vmms'
);

foreach ($Service in $GetServices.Keys) {
    $HypervService = $GetServices[$Service];
        Write-host $HypervService.metadata.DisplayName "($Service)" "Exit code:" $HypervService.configuration.ExitCode;
}
Hyper-V PowerShell Direct Service (vmicvmsession) Exit code: 1077
Hyper-V Heartbeat Service (vmicheartbeat) Exit code: 1077
Hyper-V Data Exchange Service (vmickvpexchange) Exit code: 1077
Hyper-V Host Compute Service (vmcompute) Exit code: 0
Hyper-V Remote Desktop Virtualization Service (vmicrdv) Exit code: 1077
Hyper-V Volume Shadow Copy Requestor (vmicvss) Exit code: 1077
Hyper-V Time Synchronization Service (vmictimesync) Exit code: 1077
Hyper-V Guest Service Interface (vmicguestinterface) Exit code: 1077
Hyper-V Guest Shutdown Service (vmicshutdown) Exit code: 1077
Hyper-V Virtual Machine Management (vmms) Exit code: 0

According to https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299- Exit code 1077 ERROR_SERVICE_NEVER_STARTED means that the service was never tried to start, which I believe is normal. Could you, please re-define unnecessary service detection in https://github.com/Icinga/icinga-powershell-hyperv/blob/838c86f4164dcf01dea514cfb1b1760d31f9bde3/plugins/Invoke-IcingaCheckHyperVHealth.psm1#L78 For example this line can be re-writed as

(([string]::IsNullOrEmpty($HypervService.configuration.ExitCode) -eq $FALSE) -And ($HypervService.configuration.ExitCode -ne 0 -And $HypervService.configuration.ExitCode -ne 1077) -And ($HypervService.configuration.Status.raw -ne $ProviderEnums.ServiceStatus.Running))
LordHepipud commented 3 years ago

I have never encountered this particular issue on systems using the Hyper-V plugins so far. I get the point for this, but I would not want to modify this state on a hardcoded base, because if for some reason a service is not started, but should be, noone would get a notification about this,

Anyone else having an oppinion on this?