Skip to content

Commit

Permalink
Merge pull request #225 from Icinga:feature/update_for_jea
Browse files Browse the repository at this point in the history
Feature: Updates Plugin module to work in JEA context

In order for the plugins to work in JEA context, we will have to get rid of all `ScriptBlocks` and replace them with native functions.
  • Loading branch information
LordHepipud authored Aug 24, 2021
2 parents 2f9cfb1 + f20f62a commit e4b1451
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 37 deletions.
1 change: 1 addition & 0 deletions doc/31-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#217](https://github.com/Icinga/icinga-powershell-plugins/issues/217) Adds feature for `Invoke-IcingaCheckPerfCounter` with new switch `-IgnoreEmptyChecks` to change the output from `UNKNOWN` to `OK`, in case no performance counters were found
* [#222](https://github.com/Icinga/icinga-powershell-plugins/pull/222) Replaces `Get-FileHash` with own implementation as `Get-IcingaFileHash`, to work with new JEA integration
* [#223](https://github.com/Icinga/icinga-powershell-plugins/pull/223) Removes the function `Get-IcingaServices`, as this function has been moved to the Icinga PowerShell Framework
* [#225](https://github.com/Icinga/icinga-powershell-plugins/pull/225) Adds support for plugins to work in JEA context

## 1.5.1 (2021-07-07)

Expand Down
22 changes: 9 additions & 13 deletions provider/enums/Icinga_ProviderEnums.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -966,25 +966,21 @@
}

[hashtable]$Stratum = @{
'UnspecifiedOrUnavailable' = 0;
'PrimaryReference' = 1;
'SecondaryReferenceNTPOrSNTP' = {$_ -ge 2 -and $_ -le 15};
'Reserved' = {$_ -gt 16};
'UnspecifiedOrUnavailable' = 0;
'PrimaryReference' = 1;
}

[hashtable]$StratumTxt = @{
0 = 'UnspecifiedOrUnavailable';
1 = 'PrimaryReference';
{$_ -ge 2 -and $_ -le 15} = 'SecondaryReferenceNTPOrSNTP';
{$_ -gt 16} = 'Reserved';
0 = 'UnspecifiedOrUnavailable';
1 = 'PrimaryReference';
}

[hashtable]$DeviceAccessName = @{
0 = 'Unknown';
1 = 'Readable';
2 = 'Writeable';
3 = 'Read/Write Supported';
4 = 'Write Once';
0 = 'Unknown';
1 = 'Readable';
2 = 'Writeable';
3 = 'Read/Write Supported';
4 = 'Write Once';
}

[hashtable]$DeviceAccess = @{
Expand Down
37 changes: 14 additions & 23 deletions provider/http/Get-IcingaCheckHTTPQuery.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,20 @@ function Get-IcingaCheckHTTPQuery()
} else {
# Defaults
if (Test-Numeric $HTTPInformation.StatusCode) {
switch ($HTTPInformation.StatusCode) {
{ $_ -eq $null } {
$Status = $IcingaEnums.IcingaExitCode.Unknown
};
{ $_ -lt 200 } { # < 200 Unknown
$Status = $IcingaEnums.IcingaExitCode.Unknown
}
{ $_ -ge 600 } { # >= 600 Unknown
$Status = $IcingaEnums.IcingaExitCode.Unknown
}
{ $_ -In 200..399 } { # 200-399 OK
$Status = $IcingaEnums.IcingaExitCode.OK
}
{ $_ -In 400..499 } { # 400-499 Warning
$Status = $IcingaEnums.IcingaExitCode.Warning
}
{ $_ -In 500..599 } { # 500-599 Critical
$Status = $IcingaEnums.IcingaExitCode.Critical
}
# Proprietary
Default {
$Status = $IcingaEnums.IcingaExitCode.Unknown
}
if ($HTTPInformation.StatusCode -eq $null) {
$Status = $IcingaEnums.IcingaExitCode.Unknown;
} elseif ($HTTPInformation.StatusCode -lt 200) { # < 200 Unknown
$Status = $IcingaEnums.IcingaExitCode.Unknown;
} elseif ($HTTPInformation.StatusCode -ge 600) { # >= 600 Unknown
$Status = $IcingaEnums.IcingaExitCode.Unknown;
} elseif ($HTTPInformation.StatusCode -In 200..399) { # 200-399 OK
$Status = $IcingaEnums.IcingaExitCode.OK;
} elseif ($HTTPInformation.StatusCode -In 400..499) { # 400-499 Warning
$Status = $IcingaEnums.IcingaExitCode.Warning;
} elseif ($HTTPInformation.StatusCode -In 500..599) { # 500-599 Critical
$Status = $IcingaEnums.IcingaExitCode.Critical;
} else {
$Status = $IcingaEnums.IcingaExitCode.Unknown; # Proprietary
}
} else {
$Status = $IcingaEnums.IcingaExitCode.Unknown;
Expand Down
1 change: 0 additions & 1 deletion provider/ntp/Get-IcingaNtpData.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ function Get-IcingaNtpData()
'LocalTime' = $LocalDateTime;
'SyncStatus' = $SyncStatus;
'Stratum' = $Stratum;
'StratumTxt' = $ProviderEnums.StratumTxt[$Stratum];
'Mode' = $Mode;
'ModeTxt' = $ProviderEnums.ClientModeName[$Mode];
};
Expand Down

0 comments on commit e4b1451

Please sign in to comment.