Skip to content

Commit

Permalink
Merge pull request #204 from atc0005/i196-use-unknown-state-for-failu…
Browse files Browse the repository at this point in the history
…re-to-add-perfdata

Use UNKNOWN state for perfdata add failure
  • Loading branch information
atc0005 authored Mar 7, 2023
2 parents 94ab4f2 + 348c7db commit 20c09f5
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions cmd/check_statuspage_components/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,23 @@ func main() {
Int("remaining_problem_components", numRemainingProblemComponents).
Logger()

if err := plugin.AddPerfData(false, pd...); err != nil {
log.Error().
Err(err).
Msg("failed to add performance data")

// Surface the error in plugin output.
plugin.AddError(err)

plugin.ExitStatusCode = nagios.StateUNKNOWNExitCode
plugin.ServiceOutput = fmt.Sprintf(
"%s: Failed to process performance data metrics",
nagios.StateUNKNOWNLabel,
)

return
}

switch {
case !componentsSet.IsOKState(false):

Expand Down Expand Up @@ -353,12 +370,6 @@ func main() {
cfg.OmitSummaryResults,
)

if err := plugin.AddPerfData(false, pd...); err != nil {
log.Error().
Err(err).
Msg("failed to add performance data")
}

return

default:
Expand All @@ -383,12 +394,6 @@ func main() {
cfg.OmitSummaryResults,
)

if err := plugin.AddPerfData(false, pd...); err != nil {
log.Error().
Err(err).
Msg("failed to add performance data")
}

return

}
Expand Down

0 comments on commit 20c09f5

Please sign in to comment.