فهرست منبع

Fixed #TASK_QT-9810 对接OmniAgent

Carl 1 سال پیش
والد
کامیت
64b99aaafd

+ 50 - 46
containers/registry.go

@@ -127,11 +127,11 @@ func NewRegistry(reg prometheus.Registerer, kernelVersion string, nodeInfo *Node
 		nodeInfo:       nodeInfo,
 		nodeInfo:       nodeInfo,
 	}
 	}
 	// 初始化软负载集群节点
 	// 初始化软负载集群节点
-	proxyClient, clientErr := NewProxyClient(*flags.ConfigEndpoint, false)
+	proxyClient, clientErr := NewProxyClient(*flags.ConfigServer, false)
 	if clientErr == nil {
 	if clientErr == nil {
 		// 负载健康检测
 		// 负载健康检测
 		try.Go(proxyClient.CheckEndpoints, CatchFn)
 		try.Go(proxyClient.CheckEndpoints, CatchFn)
-		log.Infof("New Proxy Client success.config_server is [%s]", *flags.ConfigEndpoint)
+		log.Infof("New Proxy Client success.config_server is [%s]", *flags.ConfigServer)
 	} else {
 	} else {
 		log.WithError(clientErr).Errorf("NewProxyClient error, Please check [export CONFIG_ENDPOINT=ip:port]")
 		log.WithError(clientErr).Errorf("NewProxyClient error, Please check [export CONFIG_ENDPOINT=ip:port]")
 		return nil, clientErr
 		return nil, clientErr
@@ -142,11 +142,13 @@ func NewRegistry(reg prometheus.Registerer, kernelVersion string, nodeInfo *Node
 		log.Errorf("init connServer error:%s.", err)
 		log.Errorf("init connServer error:%s.", err)
 		return nil, err
 		return nil, err
 	}
 	}
-	// Register Host
-	err = r.RegisterHost()
-
-	if err != nil {
-		return nil, err
+	if !*flags.DisableRegisterHost {
+		// Register Host
+		err = r.RegisterHost()
+		if err != nil {
+			klog.WithError(err).Errorf("Failed Register Host.")
+			return nil, err
+		}
 	}
 	}
 
 
 	if err = reg.Register(r); err != nil {
 	if err = reg.Register(r); err != nil {
@@ -196,51 +198,53 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 			}
 			}
 			runtimeApps := make(map[uint32]AppStatusInfo)
 			runtimeApps := make(map[uint32]AppStatusInfo)
 			for pid, c := range r.containersByPid {
 			for pid, c := range r.containersByPid {
-				if !common.IsOpenFilter() {
-					verifyAttachConditions := c.verifyAttachConditions(r, pid)
-					if verifyAttachConditions {
-						err = c.RegisterAppInfo(r, pid)
-						if err == nil {
-							klog.WithField("pid", pid).Infoln("[registry] Attach uprobes.")
-							err = c.attachUprobes(r.tracer, pid)
-							if err != nil {
-								klog.WithField("pid", pid).WithError(err).Errorf("[registry] Failed attach uprobes error!")
+				if c != nil {
+					if !common.IsOpenFilter() {
+						verifyAttachConditions := c.verifyAttachConditions(r, pid)
+						if verifyAttachConditions {
+							err = c.RegisterAppInfo(r, pid)
+							if err == nil {
+								klog.WithField("pid", pid).Infoln("[registry] Attach uprobes.")
+								err = c.attachUprobes(r.tracer, pid)
+								if err != nil {
+									klog.WithField("pid", pid).WithError(err).Errorf("[registry] Failed attach uprobes error!")
+								} else {
+									klog.WithField("pid", pid).Infoln("[registry] Attach uprobes success!")
+								}
+								klog.WithField("pid", pid).Infoln("[registry] Attach app stack.")
+								err = c.StackTrace(r.tracer, pid)
+								if err != nil {
+									klog.WithField("pid", pid).WithError(err).Errorf("[registry][end] Failed attach stack trace!")
+								}
 							} else {
 							} else {
-								klog.WithField("pid", pid).Infoln("[registry] Attach uprobes success!")
+								klog.WithError(err).Errorf("[registry] Failed registerAppInfo.")
 							}
 							}
-							klog.WithField("pid", pid).Infoln("[registry] Attach app stack.")
-							err = c.StackTrace(r.tracer, pid)
-							if err != nil {
-								klog.WithField("pid", pid).WithError(err).Errorf("[registry][end] Failed attach stack trace!")
-							}
-						} else {
-							klog.WithError(err).Errorf("[registry] Failed registerAppInfo.")
 						}
 						}
-					}
 
 
-					if !verifyAttachConditions && c.checkL7AttachReady() {
-						// detach
-						c.detachUprobes(pid)
-					}
-				}
-				if c != nil && c.AppInfo.AppName != "" {
-					detail := AppStatusInfo{
-						Pid:        pid,
-						ProcName:   c.containerName,
-						AppName:    c.AppInfo.AppName,
-						Language:   c.AppInfo.CodeType.String(),
-						AppID:      c.AppInfo.AppIdHash.IntVal,
-						AgentID:    c.AppInfo.AgentId,
-						InstanceID: c.AppInfo.InstanceIdHash.IntVal,
-						Sn:         c.AppInfo.Sn,
-						Sport:      c.AppInfo.Sport,
-						RegisterAt: time.Unix(c.AppInfo.RegisterAt, 0).Format("060102 15:04:05"),
-					}
-					if c.AppInfo.UpdateAt != 0 {
-						detail.UpdateAt = time.Unix(c.AppInfo.UpdateAt, 0).Format("060102 15:04:05")
+						if !verifyAttachConditions && c.checkL7AttachReady() {
+							// detach
+							c.detachUprobes(pid)
+						}
 					}
 					}
+					if c.AppInfo.AppName != "" {
+						detail := AppStatusInfo{
+							Pid:        pid,
+							ProcName:   c.containerName,
+							AppName:    c.AppInfo.AppName,
+							Language:   c.AppInfo.CodeType.String(),
+							AppID:      c.AppInfo.AppIdHash.IntVal,
+							AgentID:    c.AppInfo.AgentId,
+							InstanceID: c.AppInfo.InstanceIdHash.IntVal,
+							Sn:         c.AppInfo.Sn,
+							Sport:      c.AppInfo.Sport,
+							RegisterAt: time.Unix(c.AppInfo.RegisterAt, 0).Format("060102 15:04:05"),
+						}
+						if c.AppInfo.UpdateAt != 0 {
+							detail.UpdateAt = time.Unix(c.AppInfo.UpdateAt, 0).Format("060102 15:04:05")
+						}
 
 
-					runtimeApps[pid] = detail
+						runtimeApps[pid] = detail
+					}
 				}
 				}
 
 
 				cg, err := proc.ReadCgroup(pid)
 				cg, err := proc.ReadCgroup(pid)

+ 4 - 30
dist/package_dir/agents/NativeAgent/conf/agent.properties

@@ -1,33 +1,7 @@
-#APM Server url.
-ConfigDomain=http://10.0.16.250:18080
-SendDomain=http://10.0.16.250:18080
-
+# APM Server url.
+ConfigDomain    = http://10.0.16.250:18084/apm
+SendDomain      = http://10.0.16.250:18084/apm
 # License Key.
 # License Key.
-LicenseKey = J45Engw88NeHUZ4Q7qNsK8L47FTH**QvgW113IEnsNaBNMR5zZ**oj/g!!!!
-
 # Logging level.
 # Logging level.
 # Optional: DEBUG, INFO, WARN, ERROR
 # Optional: DEBUG, INFO, WARN, ERROR
-agent.log.level=ERROR
-
-# Web container that supports automatic injection of js.
-# Optional:
-# tomcat6,tomcat7,tomcat8,tomcat9
-# jetty7,jetty8,jetty9
-# weblogic10,weblogic12
-# jboss7,resin3
-js=
-
-# js file location
-jsEnvAdd=http://data.toushibao.com/api/browser/settings/v70/js
-
-# js Inject positon, Optional: html(Default),body,head
-#js.inject.position=html
-
-# Chinese is not supported!
-appName=javaApplication
-
-# Compression mode, Optional: gzip(Default), disable
-send.compression.mode=gzip
-
-# Asynchronous stack collection, Optional: true, false(Default)
-#tracer.asynchronous=false
+agent.log.level = ERROR

+ 4 - 1
dist/package_dir/bin/start.sh

@@ -1,6 +1,9 @@
 #!/bin/bash
 #!/bin/bash
 echo "start in start.sh"
 echo "start in start.sh"
-export TRACES_ENDPOINT=http://10.0.12.192:18080/docp/api/v2/data/receive
+#export CONFIG_SERVER=
+#export DATA_SERVER=
+export DISABLE_E2E_TRACING=false
+export DISABLE_STACK_TRACING=false
 pid=$(nohup $1 --listen="0.0.0.0:8123">>"/dev/null" 2>&1 & echo $!)
 pid=$(nohup $1 --listen="0.0.0.0:8123">>"/dev/null" 2>&1 & echo $!)
 AGENT_PID_FILE="$1.pid"
 AGENT_PID_FILE="$1.pid"
 echo ${pid} > "${AGENT_PID_FILE}"
 echo ${pid} > "${AGENT_PID_FILE}"

+ 1 - 1
dist/scripts/package.sh

@@ -366,7 +366,7 @@ deleteParentTmpFile() {
 PARAM_DEBUG=false
 PARAM_DEBUG=false
 PARAM_RELEASE=false
 PARAM_RELEASE=false
 #PARAM_VERSION=1.1.0
 #PARAM_VERSION=1.1.0
-PARAM_NAME=chaosd
+PARAM_NAME=euspace
 PARAM_AGENT_PROC=$PARAM_NAME
 PARAM_AGENT_PROC=$PARAM_NAME
 PARAM_CONFIG_PATH=
 PARAM_CONFIG_PATH=
 
 

+ 1 - 1
dist/scripts/uninstall.sh

@@ -21,7 +21,7 @@ readonly BRAND_AGENT_DEFAULT_USER_AND_GROUP_NAME="cloudwise"
 #== **********************************************************
 #== **********************************************************
 #== smartagentd
 #== smartagentd
 readonly AGENT_PROC="euspace"
 readonly AGENT_PROC="euspace"
-readonly AGENT_INSTALLER_VERSION=0.0.2
+readonly AGENT_INSTALLER_VERSION=0.0.1
 #== **********************************************************
 #== **********************************************************
 #==  配置目录
 #==  配置目录
 #== **********************************************************
 #== **********************************************************

+ 54 - 9
flags/flags.go

@@ -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() {

+ 8 - 5
main.go

@@ -139,6 +139,12 @@ func main() {
 	log.Infoln("hostname:", hostname)
 	log.Infoln("hostname:", hostname)
 	log.Infoln("kernel version:", kv)
 	log.Infoln("kernel version:", kv)
 
 
+	// 构建节点信息
+	nodeInfo, err := node.NewNodeInfo(hostname, kv)
+	if err != nil || nodeInfo == nil {
+		log.Fatalln(err)
+	}
+	log.Infof("node info %s", utils.ToString(nodeInfo))
 	ver := common.KernelMajorMinor(kv)
 	ver := common.KernelMajorMinor(kv)
 	if ver == "" {
 	if ver == "" {
 		log.Fatalln("invalid kernel version:", kv)
 		log.Fatalln("invalid kernel version:", kv)
@@ -149,7 +155,7 @@ func main() {
 
 
 	whitelistNodeExternalNetworks()
 	whitelistNodeExternalNetworks()
 
 
-	machineId := utils.MachineID()
+	machineId := nodeInfo.GetNodeInfo().SystemUUID
 	tracing.Init(machineId, hostname, version)
 	tracing.Init(machineId, hostname, version)
 	logs.Init(machineId, hostname, version)
 	logs.Init(machineId, hostname, version)
 
 
@@ -163,10 +169,7 @@ func main() {
 	}
 	}
 
 
 	//processInfoCh := profiling.Init(machineId, hostname)
 	//processInfoCh := profiling.Init(machineId, hostname)
-	nodeInfo, err := node.NewNodeInfo(hostname, kv, machineId)
-	if err != nil || nodeInfo == nil {
-		log.Fatalln(err)
-	}
+
 	cr, err := containers.NewRegistry(registerer, kv, nodeInfo, nil)
 	cr, err := containers.NewRegistry(registerer, kv, nodeInfo, nil)
 
 
 	if err != nil {
 	if err != nil {

+ 59 - 3
node/apm_host_info.go

@@ -1,11 +1,26 @@
 package node
 package node
 
 
 import (
 import (
+	"encoding/base64"
+	"fmt"
+	"github.com/coroot/coroot-node-agent/flags"
 	"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"
+	klog "github.com/sirupsen/logrus"
+	"gopkg.in/ini.v1"
+	"strconv"
+	"strings"
 )
 )
 
 
-func NewNodeInfo(name, kv, machineId string) (*NodeInfoT, error) {
+func NewNodeInfo(name, kv string) (*NodeInfoT, error) {
+	ni, err := newNodeInfoFromCommonIni(name, kv)
+	if err != nil {
+		klog.Errorf("Failed to create node info from common ini: %v", err)
+	} else {
+		klog.Infof("run in omniagent.")
+		return ni, err
+	}
+
 	ip, err := utils.GetRealIp()
 	ip, err := utils.GetRealIp()
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
@@ -14,10 +29,51 @@ func NewNodeInfo(name, kv, machineId string) (*NodeInfoT, error) {
 		Hostname:      name,
 		Hostname:      name,
 		HostIp:        ip,
 		HostIp:        ip,
 		KernelVersion: kv,
 		KernelVersion: kv,
-		SystemUUID:    machineId,
+		SystemUUID:    utils.SystemUUID(),
 		HostID:        utils.GetIntHostID(),
 		HostID:        utils.GetIntHostID(),
 		AccountID:     utils.GetAccountID(),
 		AccountID:     utils.GetAccountID(),
-		LicenseKey:    "J45Engw88NeHUZ4Q7qNsK8L47FTH**QvgW113IEnsNaBNMR5zZ**oj/g!!!!",
+		LicenseKey:    *flags.LicenseKey,
 	}
 	}
+	klog.Infof("run standalone.")
 	return n, nil
 	return n, nil
 }
 }
+
+func newNodeInfoFromCommonIni(name, kv string) (*NodeInfoT, error) {
+	if *flags.CommonIni != "" {
+		iniData, err := ini.Load(*flags.CommonIni)
+		if err != nil {
+			return nil, err
+		}
+		if iniData == nil {
+			return nil, fmt.Errorf("no ini data")
+		}
+		ip := iniData.Section("common").Key("ip").String()
+		uuid := iniData.Section("common").Key("system_uuid").String()
+		host_id, err := iniData.Section("common").Key("host_id").Int64()
+		if err != nil {
+			return nil, err
+		}
+		token := iniData.Section("common").Key("token").String()
+		account_and_user_byte, err := base64.StdEncoding.DecodeString(token)
+		if err != nil {
+			return nil, err
+		}
+		account_and_user_string := strings.Split(string(account_and_user_byte), "@")
+		if len(account_and_user_string) > 0 {
+			accountId, err := strconv.Atoi(account_and_user_string[0])
+			if err == nil {
+				n := &NodeInfoT{
+					Hostname:      name,
+					HostIp:        ip,
+					KernelVersion: kv,
+					SystemUUID:    uuid,
+					HostID:        host_id,
+					AccountID:     accountId,
+					LicenseKey:    *flags.LicenseKey,
+				}
+				return n, nil
+			}
+		}
+	}
+	return nil, nil
+}

+ 2 - 2
utils/id.go

@@ -58,7 +58,7 @@ func GetHostID() (int64, HashByte) {
 	if HOST_ID_INT64 != 0 {
 	if HOST_ID_INT64 != 0 {
 		return HOST_ID_INT64, HOST_ID_BYTE
 		return HOST_ID_INT64, HOST_ID_BYTE
 	}
 	}
-	uuid := MachineID()
+	uuid := SystemUUID()
 	// todo AccountId
 	// todo AccountId
 	str := fmt.Sprintf("%d:%s", GetAccountID(), uuid)
 	str := fmt.Sprintf("%d:%s", GetAccountID(), uuid)
 	srcCode := md5.Sum([]byte(str))
 	srcCode := md5.Sum([]byte(str))
@@ -86,7 +86,7 @@ func GetIntHostID() int64 {
 	return id
 	return id
 }
 }
 
 
-func MachineID() string {
+func SystemUUID() string {
 	for _, p := range []string{"sys/devices/virtual/dmi/id/product_uuid", "etc/machine-id", "var/lib/dbus/machine-id"} {
 	for _, p := range []string{"sys/devices/virtual/dmi/id/product_uuid", "etc/machine-id", "var/lib/dbus/machine-id"} {
 		payload, err := os.ReadFile(path.Join("/proc/1/root", p))
 		payload, err := os.ReadFile(path.Join("/proc/1/root", p))
 		if err != nil {
 		if err != nil {

+ 8 - 8
utils/modelse/node.go

@@ -5,14 +5,14 @@ import (
 )
 )
 
 
 type NodeInfoT struct {
 type NodeInfoT struct {
-	Hostname      string
-	HostIp        string
-	KernelVersion string
-	SystemUUID    string
-	HostID        int64
-	AccountID     int
-	LicenseKey    string
-	Lock          sync.RWMutex
+	Hostname      string       `json:"hostname"`
+	HostIp        string       `json:"host_ip"`
+	KernelVersion string       `json:"kernel_version"`
+	SystemUUID    string       `json:"system_uuid"`
+	HostID        int64        `json:"host_id"`
+	AccountID     int          `json:"account_id"`
+	LicenseKey    string       `json:"license_key"`
+	Lock          sync.RWMutex `json:"lock,omitempty"`
 }
 }
 
 
 type NodeInfoInterface interface {
 type NodeInfoInterface interface {

+ 1 - 1
utils/worker/proxySender.go

@@ -200,7 +200,7 @@ func (c *Client) SetEndpoint(endPointStr string, ssl bool) error {
 		if !strings.HasPrefix(server, phonetic) {
 		if !strings.HasPrefix(server, phonetic) {
 			server = fmt.Sprintf("%s://%s", phonetic, server)
 			server = fmt.Sprintf("%s://%s", phonetic, server)
 		}
 		}
-		log.WithField("module", "proxy").Debugf("proxy server %s", server)
+		log.WithField("module", "proxy").Infof("proxy server %s", server)
 		endpoints = append(endpoints, &Endpoint{
 		endpoints = append(endpoints, &Endpoint{
 			Url:       server,
 			Url:       server,
 			FailCount: 0,
 			FailCount: 0,

+ 4 - 0
utils/worker/serverWorker.go

@@ -3,6 +3,7 @@ package worker
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
+	"github.com/coroot/coroot-node-agent/flags"
 	"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"
 	log "github.com/sirupsen/logrus"
 	log "github.com/sirupsen/logrus"
@@ -104,6 +105,7 @@ type ServerHTTPWorker struct {
 	connectList     []string
 	connectList     []string
 	tokenList       []string
 	tokenList       []string
 	//nodeInfo 		*NodeInfo
 	//nodeInfo 		*NodeInfo
+	prefix      string
 	proxyClient *Client
 	proxyClient *Client
 }
 }
 
 
@@ -116,6 +118,7 @@ func NewServerHTTPWorker() (*ServerHTTPWorker, error) {
 		//tokenList:    strings.Split(token, ","),
 		//tokenList:    strings.Split(token, ","),
 		mux: new(sync.Mutex),
 		mux: new(sync.Mutex),
 	}
 	}
+	s.prefix = *flags.ServerPrefix
 	s.proxyClient, _ = GetProxyClient()
 	s.proxyClient, _ = GetProxyClient()
 	//s.nodeInfo,_ = node.GetNodeInfo()
 	//s.nodeInfo,_ = node.GetNodeInfo()
 	return s, nil
 	return s, nil
@@ -338,6 +341,7 @@ func NewServerHTTPWorker() (*ServerHTTPWorker, error) {
 //		return w.currentIndex
 //		return w.currentIndex
 //	}
 //	}
 func (w *ServerHTTPWorker) requestServer(uri string, data interface{}) ([]byte, error) {
 func (w *ServerHTTPWorker) requestServer(uri string, data interface{}) ([]byte, error) {
+	uri = w.prefix + uri
 	byteData, err := json.Marshal(data)
 	byteData, err := json.Marshal(data)
 	if err != nil {
 	if err != nil {
 		log.WithError(err).Errorf("[requestServer] marshal request error.")
 		log.WithError(err).Errorf("[requestServer] marshal request error.")