api

package
v0.0.0-...-3641ea5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 37 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// All stands for collecting logs from all discovered nodes.
	All = "all"

	// Masters stand for collecting from discovered master nodes.
	Masters = "masters"

	// Agents stand for collecting from discovered agent/agent_public nodes.
	Agents = "agents"
)
View Source
const (
	GoosWindows = "windows"

	GoosDarwin = "darwin"
)

Variables

This section is empty.

Functions

func LoadCollectors

func LoadCollectors(cfg *config.Config, tools dcos.Tooler, client *http.Client) ([]collector.Collector, error)

func NewRouter

func NewRouter(dt *Dt) *mux.Router

NewRouter returns a new *mux.Router with loaded routes.

func StartPullWithInterval

func StartPullWithInterval(dt *Dt)

StartPullWithInterval will start to pull a DC/OS cluster health status

Types

type CommandProvider

type CommandProvider struct {
	Command  []string
	Role     []string
	Optional bool
}

CommandProvider is a local command to execute.

type DiagnosticsJob

type DiagnosticsJob struct {
	sync.RWMutex

	Cfg       *config.Config
	DCOSTools dcos.Tooler
	Transport http.RoundTripper

	Running               bool
	Status                string
	Errors                []string
	LastBundlePath        string
	JobStarted            time.Time
	JobEnded              time.Time
	JobProgressPercentage float32
	// This vector is used to collect the HTTP response times of all endpoints.
	FetchPrometheusVector prometheus.ObserverVec
	// contains filtered or unexported fields
}

DiagnosticsJob is the main structure for a logs collection job.

func (*DiagnosticsJob) Init

func (j *DiagnosticsJob) Init() error

Init will prepare diagnostics job, read config files etc.

type Dt

type Dt struct {
	Cfg                  *config.Config
	DtDCOSTools          dcos.Tooler
	DtDiagnosticsJob     *DiagnosticsJob
	BundleHandler        rest.BundleHandler
	ClusterBundleHandler *rest.ClusterBundleHandler
	RunPullerChan        chan bool
	RunPullerDoneChan    chan bool
	SystemdUnits         *SystemdUnits
	MR                   *MonitoringResponse
}

Dt is a struct of dependencies used in dcos-diagnostics code. There are 2 implementations, the one runs on a real system and the one used for testing.

type FileProvider

type FileProvider struct {
	Location string
	Role     []string
	Optional bool
}

FileProvider is a local file provider.

type HTTPProvider

type HTTPProvider struct {
	Port     int
	URI      string
	FileName string
	Role     []string
	Optional bool
}

HTTPProvider is a provider for fetching an HTTP endpoint.

type HealthResponseValues

type HealthResponseValues struct {
	UnitID     string      `json:"id"`
	UnitHealth dcos.Health `json:"health"`
	UnitOutput string      `json:"output"`
	UnitTitle  string      `json:"description"`
	Help       string      `json:"help"`
	PrettyName string      `json:"name"`
}

HealthResponseValues is a health values json response.

type LogProviders

type LogProviders struct {
	HTTPEndpoints []HTTPProvider
	LocalFiles    []FileProvider
	LocalCommands []CommandProvider
}

LogProviders a structure defines a list of Providers

type MonitoringResponse

type MonitoringResponse struct {
	sync.RWMutex

	Units       map[string]dcos.Unit
	Nodes       map[string]dcos.Node
	UpdatedTime time.Time
}

MonitoringResponse top level global variable to store the entire units/nodes status tree.

func (*MonitoringResponse) GetAllUnits

func (mr *MonitoringResponse) GetAllUnits() UnitsResponseJSONStruct

GetAllUnits returns all systemd units from status tree.

func (*MonitoringResponse) GetLastUpdatedTime

func (mr *MonitoringResponse) GetLastUpdatedTime() string

GetLastUpdatedTime returns timestamp of latest updated monitoring response.

func (*MonitoringResponse) GetMasterAgentNodes

func (mr *MonitoringResponse) GetMasterAgentNodes() ([]dcos.Node, []dcos.Node, error)

GetMasterAgentNodes returns a list of master and agent nodes available in status tree.

func (*MonitoringResponse) GetNodeByID

func (mr *MonitoringResponse) GetNodeByID(nodeIP string) (NodeResponseFieldsStruct, error)

GetNodeByID returns a node by IP address from a status tree.

func (*MonitoringResponse) GetNodeUnitByNodeIDUnitID

func (mr *MonitoringResponse) GetNodeUnitByNodeIDUnitID(nodeIP, unitID string) (HealthResponseValues, error)

GetNodeUnitByNodeIDUnitID returns a Unit status by node IP address and Unit id.

