2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-07-14 05:33:47 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
2022-03-13 03:55:53 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2022-03-22 23:58:41 +00:00
|
|
|
"github.com/hashicorp/consul/api"
|
2017-07-14 05:33:47 +00:00
|
|
|
"github.com/hashicorp/consul/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// These are used to manage the built-in "serfHealth" check that's attached
|
|
|
|
// to every node in the catalog.
|
|
|
|
const (
|
|
|
|
SerfCheckID types.CheckID = "serfHealth"
|
|
|
|
SerfCheckName = "Serf Health Status"
|
|
|
|
SerfCheckAliveOutput = "Agent alive and reachable"
|
|
|
|
SerfCheckFailedOutput = "Agent not live or unreachable"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-03-07 01:32:41 +00:00
|
|
|
// These are used to manage the "consul" service that's attached to every
|
|
|
|
// Consul server node in the catalog.
|
2017-07-14 05:33:47 +00:00
|
|
|
ConsulServiceID = "consul"
|
|
|
|
ConsulServiceName = "consul"
|
|
|
|
)
|
2022-03-22 23:58:41 +00:00
|
|
|
|
|
|
|
type CatalogContents struct {
|
|
|
|
Nodes []*Node
|
|
|
|
Services []*ServiceNode
|
|
|
|
Checks []*HealthCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
type CatalogSummary struct {
|
|
|
|
Nodes []HealthSummary
|
|
|
|
Services []HealthSummary
|
|
|
|
Checks []HealthSummary
|
|
|
|
}
|
|
|
|
|
|
|
|
type HealthSummary struct {
|
|
|
|
Name string `json:",omitempty"`
|
|
|
|
|
|
|
|
Total int
|
|
|
|
Passing int
|
|
|
|
Warning int
|
|
|
|
Critical int
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
acl.EnterpriseMeta
|
2022-03-22 23:58:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HealthSummary) Add(status string) {
|
|
|
|
h.Total++
|
|
|
|
switch status {
|
|
|
|
case api.HealthPassing:
|
|
|
|
h.Passing++
|
|
|
|
case api.HealthWarning:
|
|
|
|
h.Warning++
|
|
|
|
case api.HealthCritical:
|
|
|
|
h.Critical++
|
|
|
|
}
|
|
|
|
}
|