forked from netdata/go.d.plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
101 lines (89 loc) · 2.94 KB
/
Copy pathmain.go
File metadata and controls
101 lines (89 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main
import (
"flag"
"fmt"
"os"
"path"
"github.com/netdata/go-orchestrator"
"github.com/netdata/go-orchestrator/cli"
"github.com/netdata/go-orchestrator/logger"
"github.com/netdata/go-orchestrator/pkg/multipath"
_ "github.com/netdata/go.d.plugin/modules/activemq"
_ "github.com/netdata/go.d.plugin/modules/apache"
_ "github.com/netdata/go.d.plugin/modules/bind"
_ "github.com/netdata/go.d.plugin/modules/consul"
_ "github.com/netdata/go.d.plugin/modules/coredns"
_ "github.com/netdata/go.d.plugin/modules/dnsmasq_dhcp"
_ "github.com/netdata/go.d.plugin/modules/dnsquery"
_ "github.com/netdata/go.d.plugin/modules/docker_engine"
_ "github.com/netdata/go.d.plugin/modules/dockerhub"
_ "github.com/netdata/go.d.plugin/modules/example"
_ "github.com/netdata/go.d.plugin/modules/fluentd"
_ "github.com/netdata/go.d.plugin/modules/freeradius"
_ "github.com/netdata/go.d.plugin/modules/httpcheck"
_ "github.com/netdata/go.d.plugin/modules/k8s_kubelet"
_ "github.com/netdata/go.d.plugin/modules/k8s_kubeproxy"
_ "github.com/netdata/go.d.plugin/modules/lighttpd"
_ "github.com/netdata/go.d.plugin/modules/lighttpd2"
_ "github.com/netdata/go.d.plugin/modules/logstash"
_ "github.com/netdata/go.d.plugin/modules/mysql"
_ "github.com/netdata/go.d.plugin/modules/nginx"
_ "github.com/netdata/go.d.plugin/modules/openvpn"
_ "github.com/netdata/go.d.plugin/modules/phpdaemon"
_ "github.com/netdata/go.d.plugin/modules/phpfpm"
_ "github.com/netdata/go.d.plugin/modules/pihole"
_ "github.com/netdata/go.d.plugin/modules/portcheck"
_ "github.com/netdata/go.d.plugin/modules/rabbitmq"
_ "github.com/netdata/go.d.plugin/modules/scaleio"
_ "github.com/netdata/go.d.plugin/modules/solr"
_ "github.com/netdata/go.d.plugin/modules/springboot2"
_ "github.com/netdata/go.d.plugin/modules/tengine"
_ "github.com/netdata/go.d.plugin/modules/vcsa"
_ "github.com/netdata/go.d.plugin/modules/vsphere"
_ "github.com/netdata/go.d.plugin/modules/weblog"
_ "github.com/netdata/go.d.plugin/modules/wmi"
_ "github.com/netdata/go.d.plugin/modules/x509check"
_ "github.com/netdata/go.d.plugin/modules/zookeeper"
)
var (
cd, _ = os.Getwd()
configPaths = multipath.New(
os.Getenv("NETDATA_USER_CONFIG_DIR"),
os.Getenv("NETDATA_STOCK_CONFIG_DIR"),
path.Join(cd, "/../../../../etc/netdata"),
path.Join(cd, "/../../../../usr/lib/netdata/conf.d"),
)
)
var version = "unknown"
func main() {
opt := parseCLI()
if opt.Version {
fmt.Println(fmt.Sprintf("go.d.plugin, version: %s", version))
return
}
if opt.Debug {
logger.SetSeverity(logger.DEBUG)
}
plugin := newPlugin(opt)
if !plugin.Setup() {
return
}
plugin.Serve()
}
func newPlugin(opt *cli.Option) *orchestrator.Orchestrator {
plugin := orchestrator.New()
plugin.Name = "go.d"
plugin.Option = opt
plugin.ConfigPath = configPaths
return plugin
}
func parseCLI() *cli.Option {
opt, err := cli.Parse(os.Args)
if err != nil {
if err != flag.ErrHelp {
os.Exit(1)
}
os.Exit(0)
}
return opt
}