mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-15 16:48:40 -05:00
Fixes Icinga for Windows being stuck while fetching service information if other services block CIM requests
This commit is contained in:
parent
fa7e729308
commit
aa5c06bbd6
2 changed files with 54 additions and 17 deletions
|
|
@ -17,6 +17,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
* [#781](https://github.com/Icinga/icinga-powershell-framework/issues/781) Fixes Icinga for Windows being stuck during installation while fetching service information over CIM-Instances, if other services are frozen, blocking the CIM-Request
|
||||||
* [#784](https://github.com/Icinga/icinga-powershell-framework/issues/784) Fixes Icinga for Windows threshold comparison which wrongly compared warning/critical thresholds for non-range values (like Match)
|
* [#784](https://github.com/Icinga/icinga-powershell-framework/issues/784) Fixes Icinga for Windows threshold comparison which wrongly compared warning/critical thresholds for non-range values (like Match)
|
||||||
* [#785](https://github.com/Icinga/icinga-powershell-framework/issues/785) Fixes Icinga for Windows freezing during loading in case the `config.json` is empty
|
* [#785](https://github.com/Icinga/icinga-powershell-framework/issues/785) Fixes Icinga for Windows freezing during loading in case the `config.json` is empty
|
||||||
* [#786](https://github.com/Icinga/icinga-powershell-framework/issues/786) Fixes Icinga for Windows installer to always force the installation of the service, to ensure it is present
|
* [#786](https://github.com/Icinga/icinga-powershell-framework/issues/786) Fixes Icinga for Windows installer to always force the installation of the service, to ensure it is present
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,66 @@
|
||||||
function Get-IcingaServices()
|
function Get-IcingaServices()
|
||||||
{
|
{
|
||||||
param (
|
param (
|
||||||
[array]$Service,
|
[array]$Service = @(),
|
||||||
[array]$Exclude = @()
|
[array]$Exclude = @()
|
||||||
);
|
);
|
||||||
|
|
||||||
$ServiceInformation = Get-Service;
|
$ServiceInformation = Get-Service;
|
||||||
$ServiceWmiInfo = $null;
|
$ServiceWmiInfo = $null;
|
||||||
|
$ServiceFilter = New-Object System.Text.StringBuilder;
|
||||||
|
|
||||||
if ($Service.Count -eq 0) {
|
if ($Service.Count -gt 0) {
|
||||||
$ServiceWmiInfo = Get-IcingaWindowsInformation Win32_Service;
|
$ServiceFilter.Append('(') | Out-Null;
|
||||||
} else {
|
|
||||||
try {
|
foreach ($svc in $Service) {
|
||||||
$ServiceWmiInfo = Get-IcingaWindowsInformation Win32_Service |
|
if ($ServiceFilter.Length -gt 1) {
|
||||||
ForEach-Object {
|
$ServiceFilter.Append(' OR ') | Out-Null;
|
||||||
foreach ($svc in $Service) {
|
}
|
||||||
if ($_.Name -Like $svc) {
|
|
||||||
return $_;
|
$ServiceFilter.Append(
|
||||||
}
|
[string]::Format(
|
||||||
}
|
'Name LIKE "{0}"',
|
||||||
} | Select-Object StartName, Name, ExitCode, StartMode, PathName;
|
$svc.Replace('*', '%')
|
||||||
} catch {
|
)
|
||||||
Exit-IcingaThrowException -InputString $_.Exception.Message -StringPattern 'wildcard' -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.RegexError;
|
) | Out-Null;
|
||||||
Exit-IcingaThrowException -CustomMessage $_.Exception.Message -ExceptionType 'Input' -ExceptionThrown $_.Exception.Message;
|
|
||||||
return $null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ServiceFilter.Append(')') | Out-Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Exclude.Count -gt 0) {
|
||||||
|
if ($ServiceFilter.Length -gt 0) {
|
||||||
|
$ServiceFilter.Append(' AND (') | Out-Null;
|
||||||
|
} else {
|
||||||
|
$ServiceFilter.Append('(') | Out-Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[bool]$First = $TRUE;
|
||||||
|
|
||||||
|
foreach ($svc in $Exclude) {
|
||||||
|
if ($First -eq $FALSE) {
|
||||||
|
$ServiceFilter.Append(' AND ') | Out-Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$First = $FALSE;
|
||||||
|
|
||||||
|
$ServiceFilter.Append(
|
||||||
|
[string]::Format(
|
||||||
|
'NOT Name LIKE "{0}"',
|
||||||
|
$svc.Replace('*', '%')
|
||||||
|
)
|
||||||
|
) | Out-Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ServiceFilter.Append(')') | Out-Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$ServiceWmiInfo = Get-IcingaWindowsInformation -ClassName Win32_Service -Filter $ServiceFilter.ToString() | Select-Object StartName, Name, ExitCode, StartMode, PathName;
|
||||||
|
} catch {
|
||||||
|
Exit-IcingaThrowException -InputString $_.Exception.Message -StringPattern 'wildcard' -ExceptionType 'Input' -ExceptionThrown $IcingaExceptions.Inputs.RegexError;
|
||||||
|
Exit-IcingaThrowException -CustomMessage $_.Exception.Message -ExceptionType 'Input' -ExceptionThrown $_.Exception.Message;
|
||||||
|
return $null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($null -eq $ServiceInformation) {
|
if ($null -eq $ServiceInformation) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue