Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adjust thresholds for certificate health #107

Merged
merged 5 commits into from
Mar 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions VMware.CloudFoundation.Reporting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -916,13 +916,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], "MMM dd HH:mm:ss yyyy 'GMT'", $null).ToUniversalTime()
bhumitra marked this conversation as resolved.
Show resolved Hide resolved
$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 @@ -960,6 +973,7 @@ Function Publish-CertificateHealth {
}
Export-ModuleMember -Function Publish-CertificateHealth


Function Publish-ConnectivityHealth {
<#
.SYNOPSIS
Expand Down