From 564711c1b67dd6a59d4e41d0a25e374773d53940 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 13 Aug 2020 17:54:00 +0200 Subject: [PATCH] Improves plugin output on verbosity levels Fixes #99 --- doc/31-Changelog.md | 2 ++ lib/icinga/plugin/New-IcingaCheckPackage.psm1 | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 2391a2e..3be0d2d 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -22,6 +22,7 @@ Check Command configuration generated by Icinga for Windows 1.2.0 require Icinga ### Notes * Improved documentation for plenty of Cmdlets and functionality +* We have updated the handling for plugin outputs which will now only print `non Ok` values by using verbosity 0 on check plugin configuration and include `Ok` checks for packages with `non Ok` checks on verbosity 1. Additional details can be found on issue [#99](https://github.com/Icinga/icinga-powershell-framework/issues/99) * [#80](https://github.com/Icinga/icinga-powershell-framework/issues/80) Adds wrapper function `Get-IcingaWindowsInformation` for WMI and CIM calls to properly handle config/permission errors * [#93](https://github.com/Icinga/icinga-powershell-framework/issues/93) Adds PSScriptAnalyzer for improved and identical code quality @@ -34,6 +35,7 @@ Check Command configuration generated by Icinga for Windows 1.2.0 require Icinga * [#94](https://github.com/Icinga/icinga-powershell-framework/issues/94) Adds `Namespace` argument for Get-IcingaWindowsInformation for additional filtering * [#95](https://github.com/Icinga/icinga-powershell-framework/issues/95) Improves error handling for issues by using `Use-Icinga` initialising or by calling plugins which are not installed * [#98](https://github.com/Icinga/icinga-powershell-framework/issues/98) Adds support for SecureString as password argument on config generation +* [#99](https://github.com/Icinga/icinga-powershell-framework/issues/99) Improves plugin output with different verbosity settings ### Bugfixes diff --git a/lib/icinga/plugin/New-IcingaCheckPackage.psm1 b/lib/icinga/plugin/New-IcingaCheckPackage.psm1 index b85ed61..a987355 100644 --- a/lib/icinga/plugin/New-IcingaCheckPackage.psm1 +++ b/lib/icinga/plugin/New-IcingaCheckPackage.psm1 @@ -269,8 +269,14 @@ function New-IcingaCheckPackage() [hashtable]$MessageOrdering = @{}; foreach ($check in $this.checks) { - if ([int]$check.exitcode -eq $skipExitCode -And $skipExitCode -ne -1) { - continue; + if ($this.verbose -eq 0) { + if ([int]$check.exitcode -eq $skipExitCode) { + continue; + } + } elseif ($this.verbose -eq 1) { + if ([int]$check.exitcode -eq $skipExitCode -And $check.checkpackage) { + continue; + } } if ($MessageOrdering.ContainsKey($check.Name) -eq $FALSE) { @@ -296,7 +302,7 @@ function New-IcingaCheckPackage() } $Check | Add-Member -MemberType ScriptMethod -Name 'WriteAllOutput' -Value { - $this.PrintOutputMessageSorted($TRUE, -1); + $this.PrintOutputMessageSorted($TRUE, $IcingaEnums.IcingaExitCode.Ok); } $Check | Add-Member -MemberType ScriptMethod -Name 'PrintAllMessages' -Value { @@ -357,7 +363,7 @@ function New-IcingaCheckPackage() break; }; 1 { - # Include the Operator into the check package result + # Include the Operator into the check package result and OK checks of package break; }; Default {