Skip to content

Commit 0ac1ac7

Browse files
committed
Fixes an exception for the windowseventlog feature of the Agent, in case it is not installed
1 parent e11a9fc commit 0ac1ac7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

doc/100-General/10-Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1313

1414
### Bugfixes
1515

16+
* [#752](https://github.com/Icinga/icinga-powershell-framework/pull/752) Fixes an exception for the windowseventlog feature of the Icinga Agent, in case it is not installed.
17+
1618
### Enhancements
1719

1820
## 1.13.0 Beta-1 (2024-08-30)

lib/core/icingaagent/writers/Write-IcingaAgentEventLogConfig.psm1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ function Write-IcingaAgentEventLogConfig()
2323
[string]$Severity = 'information'
2424
);
2525

26+
[string]$FilePath = (Join-Path -Path (Get-IcingaAgentConfigDirectory) -ChildPath 'features-available\windowseventlog.conf');
27+
28+
if ((Test-Path -Path $FilePath) -eq $FALSE) {
29+
Write-IcingaConsoleNotice 'Windows Eventlog configuration for the Icinga Agent was not written. Either the Icinga Agent is not installed or your installed version does not support this feature';
30+
return;
31+
}
32+
2633
$EventLogConf = New-Object System.Text.StringBuilder;
2734

2835
$EventLogConf.AppendLine('/**') | Out-Null;
@@ -33,6 +40,6 @@ function Write-IcingaAgentEventLogConfig()
3340
$EventLogConf.AppendLine([string]::Format(' severity = "{0}"', $Severity)) | Out-Null;
3441
$EventLogConf.Append('}') | Out-Null;
3542

36-
Write-IcingaFileSecure -File (Join-Path -Path (Get-IcingaAgentConfigDirectory) -ChildPath 'features-available\windowseventlog.conf') -Value $EventLogConf.ToString();
43+
Write-IcingaFileSecure -File $FilePath -Value $EventLogConf.ToString();
3744
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;
3845
}

0 commit comments

Comments
 (0)