Skip to content

Commit fad86f9

Browse files
authored
Merge pull request #744 from Icinga:feature/allows_setting_windowseventlog_config_for_agent
Feature: Adds cmdlet `Write-IcingaAgentEventLogConfig` to update eventlog severity and defaults to `warning`during installation and migration Adds cmdlet `Write-IcingaAgentEventLogConfig` to update eventlog severity and defaults to `warning`during installation and migration tasks while updating to Icinga for Windows v1.13.0
2 parents 6ffc7b7 + e84b511 commit fad86f9

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1919

2020
### Enhancements
2121

22+
* [#711](https://github.com/Icinga/icinga-powershell-framework/issues/711) Adds cmdlet `Write-IcingaAgentEventLogConfig` to update eventlog severity and defaults to `warning` during installation and migration
2223
* [#732](https://github.com/Icinga/icinga-powershell-framework/pull/732) Adds support for TLS 1.3 and improves startup response
2324
* [#735](https://github.com/Icinga/icinga-powershell-framework/pull/735) Adds support to provide occuring problem event id's for the Eventlog and corresponding acknowledgement id's, providing an indicator if certain issues are resolved or still present
2425
* [#739](https://github.com/Icinga/icinga-powershell-framework/pull/739) Adds support to check the encoding of files to ensure we can properly load them and throw errors for unsupported encoding

lib/core/framework/Invoke-IcingaForWindowsMigration.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ function Invoke-IcingaForWindowsMigration()
149149

150150
# Updates certificate renew task to handle changes made which now stores the Icinga CA inside the cert store
151151
Start-IcingaWindowsScheduledTaskRenewCertificate;
152+
# Ensure the Icinga Agent is not spamming the Application log by default
153+
Write-IcingaAgentEventLogConfig -Severity 'warning';
152154

153155
Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.13.0');
154156
}

lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ function Start-IcingaAgentInstallWizard()
750750
# First cleanup the system by removing all old Firewalls
751751
Enable-IcingaFirewall -IcingaPort $CAPort -Force;
752752
}
753+
# Ensure the Icinga Agent is not spamming the Application log by default
754+
Write-IcingaAgentEventLogConfig -Severity 'warning';
753755
Test-IcingaAgent;
754756
if ($InstallFrameworkService) {
755757
Restart-IcingaForWindows;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<#
2+
.SYNOPSIS
3+
Writes the Icinga Agent Event Log configuration.
4+
5+
.DESCRIPTION
6+
The Write-IcingaAgentEventLogConfig function is used to write the configuration for the Icinga Agent Event Log. It creates a configuration file with the specified severity level for the Windows Event Log Logger.
7+
8+
.PARAMETER Severity
9+
Specifies the severity level for the Windows Event Log Logger. Valid values are 'debug', 'notice', 'information', 'warning', and 'critical'. The default value is 'information'.
10+
11+
.EXAMPLE
12+
Write-IcingaAgentEventLogConfig -Severity 'warning'
13+
This example writes the Icinga Agent Event Log configuration with the severity level set to 'warning'.
14+
15+
.NOTES
16+
Please make sure to restart the Icinga Agent after applying any changes to the configuration.
17+
#>
18+
19+
function Write-IcingaAgentEventLogConfig()
20+
{
21+
param (
22+
[ValidateSet('debug', 'notice', 'information', 'warning', 'critical')]
23+
[string]$Severity = 'information'
24+
);
25+
26+
$EventLogConf = New-Object System.Text.StringBuilder;
27+
28+
$EventLogConf.AppendLine('/**') | Out-Null;
29+
$EventLogConf.AppendLine(' * The WindowsEventLogLogger type writes log information to the Windows Event Log.') | Out-Null;
30+
$EventLogConf.AppendLine(' */') | Out-Null;
31+
$EventLogConf.AppendLine('') | Out-Null;
32+
$EventLogConf.AppendLine('object WindowsEventLogLogger "windowseventlog" {') | Out-Null;
33+
$EventLogConf.AppendLine([string]::Format(' severity = "{0}"', $Severity)) | Out-Null;
34+
$EventLogConf.Append('}') | Out-Null;
35+
36+
Write-IcingaFileSecure -File (Join-Path -Path (Get-IcingaAgentConfigDirectory) -ChildPath 'features-available\windowseventlog.conf') -Value $EventLogConf.ToString();
37+
Write-IcingaConsoleNotice 'Windows Eventlog configuration has been written successfully to use severity level: {0} - Please restart the Icinga Agent to apply this change' -Objects $Severity;
38+
}

lib/core/installer/Start-IcingaForWindowsInstallation.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ function Start-IcingaForWindowsInstallation()
203203
Set-IcingaUserPermissions -IcingaUser $ServiceUser;
204204
Install-IcingaAgentBaseFeatures;
205205
Write-IcingaAgentApiConfig -Port $IcingaPort;
206+
# Ensure the Icinga Agent is not spamming the Application log by default
207+
Write-IcingaAgentEventLogConfig -Severity 'warning';
206208

207209
# Fixes an issue with the local Icinga for Windows listen port and the defined ports for communicating with the Icinga Parent/CA Nodes
208210
# This will check if we provided a custom port for the endpoints and use this one instead of the configured listen port if Icinga for Windows

0 commit comments

Comments
 (0)