|
@@ -6,21 +6,35 @@ import (
|
|
|
"github.com/coroot/coroot-node-agent/utils"
|
|
"github.com/coroot/coroot-node-agent/utils"
|
|
|
"github.com/coroot/coroot-node-agent/utils/modelse"
|
|
"github.com/coroot/coroot-node-agent/utils/modelse"
|
|
|
"github.com/jedib0t/go-pretty/v6/table"
|
|
"github.com/jedib0t/go-pretty/v6/table"
|
|
|
|
|
+ klog "github.com/sirupsen/logrus"
|
|
|
"gopkg.in/alecthomas/kingpin.v2"
|
|
"gopkg.in/alecthomas/kingpin.v2"
|
|
|
|
|
+ "gopkg.in/ini.v1"
|
|
|
|
|
+ "net/url"
|
|
|
"os"
|
|
"os"
|
|
|
"path"
|
|
"path"
|
|
|
"strings"
|
|
"strings"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
|
- ListenAddress = kingpin.Flag("listen", "Listen address - ip:port or :port").Default("0.0.0.0:80").Envar("LISTEN").String()
|
|
|
|
|
- CgroupRoot = kingpin.Flag("cgroupfs-root", "The mount point of the host cgroupfs root").Default("/sys/fs/cgroup").Envar("CGROUPFS_ROOT").String()
|
|
|
|
|
- DisableLogParsing = kingpin.Flag("disable-log-parsing", "Disable container log parsing").Default("false").Envar("DISABLE_LOG_PARSING").Bool()
|
|
|
|
|
- DisablePinger = kingpin.Flag("disable-pinger", "Don't ping upstreams").Default("false").Envar("DISABLE_PINGER").Bool()
|
|
|
|
|
- DisableL7Tracing = kingpin.Flag("disable-l7-tracing", "Disable L7 tracing").Default("false").Envar("DISABLE_L7_TRACING").Bool()
|
|
|
|
|
|
|
+ // apm
|
|
|
|
|
+ ConfigServer = kingpin.Flag("config-server", "The URL of the endpoint to send traces to").Envar("CONFIG_SERVER").Default("http://10.0.16.250:18080").String()
|
|
|
|
|
+ DataServer = kingpin.Flag("data-server", "The URL of the endpoint to send traces to").Envar("DATA_SERVER").Default("http://10.0.16.250:18080").String()
|
|
|
|
|
+ DumpApps = kingpin.Flag("dump", "Dump app snap").Default("false").Bool()
|
|
|
|
|
+ LogLevel = kingpin.Flag("log-level", "Log level").Envar("LOG_LEVEL").Default("info").String()
|
|
|
|
|
+ EbpfFilePath = kingpin.Flag("ebpf-path", "Set ebpf file path").Envar("EBPF_FILE").Default("").String()
|
|
|
|
|
+ CommonIni = kingpin.Flag("common.ini", "Set ebpf file path").Envar("COMMON_INI").Default("/opt/cloudwise/omniagent/conf/common.ini").String()
|
|
|
|
|
+ ServerPrefix = kingpin.Flag("server-prefix", "server-prefix").Envar("SERVER_PREFIX").Default("").String()
|
|
|
|
|
+ DisableRegisterHost = kingpin.Flag("disable-reg-host", "Disable reg host").Default("true").Envar("DISABLE_REG_HOST").Bool()
|
|
|
|
|
+ // agent
|
|
|
DisableStackTracing = kingpin.Flag("disable-stack-tracing", "Disable stack tracing").Default("false").Envar("DISABLE_STACK_TRACING").Bool()
|
|
DisableStackTracing = kingpin.Flag("disable-stack-tracing", "Disable stack tracing").Default("false").Envar("DISABLE_STACK_TRACING").Bool()
|
|
|
DisableE2ETracing = kingpin.Flag("disable-e2e-tracing", "Disable e2e tracing").Default("false").Envar("DISABLE_E2E_TRACING").Bool()
|
|
DisableE2ETracing = kingpin.Flag("disable-e2e-tracing", "Disable e2e tracing").Default("false").Envar("DISABLE_E2E_TRACING").Bool()
|
|
|
|
|
+ LicenseKey = kingpin.Flag("license-key", "Apm API key").Default("J45Engw88NeHUZ4Q7qNsK8L47FTH**QvgW113IEnsNaBNMR5zZ**oj/g!!!!").Envar("LICENSE_KEY").String()
|
|
|
|
|
|
|
|
|
|
+ ListenAddress = kingpin.Flag("listen", "Listen address - ip:port or :port").Default("0.0.0.0:80").Envar("LISTEN").String()
|
|
|
|
|
+ CgroupRoot = kingpin.Flag("cgroupfs-root", "The mount point of the host cgroupfs root").Default("/sys/fs/cgroup").Envar("CGROUPFS_ROOT").String()
|
|
|
|
|
+ DisableLogParsing = kingpin.Flag("disable-log-parsing", "Disable container log parsing").Default("false").Envar("DISABLE_LOG_PARSING").Bool()
|
|
|
|
|
+ DisablePinger = kingpin.Flag("disable-pinger", "Don't ping upstreams").Default("false").Envar("DISABLE_PINGER").Bool()
|
|
|
|
|
+ DisableL7Tracing = kingpin.Flag("disable-l7-tracing", "Disable L7 tracing").Default("false").Envar("DISABLE_L7_TRACING").Bool()
|
|
|
ExternalNetworksWhitelist = kingpin.Flag("track-public-network", "Allow track connections to the specified IP networks, all private networks are allowed by default (e.g., Y.Y.Y.Y/mask)").Envar("TRACK_PUBLIC_NETWORK").Strings()
|
|
ExternalNetworksWhitelist = kingpin.Flag("track-public-network", "Allow track connections to the specified IP networks, all private networks are allowed by default (e.g., Y.Y.Y.Y/mask)").Envar("TRACK_PUBLIC_NETWORK").Strings()
|
|
|
EphemeralPortRange = kingpin.Flag("ephemeral-port-range", "Destination and Listen TCP ports from this range will be skipped").Default("").Envar("EPHEMERAL_PORT_RANGE").String()
|
|
EphemeralPortRange = kingpin.Flag("ephemeral-port-range", "Destination and Listen TCP ports from this range will be skipped").Default("").Envar("EPHEMERAL_PORT_RANGE").String()
|
|
|
|
|
|
|
@@ -36,15 +50,11 @@ var (
|
|
|
ApiKey = kingpin.Flag("api-key", "Coroot API key").Envar("API_KEY").String()
|
|
ApiKey = kingpin.Flag("api-key", "Coroot API key").Envar("API_KEY").String()
|
|
|
MetricsEndpoint = kingpin.Flag("metrics-endpoint", "The URL of the endpoint to send metrics to").Envar("METRICS_ENDPOINT").URL()
|
|
MetricsEndpoint = kingpin.Flag("metrics-endpoint", "The URL of the endpoint to send metrics to").Envar("METRICS_ENDPOINT").URL()
|
|
|
TracesEndpoint = kingpin.Flag("traces-endpoint", "The URL of the endpoint to send traces to").Envar("TRACES_ENDPOINT").URL()
|
|
TracesEndpoint = kingpin.Flag("traces-endpoint", "The URL of the endpoint to send traces to").Envar("TRACES_ENDPOINT").URL()
|
|
|
- ConfigEndpoint = kingpin.Flag("config-endpoint", "The URL of the endpoint to send traces to").Envar("CONFIG_ENDPOINT").Default("10.0.16.250:18080").String()
|
|
|
|
|
LogsEndpoint = kingpin.Flag("logs-endpoint", "The URL of the endpoint to send logs to").Envar("LOGS_ENDPOINT").URL()
|
|
LogsEndpoint = kingpin.Flag("logs-endpoint", "The URL of the endpoint to send logs to").Envar("LOGS_ENDPOINT").URL()
|
|
|
ProfilesEndpoint = kingpin.Flag("profiles-endpoint", "The URL of the endpoint to send profiles to").Envar("PROFILES_ENDPOINT").URL()
|
|
ProfilesEndpoint = kingpin.Flag("profiles-endpoint", "The URL of the endpoint to send profiles to").Envar("PROFILES_ENDPOINT").URL()
|
|
|
|
|
|
|
|
ScrapeInterval = kingpin.Flag("scrape-interval", "How often to gather metrics from the agent").Default("15s").Envar("SCRAPE_INTERVAL").Duration()
|
|
ScrapeInterval = kingpin.Flag("scrape-interval", "How often to gather metrics from the agent").Default("15s").Envar("SCRAPE_INTERVAL").Duration()
|
|
|
WalDir = kingpin.Flag("wal-dir", "Path to where the agent stores data (e.g. the metrics Write-Ahead Log)").Default("/tmp/coroot-node-agent").Envar("WAL_DIR").String()
|
|
WalDir = kingpin.Flag("wal-dir", "Path to where the agent stores data (e.g. the metrics Write-Ahead Log)").Default("/tmp/coroot-node-agent").Envar("WAL_DIR").String()
|
|
|
- DumpApps = kingpin.Flag("dump", "Dump app snap").Default("false").Bool()
|
|
|
|
|
- LogLevel = kingpin.Flag("log-level", "Log level").Envar("LOG_LEVEL").Default("info").String()
|
|
|
|
|
- EbpfFilePath = kingpin.Flag("ebpf-path", "Set ebpf file path").Envar("EBPF_FILE").Default("").String()
|
|
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func GetString(fl *string) string {
|
|
func GetString(fl *string) string {
|
|
@@ -83,6 +93,41 @@ func init() {
|
|
|
if *MetricsEndpoint != nil {
|
|
if *MetricsEndpoint != nil {
|
|
|
*ListenAddress = "127.0.0.1:10300"
|
|
*ListenAddress = "127.0.0.1:10300"
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // set ServerPrefix
|
|
|
|
|
+ // set ConfigServer
|
|
|
|
|
+ // set DataServer
|
|
|
|
|
+ if *CommonIni != "" {
|
|
|
|
|
+ iniData, err := ini.Load(*CommonIni)
|
|
|
|
|
+ if err == nil && iniData != nil {
|
|
|
|
|
+ *ServerPrefix = "/apm"
|
|
|
|
|
+ *ConfigServer = iniData.Section("common").Key("config_server").String()
|
|
|
|
|
+ *DataServer = iniData.Section("common").Key("data_server").String()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // set TracesEndpoint
|
|
|
|
|
+ if *TracesEndpoint == nil && *DataServer != "" {
|
|
|
|
|
+ if !strings.HasPrefix(*DataServer, "http") {
|
|
|
|
|
+ *DataServer = fmt.Sprintf("http://%s", *DataServer)
|
|
|
|
|
+ }
|
|
|
|
|
+ dataServer, err := url.Parse(*DataServer)
|
|
|
|
|
+ if err == nil && dataServer != nil {
|
|
|
|
|
+ *TracesEndpoint = dataServer.JoinPath(*ServerPrefix + "/api/v2/data/receive")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // set tiny-agent config
|
|
|
|
|
+ nativeConf := utils.GetDefaultAgentsPath("NativeAgent", "conf", "agent.properties")
|
|
|
|
|
+ confData, err := ini.Load(nativeConf)
|
|
|
|
|
+ if err == nil {
|
|
|
|
|
+ confData.Section(ini.DEFAULT_SECTION).Key("ConfigDomain").SetValue(*ConfigServer + *ServerPrefix)
|
|
|
|
|
+ confData.Section(ini.DEFAULT_SECTION).Key("SendDomain").SetValue(*DataServer + *ServerPrefix)
|
|
|
|
|
+ err = confData.SaveTo(nativeConf)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ klog.Error(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func DumpTableFeatures() {
|
|
func DumpTableFeatures() {
|