Adds support for check objects not being added to summary header

This commit is contained in:
Lord Hepipud 2024-03-13 17:38:08 +01:00
parent 43370817af
commit 0c83f7a70b
4 changed files with 40 additions and 25 deletions

View file

@ -28,6 +28,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#690](https://github.com/Icinga/icinga-powershell-framework/pull/690) Adds automatic renewal of the `icingaforwindows.pfx` certificate for the REST-Api daemon in case the certificate is not yet present, valid or changed during the runtime of the daemon while also making the `icingaforwindows.pfx` mandatory for all installations, regardless of JEA being used or not
* [#692](https://github.com/Icinga/icinga-powershell-framework/pull/692) Renames `Restart-IcingaWindowsService` to `Restart-IcingaForWindows` and adds alias for backwards compatibility to start unifying the Icinga for Windows cmdlets
* [#693](https://github.com/Icinga/icinga-powershell-framework/pull/693) Adds new command `Restart-Icinga` to restart both, the Icinga Agent and Icinga for Windows
* [#694](https://github.com/Icinga/icinga-powershell-framework/pull/694) Adds support for check objects not being added to summary header
## 1.11.2 (tbd)

View file

@ -1,19 +1,20 @@
function New-IcingaCheck()
{
param(
[string]$Name = '',
$Value = $null,
$BaseValue = $null,
$Unit = '',
$MetricIndex = 'default',
$MetricName = '',
$MetricTemplate = '',
[string]$Minimum = '',
[string]$Maximum = '',
$ObjectExists = -1,
$Translation = $null,
[string]$LabelName = $null,
[switch]$NoPerfData = $FALSE
[string]$Name = '',
$Value = $null,
$BaseValue = $null,
$Unit = '',
$MetricIndex = 'default',
$MetricName = '',
$MetricTemplate = '',
[string]$Minimum = '',
[string]$Maximum = '',
$ObjectExists = -1,
$Translation = $null,
[string]$LabelName = $null,
[switch]$NoPerfData = $FALSE,
[switch]$NoHeaderReport = $FALSE
);
$IcingaCheck = New-IcingaCheckBaseObject;
@ -45,6 +46,8 @@ function New-IcingaCheck()
$IcingaCheck | Add-Member -MemberType NoteProperty -Name '__ThresholdObject' -Value $null;
$IcingaCheck | Add-Member -MemberType NoteProperty -Name '__TimeInterval' -Value $null;
$IcingaCheck.__SetNoHeaderReport($NoHeaderReport);
$IcingaCheck | Add-Member -MemberType ScriptMethod -Force -Name 'Compile' -Value {
$this.__ValidateThresholdInput();
if ($null -eq $this.__ThresholdObject) {

View file

@ -2,17 +2,18 @@ function New-IcingaCheckBaseObject()
{
$IcingaCheckBaseObject = New-Object -TypeName PSObject;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name 'Name' -Value '';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name 'Verbose' -Value 0;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckPerfData' -Value @{ };
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__Hidden' -Value $FALSE;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__Parent' -Value $IcingaCheckBaseObject;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__Indention' -Value 0;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__ErrorMessage' -Value '';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckState' -Value $IcingaEnums.IcingaExitCode.Ok;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckCommand' -Value '';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckOutput' -Value $null;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__ObjectType' -Value 'IcingaCheckBaseObject';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name 'Name' -Value '';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name 'Verbose' -Value 0;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckPerfData' -Value @{ };
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__Hidden' -Value $FALSE;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__SkipSummary' -Value $FALSE;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__Parent' -Value $IcingaCheckBaseObject;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__Indention' -Value 0;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__ErrorMessage' -Value '';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckState' -Value $IcingaEnums.IcingaExitCode.Ok;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckCommand' -Value '';
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__CheckOutput' -Value $null;
$IcingaCheckBaseObject | Add-Member -MemberType NoteProperty -Name '__ObjectType' -Value 'IcingaCheckBaseObject';
$IcingaCheckBaseObject | Add-Member -MemberType ScriptMethod -Name '__SetCheckCommand' -Value {
$CallStack = Get-PSCallStack;
@ -65,6 +66,16 @@ function New-IcingaCheckBaseObject()
$this.__Hidden = $Hidden;
}
$IcingaCheckBaseObject | Add-Member -MemberType ScriptMethod -Name '__NoHeaderReport' -Value {
return $this.__SkipSummary;
}
$IcingaCheckBaseObject | Add-Member -MemberType ScriptMethod -Name '__SetNoHeaderReport' -Value {
param ([bool]$SkipSummary);
$this.__SkipSummary = $SkipSummary;
}
$IcingaCheckBaseObject | Add-Member -MemberType ScriptMethod -Name '__GetName' -Value {
return $this.Name;
}

View file

@ -179,7 +179,7 @@ function New-IcingaCheckPackage()
$check.Compile();
if ($check.__IsHidden()) {
if ($check.__IsHidden() -Or $check.__NoHeaderReport()) {
continue;
}