Skip to content

Commit 2f281b8

Browse files
authored
Merge branch 'master' into feature/icinga2_plain_config_generator
2 parents 3c82757 + 405babc commit 2f281b8

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

doc/31-Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2222
* [#134](https://github.com/Icinga/icinga-powershell-framework/pull/134) Adds Cmdlet `Test-IcingaWindowsInformation` to check if a WMI class exist and if we can fetch data from it. In addition we add support for binary value comparison with the new Cmdlet `Test-IcingaBinaryOperator`
2323
* [#142](https://github.com/Icinga/icinga-powershell-framework/pull/142) **Experimental:** Adds feature to cache the Framework code into a single file to speed up the entire loading process, mitigating the impact on performance on systems with few CPU cores. You enable disables this feature by using `Enable-IcingaFrameworkCodeCache` and `Disable-IcingaFrameworkCodeCache`. Updating the cache is done with `Write-IcingaFrameworkCodeCache`
2424
* [#149](https://github.com/Icinga/icinga-powershell-framework/pull/149) Adds support to add Wmi permissions for a specific user and namespace with `Add-IcingaWmiPermissions`. In addition you can remove users from Wmi namespaces by using `Remove-IcingaWmiPermissions`
25+
* [#153](https://github.com/Icinga/icinga-powershell-framework/pull/153) Adds support to add a knowledge base id to `Exit-IcingaThrowException` for easier referencing. This should mostly be used for custom messages, as we should track the main knowledge base id's inside the messages directly. Native messages should be split in a hashtable with a `Message` and `IWKB` key
2526
* [#155](https://github.com/Icinga/icinga-powershell-framework/pull/155) Adds support to write all objects collected by `Get-IcingaWindowsInformation` into the Windows EventLog in case the debug output for the Icinga PowerShell Framework is enabled.
2627
* [#162](https://github.com/Icinga/icinga-powershell-framework/pull/162) Adds feature to test the length of plugin custom variables during config generation and throws error in case the total length is bigger than 64 digits, as imports into the Icinga Director by using baskets is not possible otherwise
2728
* [#163](https://github.com/Icinga/icinga-powershell-framework/pull/163) Adds native support for writing Icinga 2 configuration for plugins and allows to easy publish new configurations for modules with the new Cmdlet `Publish-IcingaPluginConfiguration`
29+
* [#164](https://github.com/Icinga/icinga-powershell-framework/pull/164) Adds `exit` after calling `icinga` on Windows Terminal integration to ensure the shell will close in case the Icinga shell is closed
2830

2931
### Bugfixes
3032

doc/icingaintegration/50-Windows-Terminal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To install the Icinga Shell as native shell in your Windows Terminal dropdown, s
1616

1717
"guid": "{fcd7a805-a41b-49f9-afee-9d17a2b76d42}",
1818
"name": "Icinga",
19-
"commandline" : "powershell.exe -noe -c \"&{ icinga }\"",
19+
"commandline" : "powershell.exe -noe -c \"&{ icinga; exit }\"",
2020
"hidden": false,
2121
"icon" : "ms-appdata:///roaming/icingawhite.png",
2222

lib/icinga/exception/Exit-IcingaThrowException.psm1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ function Exit-IcingaThrowException()
44
[string]$InputString,
55
[string]$StringPattern,
66
[string]$CustomMessage,
7-
[string]$ExceptionThrown,
7+
$ExceptionThrown,
88
[ValidateSet('Permission', 'Input', 'Configuration', 'Connection', 'Unhandled', 'Custom')]
99
[string]$ExceptionType = 'Unhandled',
10+
[string]$KnowledgeBaseId,
1011
[switch]$Force
1112
);
1213

@@ -49,6 +50,12 @@ function Exit-IcingaThrowException()
4950
}
5051

5152
[string]$ExceptionName = '';
53+
[string]$ExceptionIWKB = $KnowledgeBaseId;
54+
55+
if ($ExceptionThrown -is [hashtable]) {
56+
$ExceptionIWKB = $ExceptionThrown.IWKB;
57+
$ExceptionThrown = $ExceptionThrown.Message;
58+
}
5259

5360
if ($null -ne $ExceptionMessageLib) {
5461
foreach ($definedError in $ExceptionMessageLib.Keys) {
@@ -67,15 +74,24 @@ function Exit-IcingaThrowException()
6774
);
6875
}
6976

70-
$OutputMessage = '{0}: Icinga {5} Error was thrown: {3}: {4}{1}{1}{2}';
77+
if ([string]::IsNullOrEmpty($ExceptionIWKB) -eq $FALSE) {
78+
$ExceptionIWKB = [string]::Format(
79+
'{0}{0}Further details can be found on the Icinga for Windows Knowledge base: https://icinga.com/docs/windows/latest/doc/knowledgebase/{1}',
80+
(New-IcingaNewLine),
81+
$ExceptionIWKB
82+
);
83+
}
84+
85+
$OutputMessage = '{0}: Icinga {6} Error was thrown: {4}: {5}{2}{2}{3}{1}';
7186
if ([string]::IsNullOrEmpty($CustomMessage) -eq $TRUE) {
72-
$OutputMessage = '{0}: Icinga {5} Error was thrown: {3}{1}{1}{2}{4}';
87+
$OutputMessage = '{0}: Icinga {6} Error was thrown: {4}{2}{2}{3}{5}{1}';
7388
}
7489

7590
$OutputMessage = [string]::Format(
7691
$OutputMessage,
7792
$IcingaEnums.IcingaExitCodeText.($IcingaEnums.IcingaExitCode.Unknown),
78-
"`r`n",
93+
$ExceptionIWKB,
94+
(New-IcingaNewLine),
7995
$ExceptionThrown,
8096
$ExceptionName,
8197
$CustomMessage,

lib/icinga/exception/Icinga_IcingaExceptionEnums.psm1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
[hashtable]$Permission = @{
88
PerformanceCounter = 'A Plugin failed to fetch Performance Counter information. This may be caused when the used Service User is not permitted to access these information. To fix this, please add the User the Icinga Agent is running on into the "Performance Log Users" group and restart the service.';
99
CacheFolder = "A plugin failed to write new data into the configured cache directory. Please update the permissions of this folder to allow write access for the user the Icinga Service is running with or use another folder as cache directory.";
10-
CimInstance = 'The user you are running this command as does not have permission to access the requested Cim-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch for the Class/Namespace mentioned above and add the permission "Remote enable". Further details can be found here: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc771551(v=ws.11)';
11-
WMIObject = 'The user you are running this command as does not have permission to access the requested Wmi-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch for the Class/Namespace mentioned above and add the permission "Remote enable". Further details can be found here: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/cc771551(v=ws.11)';
10+
CimInstance = @{
11+
'Message' = 'The user you are running this command as does not have permission to access the requested Cim-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch for the Class/Namespace mentioned above and add the permission "Remote enable".';
12+
'IWKB' = 'IWKB000001';
13+
}
14+
WMIObject = @{
15+
'Message' = 'The user you are running this command as does not have permission to access the requested Wmi-Object. To fix this, please add the user the Agent is running with to the "Remote Management Users" groups and grant access to the WMI branch for the Class/Namespace mentioned above and add the permission "Remote enable".';
16+
'IWKB' = 'IWKB000001';
17+
}
1218
WindowsUpdate = 'The user you are running this command as does not have permission to access the Windows Update ComObject "Microsoft.Update.Session". In order to fetch currently installed and pending updates, please grant the user the required permissions for fetching this information.';
1319
};
1420

@@ -20,7 +26,7 @@
2026
MultipleUnitUsage = 'Failed to convert your Icinga threshold units as you were trying to convert values with a different type of unit category. This feature only supports the conversion of one unit category. For example you can not convert 20MB:10d in the same call, as size and time units are not compatible.';
2127
CimClassNameUnknown = 'The provided class name you try to fetch with Get-CimInstance is not known on this system.';
2228
WmiObjectClassUnknown = 'The provided class name you try to fetch with Get-WmiObject is not known on this system.';
23-
MSSQLCredentialHandling = 'The connection to MSSQL was not possbible because your login credential was not correct.';
29+
MSSQLCredentialHandling = 'The connection to MSSQL was not possible because your login credential was not correct.';
2430
MSSQLCommandMissing = 'Failed to build a SQL query'
2531
};
2632

0 commit comments

Comments
 (0)