func (*MonitoringResponse) GetNodeUnitsID

func (mr *MonitoringResponse) GetNodeUnitsID(nodeIP string) (UnitsResponseJSONStruct, error)

GetNodeUnitsID returns a Unit status for a given node from status tree.

func (*MonitoringResponse) GetNodes

GetNodes gets all available nodes in status tree.

func (*MonitoringResponse) GetNodesForUnit

func (mr *MonitoringResponse) GetNodesForUnit(unitName string) (NodesResponseJSONStruct, error)

GetNodesForUnit get all hosts for a specific Unit available in status tree.

func (*MonitoringResponse) GetSpecificNodeForUnit

func (mr *MonitoringResponse) GetSpecificNodeForUnit(unitName, nodeIP string) (NodeResponseFieldsWithErrorStruct, error)

GetSpecificNodeForUnit gets a specific notFoundError{nodeIP}e.

func (*MonitoringResponse) GetUnit

func (mr *MonitoringResponse) GetUnit(unitName string) (UnitResponseFieldsStruct, error)

GetUnit gets a specific Unit from a status tree.

func (*MonitoringResponse) UpdateMonitoringResponse

func (mr *MonitoringResponse) UpdateMonitoringResponse(r *MonitoringResponse)

UpdateMonitoringResponse will update the status tree.

type NodeResponseFieldsStruct

type NodeResponseFieldsStruct struct {
	HostIP     string      `json:"host_ip"`
	NodeHealth dcos.Health `json:"health"`
	NodeRole   string      `json:"role"`
}

NodeResponseFieldsStruct contains a response from a node.

type NodeResponseFieldsWithErrorStruct

type NodeResponseFieldsWithErrorStruct struct {
	HostIP     string      `json:"host_ip"`
	NodeHealth dcos.Health `json:"health"`
	NodeRole   string      `json:"role"`
	UnitOutput string      `json:"output"`
	Help       string      `json:"help"`
}

NodeResponseFieldsWithErrorStruct contains node response with errors.

type NodesResponseJSONStruct

type NodesResponseJSONStruct struct {
	Array []*NodeResponseFieldsStruct `json:"nodes"`
}

NodesResponseJSONStruct contains an array of responses from nodes.

type SystemdUnits

type SystemdUnits struct {
	sync.Mutex
}

SystemdUnits used to make GetUnitsProperties thread safe.

func (*SystemdUnits) GetUnits

func (s *SystemdUnits) GetUnits(tools dcos.Tooler) (allUnits []HealthResponseValues, err error)

GetUnits returns a list of found unit properties.

func (*SystemdUnits) GetUnitsProperties

func (s *SystemdUnits) GetUnitsProperties(tools dcos.Tooler) (healthReport UnitsHealthResponseJSONStruct, err error)

GetUnitsProperties return a structured units health response of UnitsHealthResponseJsonStruct type.

type UnitPropertiesResponse

type UnitPropertiesResponse struct {
	ID             string `mapstructure:"Id"`
	LoadState      string
	ActiveState    string
	SubState       string
	Description    string
	ExecMainStatus int

	InactiveExitTimestampMonotonic  uint64
	ActiveEnterTimestampMonotonic   uint64
	ActiveExitTimestampMonotonic    uint64
	InactiveEnterTimestampMonotonic uint64
}

UnitPropertiesResponse is a structure to unmarshal dbus.GetunitProperties response

func (*UnitPropertiesResponse) CheckUnitHealth

func (u *UnitPropertiesResponse) CheckUnitHealth() (dcos.Health, string, error)

CheckUnitHealth tells if the Unit is healthy

type UnitResponseFieldsStruct

type UnitResponseFieldsStruct struct {
	UnitID     string      `json:"id"`
	PrettyName string      `json:"name"`
	UnitHealth dcos.Health `json:"health"`
	UnitTitle  string      `json:"description"`
}

UnitResponseFieldsStruct contains systemd unit health report.

type UnitsHealthResponseJSONStruct

type UnitsHealthResponseJSONStruct struct {
	Array       []HealthResponseValues `json:"units"`
	Hostname    string                 `json:"hostname"`
	IPAddress   string                 `json:"ip"`
	DcosVersion string                 `json:"dcos_version"`
	Role        string                 `json:"node_role"`
	MesosID     string                 `json:"mesos_id"`
	TdtVersion  string                 `json:"dcos_diagnostics_version"`
}

UnitsHealthResponseJSONStruct json response /system/health/v1

type UnitsResponseJSONStruct

type UnitsResponseJSONStruct struct {
	Array []UnitResponseFieldsStruct `json:"units"`
}

UnitsResponseJSONStruct contains health overview, collected from all hosts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL