Skip to content

Commit e50170d

Browse files
committed
Fixes disk health error for int to str enum conversion
1 parent 7502d44 commit e50170d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

doc/31-Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ documentation before upgrading to a new release.
77

88
Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-plugins/milestones?state=closed).
99

10+
# 1.11.0 (2023-05-31)
11+
12+
### Bugfixes
13+
14+
* [#342](https://github.com/Icinga/icinga-powershell-plugins/issues/342) Fixes an issue for disk health plugin, which can fail in some cases due to an invalid conversion from the MSFT output from int to string
15+
1016
## 1.10.1 (2022-12-20)
1117

1218
### Bugfixes

provider/disks/Get-IcingaPhysicalDiskInfo.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function Global:Get-IcingaPhysicalDiskInfo()
220220
'BusType',
221221
@{
222222
'value' = $disk.BusType;
223-
'name' = $ProviderEnums.DiskBusType[[int]$disk.BusType];
223+
'name' = (Get-IcingaProviderEnumData -Enum $ProviderEnums -Key 'DiskBusType' -Index $disk.BusType);
224224
}
225225
)
226226
$DiskInfo.Add('HealthStatus', $disk.HealthStatus);
@@ -229,11 +229,11 @@ function Global:Get-IcingaPhysicalDiskInfo()
229229

230230
foreach ($entry in $disk.OperationalStatus) {
231231
if (Test-Numeric $entry) {
232-
Add-IcingaHashtableItem -Hashtable $OperationalStatus -Key ([int]$entry) -Value ($ProviderEnums.DiskOperationalStatus[[int]$entry]) | Out-Null;
232+
Add-IcingaHashtableItem -Hashtable $OperationalStatus -Key ([int]$entry) -Value (Get-IcingaProviderEnumData -Enum $ProviderEnums -Key 'DiskOperationalStatus' -Index $entry) | Out-Null;
233233
} else {
234234
if ($ProviderEnums.DiskOperationalStatus.Values -Contains $entry) {
235235
foreach ($opStatus in $ProviderEnums.DiskOperationalStatus.Keys) {
236-
$opStatusValue = $ProviderEnums.DiskOperationalStatus[$opStatus];
236+
$opStatusValue = (Get-IcingaProviderEnumData -Enum $ProviderEnums -Key 'DiskOperationalStatus' -Index $opStatus);
237237
if ($opStatusValue.ToLower() -eq ([string]$entry).ToLower()) {
238238
Add-IcingaHashtableItem -Hashtable $OperationalStatus -Key ([int]$opStatus) -Value $entry | Out-Null;
239239
break;
@@ -280,8 +280,8 @@ function Global:Get-IcingaPhysicalDiskInfo()
280280
$DiskInfo.Add(
281281
'MediaType',
282282
@{
283-
'Value' = $disk.MediaType
284-
'Name' = ($ProviderEnums.DiskMediaType[[int]$disk.MediaType])
283+
'Value' = $disk.MediaType;
284+
'Name' = (Get-IcingaProviderEnumData -Enum $ProviderEnums -Key 'DiskMediaType' -Index $disk.MediaType);
285285
}
286286
);
287287

0 commit comments

Comments
 (0)