Skip to content

Commit

Permalink
feat: adjust thresholds for certificate health (#107)
Browse files Browse the repository at this point in the history
- Updates `Publish-CertificateHealth` with thresholds based on certificate expiration.
- Updates `Publish-CertificateHealth` to include an "Expires In (Days)" column.
- Updates `Publish-CertificateHealth` to include ESXi host certificates.
- Bumps the module version to v2.0.0.1003.
- Updates `CHANGELOG.md`.

Signed-off-by: bhumitra nagar <[email protected]>
Co-authored-by: Ryan Johnson <[email protected]>
  • Loading branch information
bhumitra and Ryan Johnson authored Mar 29, 2023
1 parent b4a34f1 commit 77df666
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

> Release Date: Unreleased
Enhancement:
- Updates `Publish-CertificateHealth` with thresholds based on certificate expiration. [GH-107](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/107)
- Updates `Publish-CertificateHealth` to include an "Expires In (Days)" column. [GH-107](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/107)
- Updates `Publish-CertificateHealth` to include ESXi host certificates. [GH-107](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/107)

Refactor:
- Updates `Request-SoSHealthJson` to use the API to retrieve the SoS Health Summary JSON results. Removes the requirement to provide the SDDC Manager appliance `root` password in the `Invoke-VcfHealthReport` cmdlet. [GH-102](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/102), [GH-110](https://github.com/vmware/powershell-module-for-vmware-cloud-foundation-reporting/pull/110)

Expand Down
2 changes: 1 addition & 1 deletion VMware.CloudFoundation.Reporting.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = '.\VMware.CloudFoundation.Reporting.psm1'

# Version number of this module.
ModuleVersion = '2.0.0.1002'
ModuleVersion = '2.0.0.1003'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
18 changes: 16 additions & 2 deletions VMware.CloudFoundation.Reporting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1010,13 +1010,26 @@ Function Publish-CertificateHealth {
if (($jsonInputData | Measure-Object).Count -lt 1) {
Write-Warning 'Certificate Status data not found in the JSON file: SKIPPED'
} else {
$jsonInputData.PSObject.Properties.Remove('ESXI')
foreach ($component in $jsonInputData.PsObject.Properties.Value) {
foreach ($element in $component.PsObject.Properties.Value) {
$elementObject = New-Object -TypeName psobject
$elementObject | Add-Member -NotePropertyName 'Component' -NotePropertyValue ($element.area -Split (':'))[0].Trim()
$elementObject | Add-Member -NotePropertyName 'Resource' -NotePropertyValue ($element.area -Split (':'))[-1].Trim()
$elementObject | Add-Member -NotePropertyName 'Alert' -NotePropertyValue $element.alert
if ($element.title -and $element.title -notcontains "-") {
$current = [DateTime]::Now
$expiry = [DateTime]::ParseExact(($element.title[2] -replace '\s+', ' '), "MMM d HH:mm:ss yyyy 'GMT'", $null).ToUniversalTime()
$expires_in = ($expiry - $current).Days
$alert = "GREEN"
if ([int]$expires_in -le 15) {
$alert = "RED"
} elseif ([int]$expires_in -le 30) {
$alert = "YELLOW"
}
$elementObject | Add-Member -NotePropertyName 'Expires In (Days)' -NotePropertyValue $expires_in
$elementObject | Add-Member -NotePropertyName 'Alert' -NotePropertyValue $alert
} else {
$elementObject | Add-Member -NotePropertyName 'Alert' -NotePropertyValue $element.alert
}
$elementObject | Add-Member -NotePropertyName 'Message' -NotePropertyValue $element.message
if ($PsBoundParameters.ContainsKey('failureOnly')) {
if (($element.status -eq 'FAILED')) {
Expand Down Expand Up @@ -1054,6 +1067,7 @@ Function Publish-CertificateHealth {
}
Export-ModuleMember -Function Publish-CertificateHealth


Function Publish-ConnectivityHealth {
<#
.SYNOPSIS
Expand Down

0 comments on commit 77df666

Please sign in to comment.