-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add support to show skipped or failed checks as warning / errors in the HTML report #146
Comments
This is a good idea. I think it might be good to have a summary of the errors observed in the report which could come from the log. |
This might be accomplished by updating the For example, display an error message in the output HTML if the For example: Function Publish-ServiceHealth {
<#
.SYNOPSIS
Formats the Service Health data from the SoS JSON output.
.DESCRIPTION
The Publish-ServiceHealth cmdlet formats the Service Health data from the SoS JSON output and publishes it as
either a standard PowerShell object or an HTML object.
.EXAMPLE
Publish-ServiceHealth -json <file-name>
This example extracts and formats the Service Health data as a PowerShell object from the JSON file.
.EXAMPLE
Publish-ServiceHealth -json <file-name> -html
This example extracts and formats the Service Health data as an HTML object from the JSON file.
.EXAMPLE
Publish-ServiceHealth -json <file-name> -failureOnly
This example extracts and formats the Service Health data as a PowerShell object from the JSON file for only the failed items.
.PARAMETER json
The path to the JSON file containing the SoS Health Summary data.
.PARAMETER html
Specifies that the output should be formatted as an HTML object.
.PARAMETER failureOnly
Specifies that the output should only contain failed items.
#>
Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$json,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$html,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly
)
Try {
if (!(Test-Path -Path $json)) {
$errorMessage = "Unable to find JSON file ($json): PRE_VALIDATION_FAILED"
Write-Error $errorMessage
Break
} else {
$targetContent = Get-Content $json | ConvertFrom-Json
}
$outputObject = New-Object System.Collections.ArrayList
$inputData = $targetContent.'Services' # Extract Data from the provided SOS JSON
if (($inputData | Measure-Object).Count -lt 1) {
$warnMessage = "Services data not found in the JSON file ($json): SKIPPED"
Write-Warning $warnMessage -WarningAction Stop
Break
} else {
foreach ($component in $inputData) {
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 'Service Name' -NotePropertyValue $element.title.ToUpper()
$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')) {
$outputObject += $elementObject
}
} else {
$outputObject += $elementObject
}
}
}
}
if ($PsBoundParameters.ContainsKey('html')) {
if (($inputData | Measure-Object).Count -gt 0) {
if ($outputObject.Count -eq 0) { $addNoIssues = $true }
if ($addNoIssues) {
$outputObject = $outputObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '<a id="general-service"></a><h3>Service Health Status</h3>' -PostContent '<p>No issues found.</p>'
} else {
$outputObject = $outputObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '<a id="general-service"></a><h3>Service Health Status</h3>' -As Table
}
$outputObject = Convert-CssClass -htmldata $outputObject
} else {
$outputObject = $outputObject | Sort-Object Component, Resource | ConvertTo-Html -Fragment -PreContent '<a id="general-service"></a><h3>Service Health Status</h3>' -PostContent '<p><strong>WARNING</strong>: Services data not found.</p>' -As Table
}
$outputObject
} else {
$outputObject | Sort-Object Component, Resource
}
} Catch {
if ($PsBoundParameters.ContainsKey('html')) {
if ($errorMessage) {
$outputObject = "<p><strong>ERROR</strong>: $errorMessage</p>"
} elseif ($warnMessage) {
$outputObject = "<p><strong>WARNING</strong>: $warnMessage</p>"
} else {
$outputObject = "<p><strong>EXCEPTION</strong>: $($_.Exception.Message)</p>"
}
} else {
Debug-CatchWriter -object $_
}
}
} |
'Marking this issue as stale due to inactivity. This helps us focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. |
@burnsjared0415 - could you take a look at picking this one up? |
Running into some issues with the way the code has been writing capture the error messages on a account being locked out or json sending errors to the report. Will keep working through error handling but it will take some time to break about the function within the functions to get information out. |
@burnsjared0415 did you make any progress with this? |
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Code of Conduct
Description
If there is some issue during running the report, script will show error in the console, but not in the HTML report.
Below are screenshots of console and report in case root account of one VC is locked or with wrong password in SDDC Manager DB
There is exception in the console:
The HTML report just skips this check:
In a complex environments or if "-failureOnly" is used, user will not see that some components are missing
Use Case(s)
If user is looking only into the report the information will not be there and some issues may be neglected. the HTML report should show an error that check "X" for component "Y" experienced an error "Error message".
Having this will catch user's attention and the issue will be resolved.
Potential Configuration
Those kind of issues, should be shown as an "ERROR" in the HTML report to catch user's attention.
References
No response
The text was updated successfully, but these errors were encountered: