Skip to content

Commit

Permalink
create checks-agent process
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Nov 28, 2024
1 parent a2de12f commit 8e7fff7
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 11 deletions.
15 changes: 5 additions & 10 deletions cmd/agent/subcommands/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ import (
internalAPI "github.com/DataDog/datadog-agent/comp/api/api/def"
authtokenimpl "github.com/DataDog/datadog-agent/comp/api/authtoken/createandfetchimpl"
commonendpoints "github.com/DataDog/datadog-agent/comp/api/commonendpoints/fx"
"github.com/DataDog/datadog-agent/comp/collector/collector"
"github.com/DataDog/datadog-agent/comp/collector/collector/collectorimpl"
"github.com/DataDog/datadog-agent/comp/core"
"github.com/DataDog/datadog-agent/comp/core/autodiscovery"
"github.com/DataDog/datadog-agent/comp/core/autodiscovery/autodiscoveryimpl"
Expand Down Expand Up @@ -127,12 +125,10 @@ import (
"github.com/DataDog/datadog-agent/comp/snmptraps"
snmptrapsServer "github.com/DataDog/datadog-agent/comp/snmptraps/server"
traceagentStatusImpl "github.com/DataDog/datadog-agent/comp/trace/status/statusimpl"
pkgcollector "github.com/DataDog/datadog-agent/pkg/collector"
"github.com/DataDog/datadog-agent/pkg/collector/check"
"github.com/DataDog/datadog-agent/pkg/collector/corechecks/net"
profileStatus "github.com/DataDog/datadog-agent/pkg/collector/corechecks/snmp/status"
"github.com/DataDog/datadog-agent/pkg/collector/python"
"github.com/DataDog/datadog-agent/pkg/commonchecks"
"github.com/DataDog/datadog-agent/pkg/config/remote/data"
commonsettings "github.com/DataDog/datadog-agent/pkg/config/settings"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
Expand Down Expand Up @@ -250,7 +246,7 @@ func run(log log.Component,
_ systemprobemetadata.Component,
_ securityagentmetadata.Component,
statusComponent status.Component,
collector collector.Component,
// collector collector.Component,
cloudfoundrycontainer cloudfoundrycontainer.Component,
_ expvarserver.Component,
_ pid.Component,
Expand Down Expand Up @@ -319,7 +315,6 @@ func run(log log.Component,
invChecks,
logReceiver,
statusComponent,
collector,
cfg,
cloudfoundrycontainer,
jmxlogger,
Expand Down Expand Up @@ -439,7 +434,7 @@ func getSharedFxOption() fx.Option {
netflow.Bundle(),
rdnsquerierfx.Module(),
snmptraps.Bundle(),
collectorimpl.Module(),
// collectorimpl.Module(),
process.Bundle(),
guiimpl.Module(),
agent.Bundle(jmxloggerimpl.NewDefaultParams()),
Expand Down Expand Up @@ -498,7 +493,7 @@ func startAgent(
invChecks inventorychecks.Component,
logReceiver optional.Option[integrations.Component],
_ status.Component,
collector collector.Component,
// collector collector.Component,
cfg config.Component,
_ cloudfoundrycontainer.Component,
jmxLogger jmxlogger.Component,
Expand Down Expand Up @@ -586,8 +581,8 @@ func startAgent(
jmxfetch.RegisterWith(ac)

// Set up check collector
commonchecks.RegisterChecks(wmeta, tagger, cfg, telemetry)
ac.AddScheduler("check", pkgcollector.InitCheckScheduler(optional.NewOption(collector), demultiplexer, logReceiver, tagger), true)
// commonchecks.RegisterChecks(wmeta, tagger, cfg, telemetry)
// ac.AddScheduler("check", pkgcollector.InitCheckScheduler(optional.NewOption(collector), demultiplexer, logReceiver, tagger), true)

demultiplexer.AddAgentStartupTelemetry(version.AgentVersion)

Expand Down
36 changes: 36 additions & 0 deletions cmd/checks-agent/command/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//nolint:revive // TODO(AML) Fix revive linter
package command

import (
//nolint:revive // TODO(AML) Fix revive linter
_ "expvar"
_ "net/http/pprof"

"github.com/spf13/cobra"

"github.com/DataDog/datadog-agent/cmd/checks-agent/subcommands/start"
"github.com/DataDog/datadog-agent/cmd/checks-agent/subcommands/version"
)

func MakeRootCommand() *cobra.Command {
// checksAgentCmd is the root command
checksAgentCmd := &cobra.Command{
Use: "checks-agent [command]",
Short: "Checks Agent at your service.",
}

for _, cmd := range makeCommands() {
checksAgentCmd.AddCommand(cmd)
}

return checksAgentCmd
}

func makeCommands() []*cobra.Command {
return []*cobra.Command{start.MakeCommand(), version.MakeCommand("Checks Agent")}
}
27 changes: 27 additions & 0 deletions cmd/checks-agent/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//go:build !windows

package main

import (
_ "net/http/pprof"
"os"

"log"

"github.com/DataDog/datadog-agent/cmd/checks-agent/command"
"github.com/DataDog/datadog-agent/pkg/util/flavor"
)

func main() {
flavor.SetFlavor(flavor.ChecksAgent)

if err := command.MakeRootCommand().Execute(); err != nil {
log.Println(err)
os.Exit(-1)
}
}
Loading

0 comments on commit 8e7fff7

Please sign in to comment.