MCPcopy
hub / github.com/netdata/netdata / main

Function main

src/go/cmd/scriptsdplugin/main.go:39–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39func main() {
40 _, _ = maxprocs.Set(maxprocs.Logger(func(string, ...any) {}))
41
42 opts := parseCLI()
43
44 if opts.Version {
45 fmt.Printf("%s.plugin, version: %s\n", executable.Name, buildinfo.Version)
46 return
47 }
48
49 pluginconfig.MustInit(pluginconfig.InitInput{
50 ConfDir: opts.ConfDir,
51 WatchPath: opts.WatchPath,
52 })
53
54 watchPaths := pluginconfig.CollectorsConfigWatchPaths()
55 if len(watchPaths) == 0 {
56 for _, dir := range pluginconfig.CollectorsDir() {
57 watchPaths = append(watchPaths, filepath.Join(dir, "*.conf"))
58 }
59 }
60
61 if lvl := pluginconfig.EnvLogLevel(); lvl != "" {
62 logger.Level.SetByName(lvl)
63 }
64 if opts.Debug {
65 logger.Level.Set(slog.LevelDebug)
66 }
67 isTerminal := terminal.IsTerminal()
68
69 a := agent.New(agent.Config{
70 Name: executable.Name,
71 PluginConfigDir: pluginconfig.ConfigDir(),
72 CollectorsConfigDir: pluginconfig.CollectorsDir(),
73 ServiceDiscoveryConfigDir: nil,
74 CollectorsConfigWatchPath: watchPaths,
75 VarLibDir: pluginconfig.VarLibDir(),
76 ModuleRegistry: collectorapi.DefaultRegistry,
77 IsInsideK8s: hostinfo.IsInsideK8sCluster(),
78 RunModePolicy: policy.Agent(isTerminal),
79 DiscoveryProviders: []discovery.ProviderFactory{
80 discoveryproviders.File(),
81 discoveryproviders.Dummy(),
82 },
83 RunModule: opts.Module,
84 RunJob: opts.Job,
85 MinUpdateEvery: opts.UpdateEvery,
86 DisableServiceDiscovery: true,
87 })
88
89 a.Debugf("plugin: name=%s, %s", a.Name, buildinfo.Info())
90 if u, err := user.Current(); err == nil {
91 a.Debugf("current user: name=%s, uid=%s", u.Username, u.Uid)
92 }
93
94 proxyCfg := httpproxy.FromEnvironment()
95 a.Infof("env proxy settings: HTTP_PROXY set=%t, HTTPS_PROXY set=%t", proxyCfg.HTTPProxy != "", proxyCfg.HTTPSProxy != "")
96

Callers

nothing calls this directly

Calls 9

PrintfMethod · 0.80
SetByNameMethod · 0.80
parseCLIFunction · 0.70
SetMethod · 0.65
NewMethod · 0.65
DebugfMethod · 0.65
InfoMethod · 0.65
InfofMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…