-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #744 from Icinga:feature/allows_setting_windowseve…
…ntlog_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
- Loading branch information
Showing
5 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
lib/core/icingaagent/writers/Write-IcingaAgentEventLogConfig.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<# | ||
.SYNOPSIS | ||
Writes the Icinga Agent Event Log configuration. | ||
.DESCRIPTION | ||
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. | ||
.PARAMETER Severity | ||
Specifies the severity level for the Windows Event Log Logger. Valid values are 'debug', 'notice', 'information', 'warning', and 'critical'. The default value is 'information'. | ||
.EXAMPLE | ||
Write-IcingaAgentEventLogConfig -Severity 'warning' | ||
This example writes the Icinga Agent Event Log configuration with the severity level set to 'warning'. | ||
.NOTES | ||
Please make sure to restart the Icinga Agent after applying any changes to the configuration. | ||
#> | ||
|
||
function Write-IcingaAgentEventLogConfig() | ||
{ | ||
param ( | ||
[ValidateSet('debug', 'notice', 'information', 'warning', 'critical')] | ||
[string]$Severity = 'information' | ||
); | ||
|
||
$EventLogConf = New-Object System.Text.StringBuilder; | ||
|
||
$EventLogConf.AppendLine('/**') | Out-Null; | ||
$EventLogConf.AppendLine(' * The WindowsEventLogLogger type writes log information to the Windows Event Log.') | Out-Null; | ||
$EventLogConf.AppendLine(' */') | Out-Null; | ||
$EventLogConf.AppendLine('') | Out-Null; | ||
$EventLogConf.AppendLine('object WindowsEventLogLogger "windowseventlog" {') | Out-Null; | ||
$EventLogConf.AppendLine([string]::Format(' severity = "{0}"', $Severity)) | Out-Null; | ||
$EventLogConf.Append('}') | Out-Null; | ||
|
||
Write-IcingaFileSecure -File (Join-Path -Path (Get-IcingaAgentConfigDirectory) -ChildPath 'features-available\windowseventlog.conf') -Value $EventLogConf.ToString(); | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters