diff --git a/health.go b/health.go index 7b44100..beb53bf 100644 --- a/health.go +++ b/health.go @@ -14,6 +14,22 @@ var ( HealthAPIPrefix = "health" ) +func (c *Client) ClusterHealth(ctx context.Context) ([]*types.ClusterHealthNode, error) { + status := []*types.ClusterHealthNode{} + url := fmt.Sprintf("/cluster/%s", HealthAPIPrefix) + + resp, err := c.do("GET", url, doOptions{context: ctx}) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + if err := json.NewDecoder(resp.Body).Decode(&status); err != nil { + return nil, err + } + return status, nil +} + // CPHealth returns the health of the control plane server at a given url. func (c *Client) CPHealth(ctx context.Context, hostname string) (*types.CPHealthStatus, error) { diff --git a/types/health.go b/types/health.go index d6c6d8e..6efe0a4 100644 --- a/types/health.go +++ b/types/health.go @@ -14,6 +14,20 @@ type NamedSubModuleStatus struct { SubModuleStatus } +type ClusterHealthNode struct { + NodeID string `json:"nodeID"` + NodeName string `json:"nodeName"` + Submodules struct { + DirectFSInitiator SubModuleStatus `json:"directfs_initiator"` + Director SubModuleStatus `json:"director"` + KV SubModuleStatus `json:"kv"` + KVWrite SubModuleStatus `json:"kv_write"` + NATS SubModuleStatus `json:"nats"` + Presentation SubModuleStatus `json:"presentation"` + RDB SubModuleStatus `json:"rdb"` + } `json:"submodules"` +} + type CPHealthStatus struct { KV SubModuleStatus KVWrite SubModuleStatus