diff --git a/doc/20-Eventlog.md b/doc/20-Eventlog.md new file mode 100644 index 0000000..25ded22 --- /dev/null +++ b/doc/20-Eventlog.md @@ -0,0 +1,21 @@ +# Framework Eventlog Documentation + +Below you will find a list of EventId's which are exported by this module. The short and detailed message are both written directly into the eventlog. This documentation shall simply provide a summary of available EventId's + +## Event Id 1000 + +| Category | Short Message | Detailed Message | +| --- | --- | --- | +| Information | Generic debug message issued by the Framework or its components | The Framework or is components can issue generic debug message in case the debug log is enabled. Please ensure to disable it, if not used. You can do so with the command "Disable-IcingaFrameworkDebugMode" | + +## Event Id 1500 + +| Category | Short Message | Detailed Message | +| --- | --- | --- | +| Error | Failed to securely establish a communiation between this server and the client | A client connection could not be established to this server. This issue is mostly caused by using Self-Signed/Icinga 2 Agent certificates for the server and the client not trusting the certificate. To resolve this issue, either use trusted certificates signed by your trusted CA or setup the client to accept untrusted certificates | + +## Event Id 1501 + +| Category | Short Message | Detailed Message | +| --- | --- | --- | +| Error | Client connection was interrupted because of invalid SSL stream | A client connection was terminated by the Framework because no secure SSL handshake could be established. This issue in general is followed by EventId 1500. | diff --git a/icinga-powershell-framework.psd1 b/icinga-powershell-framework.psd1 index 61e83b7..6f77fe1 100644 --- a/icinga-powershell-framework.psd1 +++ b/icinga-powershell-framework.psd1 @@ -7,7 +7,7 @@ Copyright = '(c) 2020 Icinga GmbH | MIT' Description = 'Icinga for Windows module which allows to entirely monitor the Windows Host system.' PowerShellVersion = '4.0' - FunctionsToExport = @( 'Use-Icinga', 'Import-IcingaLib', 'Publish-IcingaModuleManifests', 'Get-IcingaPluginDir', 'Get-IcingaCustomPluginDir', 'Get-IcingaCacheDir', 'Get-IcingaPowerShellConfigDir', 'Get-IcingaFrameworkRootPath', 'Get-IcingaPowerShellModuleFile' ) + FunctionsToExport = @( 'Use-Icinga', 'Import-IcingaLib', 'Publish-IcingaModuleManifests', 'Publish-IcingaEventlogDocumentation', 'Get-IcingaPluginDir', 'Get-IcingaCustomPluginDir', 'Get-IcingaCacheDir', 'Get-IcingaPowerShellConfigDir', 'Get-IcingaFrameworkRootPath', 'Get-IcingaPowerShellModuleFile' ) CmdletsToExport = @() VariablesToExport = '*' AliasesToExport = @() diff --git a/icinga-powershell-framework.psm1 b/icinga-powershell-framework.psm1 index 1e15d88..27b0b7d 100644 --- a/icinga-powershell-framework.psm1 +++ b/icinga-powershell-framework.psm1 @@ -190,6 +190,44 @@ function Publish-IcingaModuleManifests() Set-Content -Path $PSDFile -Value $NewContent; } +function Publish-IcingaEventlogDocumentation() +{ + param( + [string]$Namespace, + [string]$OutFile + ); + + [string]$DocContent = [string]::Format( + '# {0} Eventlog Documentation', + $Namespace + ); + $DocContent += New-IcingaNewLine; + $DocContent += New-IcingaNewLine; + $DocContent += "Below you will find a list of EventId's which are exported by this module. The short and detailed message are both written directly into the eventlog. This documentation shall simply provide a summary of available EventId's"; + + $SortedArray = $IcingaEventLogEnums[$Namespace].Keys.GetEnumerator() | Sort-Object; + + foreach ($entry in $SortedArray) { + $entry = $IcingaEventLogEnums[$Namespace][$entry]; + + $DocContent = [string]::Format( + '{0}{2}{2}## Event Id {1}{2}{2}| Category | Short Message | Detailed Message |{2}| --- | --- | --- |{2}| {3} | {4} | {5} |', + $DocContent, + $entry.EventId, + (New-IcingaNewLine), + $entry.EntryType, + $entry.Message, + $entry.Details + ); + } + + if ([string]::IsNullOrEmpty($OutFile)) { + Write-Host $DocContent; + } else { + Set-Content -Path $OutFile -Value $DocContent; + } +} + function Get-IcingaPluginDir() { return (Join-Path -Path $PSScriptRoot -ChildPath 'lib\plugins\');