From 01b39ea514302be04287438557b58df42d363b17 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 23 Apr 2021 12:55:05 +0200 Subject: [PATCH] Supress other messages then plugin output --- doc/31-Changelog.md | 1 + icinga-powershell-framework.psm1 | 10 +++++++++- lib/icinga/plugin/Write-IcingaPluginOutput.psm1 | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 818ced5..6d43b88 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Enhancements +* [#228](https://github.com/Icinga/icinga-powershell-framework/issues/228) Adds feature to suppress any kind of console output except for plugin output and performance data * [#229](https://github.com/Icinga/icinga-powershell-framework/pull/229) CustomFields defined as `SecureString` are now set to `hidden` within the Icinga Director configuration basket - please read the [upgrading docs](30-upgrading-framework.md) carefully * [#234](https://github.com/Icinga/icinga-powershell-framework/pull/234) Adds support to allow custom exception lists for Icinga Exceptions, making it easier for different modules to ship their own exception messages * [#235](https://github.com/Icinga/icinga-powershell-framework/pull/235) Adds new Cmdlet `Show-IcingaEventLogAnalysis` to get a better overview on how many log entries are present within the EventLog based on hour, minute and day average/maximum for allowing a more dynamic configuration for `Invoke-IcingaCheckEventLog` diff --git a/icinga-powershell-framework.psm1 b/icinga-powershell-framework.psm1 index d03af69..0f81452 100644 --- a/icinga-powershell-framework.psm1 +++ b/icinga-powershell-framework.psm1 @@ -10,7 +10,7 @@ function Use-Icinga() { - param( + param ( [switch]$LibOnly = $FALSE, [switch]$Daemon = $FALSE, [switch]$DebugMode = $FALSE, @@ -20,6 +20,14 @@ function Use-Icinga() Disable-IcingaProgressPreference; if ($Minimal) { + if ($null -eq $global:Icinga) { + $global:Icinga = @{ }; + } + + if ($global:Icinga.ContainsKey('Minimal') -eq $FALSE) { + $global:Icinga.Add('Minimal', $TRUE); + } + # If we load the minimal Framework files, we have to ensure our enums are loaded Import-Module ([string]::Format('{0}\lib\icinga\exception\Icinga_IcingaExceptionEnums.psm1', $PSScriptRoot)) -Global; Import-Module ([string]::Format('{0}\lib\icinga\enums\Icinga_IcingaEnums.psm1', $PSScriptRoot)) -Global; diff --git a/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 b/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 index f45b6a1..21a1d05 100644 --- a/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 +++ b/lib/icinga/plugin/Write-IcingaPluginOutput.psm1 @@ -1,10 +1,13 @@ function Write-IcingaPluginOutput() { - param( + param ( $Output ); if ($global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) { + if ($null -ne $global:Icinga -And $global:Icinga.Minimal) { + Clear-Host; + } Write-IcingaConsolePlain $Output; } else { # New behavior with local thread separated results