diagnose

package
v0.0.0-...-9c6a4e6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 26 Imported by: 4

README

package diagnose

This package is used to register and run agent diagnostics which validates various aspects of agent installation, configuration and run-time environment.

Running agent diagnose all

Details and command line options are specified in agent diagnose command You can run all registered diagnosis with the diagnose command on the agent

The flare command will also run registered diagnosis and output them in a diagnose.log file.

Registering a new diagnose suite

All function and structures details can be found in loader.go file.

To register a diagnose suite one need to register a function which returns []diagnosis.Diagnosis.

Example from loader.go file:

package connectivity

import (
    ...
	"github.com/DataDog/datadog-agent/pkg/diagnose/diagnosis"
    ...
)
...
func init() {
	diagnosis.Register("connectivity-datadog-core-endpoints", diagnose)
}
...
func diagnose(diagCfg diagnosis.Config) []diagnosis.Diagnosis {
    ...
    var diagnoses []diagnosis.Diagnosis
    ...
	for _, domainResolver := range domainResolvers {
        ...
		for _, apiKey := range domainResolver.GetAPIKeys() {
			for _, endpointInfo := range endpointsInfo {
                ...
				name := "Connectivity to " + logURL
				if reportErr == nil {
					diagnoses = append(diagnoses, diagnosis.Diagnosis{
						Result:    diagnosis.DiagnosisSuccess,
						Name:      name,
						Diagnosis: fmt.Sprintf("Connectivity to `%s` is Ok\n%s", logURL, report),
					})
				} else {
					diagnoses = append(diagnoses, diagnosis.Diagnosis{
						Result:      diagnosis.DiagnosisFail,
						Name:        name,
						Diagnosis:   fmt.Sprintf("Connection to `%s` failed\n%s", logURL, report),
						Remediation: "Please validate Agent configuration and firewall to access " + logURL,
						RawError:    err,
					})
				}
			}
		}
	}

	return diagnoses
}

Context of a diagnose function execution

Normally, registered diagnose suite functions will be executed in context of the running agent service (or other services) but if Config.ForceLocal configuration is specified the registered diagnose function will be executed in the context of agent diagnose CLI command (if possible).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListStdOut

func ListStdOut(w io.Writer, diagCfg diagnosis.Config, deps SuitesDeps)

Enumerate registered Diagnose suites and get their diagnoses for human consumption

func Run

func Run(diagCfg diagnosis.Config, deps SuitesDeps) ([]diagnosis.Diagnoses, error)

Run runs diagnoses.

func RunStdOut

func RunStdOut(w io.Writer, diagCfg diagnosis.Config, deps SuitesDeps) error

Enumerate registered Diagnose suites and get their diagnoses for human consumption

Types

type SuitesDeps

type SuitesDeps struct {
	AC optional.Option[autodiscovery.Component]
	// contains filtered or unexported fields
}

SuitesDeps stores the dependencies for the diagnose suites.

func NewSuitesDeps

NewSuitesDeps returns a new SuitesDeps.

func (*SuitesDeps) GetWMeta

GetWMeta returns the workload metadata instance

Directories

Path Synopsis
Package connectivity contains logic for connectivity troubleshooting between the Agent and Datadog endpoints.
Package connectivity contains logic for connectivity troubleshooting between the Agent and Datadog endpoints.
Package diagnosis contains types used by the "agent diagnose" command.
Package diagnosis contains types used by the "agent diagnose" command.

Jump to

Keyboard shortcuts

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