Adds support to generate eventlog documentation for event ids

This commit is contained in:
Lord Hepipud 2020-03-28 18:58:14 +01:00
parent 9a2f3cd429
commit 21e1d127c5
3 changed files with 60 additions and 1 deletions

21
doc/20-Eventlog.md Normal file
View file

@ -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. |

View file

@ -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 = @()

View file

@ -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\');