Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#534](https://github.com/Icinga/icinga-powershell-framework/pull/534) Improves Icinga and Director configuration generator, by wrapping PowerShell arrays inside `@()` instead of simply writing them comma separated
* [#536](https://github.com/Icinga/icinga-powershell-framework/pull/536) Adds new function `Test-IcingaArrayFilter` for easier include and exclude filtering during plugin runtime and to allow filtering of array content for intended values only
* [#560](https://github.com/Icinga/icinga-powershell-framework/pull/560) Improves handling for Icinga Management Console which will now terminate itself during full uninstallation and restarts after updating the Icinga PowerShell Framework, to apply changes directly
* [#569](https://github.com/Icinga/icinga-powershell-framework/pull/569) Adds `-Include` and `-Exclude` filter for EventLog CLI parser, to only contain certain messages or exclude them from the output

## 1.9.2 (2022-06-03)

Expand Down
6 changes: 4 additions & 2 deletions lib/core/framework/Read-IcingaForWindowsLog.psm1
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
function Read-IcingaForWindowsLog()
{
param (
[array]$Source = @()
[array]$Source = @(),
[array]$Include = @(),
[array]$Exclude = @()
);

Read-IcingaWindowsEventLog -LogName 'Icinga for Windows' -Source $Source -MaxEntries 500;
Read-IcingaWindowsEventLog -LogName 'Icinga for Windows' -Source $Source -MaxEntries 500 -Include $Include -Exclude $Exclude;
}
8 changes: 7 additions & 1 deletion lib/core/framework/Read-IcingaWindowsEventLog.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ function Read-IcingaWindowsEventLog()
param (
[string]$LogName = 'Application',
[array]$Source = @(),
[array]$Include = @(),
[array]$Exclude = @(),
[int]$MaxEntries = 500
);

Expand All @@ -17,7 +19,7 @@ function Read-IcingaWindowsEventLog()
$MaxEvents = 40000;

while ($TRUE) {
[array]$IcingaEvents = Get-WinEvent -LogName $LogName -MaxEvents $MaxEvents -ErrorAction Stop;
[array]$IcingaEvents = Get-WinEvent -LogName $LogName -MaxEvents $MaxEvents -ErrorAction SilentlyContinue;
[int]$CurrentIndex = $MaxEntries;
[array]$CollectedEvents = @();

Expand All @@ -43,6 +45,10 @@ function Read-IcingaWindowsEventLog()
break;
}

if ((Test-IcingaArrayFilter -InputObject $event.Message -Include $Include -Exclude $Exclude) -eq $FALSE) {
continue;
}

$CollectedEvents += $event;
}

Expand Down
7 changes: 6 additions & 1 deletion lib/core/icingaagent/readers/Read-IcingaAgentLogFile.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
function Read-IcingaAgentLogFile()
{
param (
[array]$Include = @(),
[array]$Exclude = @()
);

if ((Test-IcingaAgentFeatureEnabled -Feature 'windowseventlog') -And ([version](Get-IcingaAgentVersion).Full) -ge (New-IcingaVersionObject -Version '2.13.0')) {

# Icinga 2.13.0 and beyond will log directly into the EventLog
Read-IcingaWindowsEventLog -LogName 'Application' -Source 'Icinga 2' -MaxEntries 500;
Read-IcingaWindowsEventLog -LogName 'Application' -Source 'Icinga 2' -MaxEntries 500 -Include $Include -Exclude $Exclude;
} else {
$Logfile = Join-Path -Path (Get-IcingaAgentLogDirectory) -ChildPath 'icinga2.log';
if ((Test-Path $Logfile) -eq $FALSE) {
Expand Down