Skip to content

Commit e4b1451

Browse files
authored
Merge pull request #225 from Icinga:feature/update_for_jea
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.
2 parents 2f9cfb1 + f20f62a commit e4b1451

File tree

4 files changed

+24
-37
lines changed

4 files changed

+24
-37
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2121
* [#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
2222
* [#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
2323
* [#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
24+
* [#225](https://github.com/Icinga/icinga-powershell-plugins/pull/225) Adds support for plugins to work in JEA context
2425

2526
## 1.5.1 (2021-07-07)
2627

provider/enums/Icinga_ProviderEnums.psm1

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -966,25 +966,21 @@
966966
}
967967

968968
[hashtable]$Stratum = @{
969-
'UnspecifiedOrUnavailable' = 0;
970-
'PrimaryReference' = 1;
971-
'SecondaryReferenceNTPOrSNTP' = {$_ -ge 2 -and $_ -le 15};
972-
'Reserved' = {$_ -gt 16};
969+
'UnspecifiedOrUnavailable' = 0;
970+
'PrimaryReference' = 1;
973971
}
974972

975973
[hashtable]$StratumTxt = @{
976-
0 = 'UnspecifiedOrUnavailable';
977-
1 = 'PrimaryReference';
978-
{$_ -ge 2 -and $_ -le 15} = 'SecondaryReferenceNTPOrSNTP';
979-
{$_ -gt 16} = 'Reserved';
974+
0 = 'UnspecifiedOrUnavailable';
975+
1 = 'PrimaryReference';
980976
}
981977

982978
[hashtable]$DeviceAccessName = @{
983-
0 = 'Unknown';
984-
1 = 'Readable';
985-
2 = 'Writeable';
986-
3 = 'Read/Write Supported';
987-
4 = 'Write Once';
979+
0 = 'Unknown';
980+
1 = 'Readable';
981+
2 = 'Writeable';
982+
3 = 'Read/Write Supported';
983+
4 = 'Write Once';
988984
}
989985

990986
[hashtable]$DeviceAccess = @{

provider/http/Get-IcingaCheckHTTPQuery.psm1

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,20 @@ function Get-IcingaCheckHTTPQuery()
100100
} else {
101101
# Defaults
102102
if (Test-Numeric $HTTPInformation.StatusCode) {
103-
switch ($HTTPInformation.StatusCode) {
104-
{ $_ -eq $null } {
105-
$Status = $IcingaEnums.IcingaExitCode.Unknown
106-
};
107-
{ $_ -lt 200 } { # < 200 Unknown
108-
$Status = $IcingaEnums.IcingaExitCode.Unknown
109-
}
110-
{ $_ -ge 600 } { # >= 600 Unknown
111-
$Status = $IcingaEnums.IcingaExitCode.Unknown
112-
}
113-
{ $_ -In 200..399 } { # 200-399 OK
114-
$Status = $IcingaEnums.IcingaExitCode.OK
115-
}
116-
{ $_ -In 400..499 } { # 400-499 Warning
117-
$Status = $IcingaEnums.IcingaExitCode.Warning
118-
}
119-
{ $_ -In 500..599 } { # 500-599 Critical
120-
$Status = $IcingaEnums.IcingaExitCode.Critical
121-
}
122-
# Proprietary
123-
Default {
124-
$Status = $IcingaEnums.IcingaExitCode.Unknown
125-
}
103+
if ($HTTPInformation.StatusCode -eq $null) {
104+
$Status = $IcingaEnums.IcingaExitCode.Unknown;
105+
} elseif ($HTTPInformation.StatusCode -lt 200) { # < 200 Unknown
106+
$Status = $IcingaEnums.IcingaExitCode.Unknown;
107+
} elseif ($HTTPInformation.StatusCode -ge 600) { # >= 600 Unknown
108+
$Status = $IcingaEnums.IcingaExitCode.Unknown;
109+
} elseif ($HTTPInformation.StatusCode -In 200..399) { # 200-399 OK
110+
$Status = $IcingaEnums.IcingaExitCode.OK;
111+
} elseif ($HTTPInformation.StatusCode -In 400..499) { # 400-499 Warning
112+
$Status = $IcingaEnums.IcingaExitCode.Warning;
113+
} elseif ($HTTPInformation.StatusCode -In 500..599) { # 500-599 Critical
114+
$Status = $IcingaEnums.IcingaExitCode.Critical;
115+
} else {
116+
$Status = $IcingaEnums.IcingaExitCode.Unknown; # Proprietary
126117
}
127118
} else {
128119
$Status = $IcingaEnums.IcingaExitCode.Unknown;

provider/ntp/Get-IcingaNtpData.psm1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ function Get-IcingaNtpData()
123123
'LocalTime' = $LocalDateTime;
124124
'SyncStatus' = $SyncStatus;
125125
'Stratum' = $Stratum;
126-
'StratumTxt' = $ProviderEnums.StratumTxt[$Stratum];
127126
'Mode' = $Mode;
128127
'ModeTxt' = $ProviderEnums.ClientModeName[$Mode];
129128
};

0 commit comments

Comments
 (0)