Răsfoiți Sursa

Feature #TASK_QT-18250 中央国债验证POC

Feature #TASK_QT-18250 中央国债arm 5.0验证

Feature #TASK_QT-18250 中央国债arm 5.0验证

Feature #TASK_QT-18250 中央国债arm 5.0验证

Feature #TASK_QT-18250 中央国债arm 5.0验证
Carl 11 luni în urmă
părinte
comite
0075ad0f6c

+ 2 - 2
Dockerfile

@@ -1,8 +1,8 @@
-FROM ubuntu:22.04
+FROM dockerproxy.net/library/ubuntu:22.04
 ARG EUSPACE_BASE_PATH=/opt/cloudwise/apm/euspace
 RUN mkdir -p $EUSPACE_BASE_PATH
 #拷贝安装目录结构
-ADD ./dist/package_dir/  $EUSPACE_BASE_PATH/
+ADD ./dist/x86_64/package_dir/  $EUSPACE_BASE_PATH/
 ARG EUSPACE_BIN_PATH=$EUSPACE_BASE_PATH/bin
 # 拷贝euspace可执行文件,make直接生成到dist/package_dir/bin/euspace
 #COPY ./euspace $EUSPACE_BIN_PATH/

+ 15 - 0
Dockerfile.arm64

@@ -0,0 +1,15 @@
+FROM harbor.cloudwise.com/apm/euspace-base:22.04-arm64
+ARG EUSPACE_BASE_PATH=/opt/cloudwise/apm/euspace
+RUN mkdir -p $EUSPACE_BASE_PATH
+RUN uname -m && cat /etc/os-release
+
+# 拷贝安装目录结构
+ADD ./dist/aarch64/package_dir/  $EUSPACE_BASE_PATH/
+
+ARG EUSPACE_BIN_PATH=$EUSPACE_BASE_PATH/bin
+#COPY ./euspace $EUSPACE_BIN_PATH/
+
+WORKDIR $EUSPACE_BASE_PATH
+ENV PATH=$PATH:$EUSPACE_BIN_PATH
+
+ENTRYPOINT ["euspace"]

+ 2 - 1
Makefile

@@ -30,9 +30,10 @@ endif
 
 GIT_COMMIT=$(shell git rev-parse --short HEAD)
 BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
+ARCH=$(shell uname -m)
 
 # Set Version
-TARGET_FILE=dist/package_dir/bin/euspace
+TARGET_FILE=dist/${ARCH}/package_dir/bin/euspace
 GO_LD_FLAGS_VERSION=-X github.com/coroot/coroot-node-agent/flags.AgentVersion=${VERSION}
 GO_LD_FLAGS_GIT_COMMIT=-X github.com/coroot/coroot-node-agent/flags.GitCommit=${GIT_COMMIT}
 GO_LD_FLAGS_BUILD_DATE=-X github.com/coroot/coroot-node-agent/flags.BuildDate=${BUILD_DATE}

+ 9 - 0
containers/apm_register_app.go

@@ -2,6 +2,7 @@ package containers
 
 import (
 	"fmt"
+	"github.com/coroot/coroot-node-agent/flags"
 	"github.com/coroot/coroot-node-agent/utils"
 	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	klog "github.com/sirupsen/logrus"
@@ -9,6 +10,14 @@ import (
 )
 
 func (c *Container) RegisterAppInfo(r *Registry, pid uint32) error {
+	if *flags.Test {
+		c.AppInfo.AppName = c.WhiteSettingInfo.AppName
+		c.AppInfo.AppIdHash.IntVal, _ = utils.BuildInt64ID(c.WhiteSettingInfo.AppName).ToInt64()
+		c.AppInfo.AppIdHash.HashtVal = utils.BuildInt64ID(c.WhiteSettingInfo.AppName).ToHashByte()
+		c.AppInfo.CodeType = CodeTypeJava
+		c.AppInfo.SetAppSuccess()
+		return nil
+	}
 	if r.isFusing {
 		return fmt.Errorf("euspace in fusing can not to regist app")
 	}

+ 2 - 2
containers/apm_stack_dispatch.go

@@ -145,7 +145,7 @@ func (c *Container) jvmStackTrace(tracer *ebpftracer.Tracer, pid uint32) error {
 		return fmt.Errorf("[jvmStackTrace] Unsupported Java version")
 	}
 
-	err = tracer.JattachJvm(pid, c.AppInfo, c.WhiteSettingInfo.WhiteStackSettingInfo.WhiteList, c.WhiteSettingInfo.WhiteStackSettingInfo.BlackList)
+	err = tracer.JattachJvm(pid, c.AppInfo, c.WhiteSettingInfo.WhiteStackSettingInfo.WhiteList, c.WhiteSettingInfo.WhiteStackSettingInfo.BlackList, c.getRootfs())
 	if err != nil {
 		p.stackStatus.JattachFailure()
 		return err
@@ -153,7 +153,7 @@ func (c *Container) jvmStackTrace(tracer *ebpftracer.Tracer, pid uint32) error {
 		p.stackStatus.JattachSuccess()
 	}
 
-	jvmStackProbes, err := tracer.AttachJVMStackUprobes(pid, c.AppInfo)
+	jvmStackProbes, err := tracer.AttachJVMStackUprobes(pid, c.AppInfo, c.getRootfs())
 
 	if err != nil {
 		p.stackStatus.StackUprobesFailure()

+ 8 - 4
containers/container.go

@@ -652,7 +652,7 @@ func (c *Container) onListenClose(pid uint32, addr netaddr.IPPort) {
 }
 
 func (c *Container) onAcceptOpen(pid uint32, fd uint64, src, dst netaddr.IPPort, timestamp uint64, failed bool, duration time.Duration) {
-	klog.Debugf("accept pid=%d id=%s dstaddr=%s srcaddr=%s", pid, c.id, dst.IP(), src.IP())
+	//klog.Debugf("accept pid=%d id=%s dstaddr=%s srcaddr=%s", pid, c.id, dst.IP(), src.IP())
 	// if common.PortFilter.ShouldBeSkipped(dst.Port()) {
 	// 	return
 	// }
@@ -1427,8 +1427,8 @@ func (c *Container) revalidateListens(now time.Time, actualListens map[netaddr.I
 	}
 }
 
-func (c *Container) AttachUprobes(tracer *ebpftracer.Tracer, pid uint32) error {
-	klog.Infoln("[attach] attachUprobes start")
+func (c *Container) AttachUprobes(tracer *ebpftracer.Tracer, pid uint32, _type string) error {
+	klog.Infoln("[attach] attachUprobes start by :", _type)
 	if tracer.DisableL7Tracing() {
 		return nil
 	}
@@ -1448,7 +1448,11 @@ func (c *Container) AttachUprobes(tracer *ebpftracer.Tracer, pid uint32) error {
 		err = c.attachNetCoreUprobes(tracer, pid)
 	}
 	if err != nil {
-		c.DetachUprobes(tracer, pid, APP_UPROBE_ERROR)
+		klog.Errorf("[attach] error  %v :", err)
+		deErr := c.DetachUprobes(tracer, pid, APP_UPROBE_ERROR)
+		if deErr != nil {
+			klog.Errorf("[attach] Detach Uprobes error  %v :", deErr)
+		}
 		return err
 	}
 	return nil

+ 2 - 2
containers/container_apm.go

@@ -108,7 +108,7 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 	//if !c.valuableTrace(r.TraceId) {
 	//	return nil
 	//}
-	// klog.Infof("====ProtocolTrace+++++ start==== %d %d", pid, r.TraceId)
+	//klog.Infof("====ProtocolTrace+++++ start==== %d %d", pid, r.TraceId)
 	// klog.Infof("====ProtocolTrace===== start==== %d %d", r.Protocol == l7.ProtocolTrace, c.l7Attach)
 	if r.Protocol == l7.ProtocolTrace && c.l7Attach && c.valuableTrace(r.TraceId) {
 		// klog.Infof("====ProtocolTrace---- start==== %d %d", pid, r.TraceId)
@@ -841,7 +841,7 @@ func (c *Container) AgentCtrl(r *Registry, pid uint32) {
 			return
 		}
 		klog.WithField("pid", pid).Infoln("[AgentCtrl] Attach uprobes.")
-		err = c.AttachUprobes(r.tracer, pid)
+		err = c.AttachUprobes(r.tracer, pid, "Agentctrl")
 		if err != nil {
 			klog.WithField("pid", pid).WithError(err).Errorf("[AgentCtrl] Failed attach uprobes error!")
 			return

+ 2 - 2
containers/process.go

@@ -5,7 +5,6 @@ import (
 	"context"
 	"fmt"
 	"github.com/coroot/coroot-node-agent/ebpftracer/tracer/jattach"
-	"github.com/coroot/coroot-node-agent/utils"
 	. "github.com/coroot/coroot-node-agent/utils/modelse"
 	"os"
 	"path/filepath"
@@ -163,7 +162,8 @@ func (p *Process) DynamicClose(closeType int) {
 
 func (p *Process) uninstallJavaAgent() error {
 	if p.codeType.IsJvmCode() && p.stackAttachOnce {
-		nativeBasePath := utils.GetDefaultAgentsPath("NativeAgent")
+		//nativeBasePath := utils.GetDefaultAgentsPath("NativeAgent")
+		nativeBasePath := "/tmp/NativeAgent"
 		kvPairs := []string{
 			fmt.Sprintf("%s=%s", filepath.Join(nativeBasePath, "lib", "apmAgent.jar"), nativeBasePath),
 			"UNINSTALL",

+ 11 - 4
containers/registry.go

@@ -206,6 +206,10 @@ func (r *Registry) Close() {
 
 func (r *Registry) CloseContainers() {
 	for pid, c := range r.containersByPid {
+		if c == nil {
+			klog.Warnf("container for pid %d is nil, skipping", pid)
+			continue
+		}
 		if c.Isl7AttachSuccess() {
 			c.Detach(r.tracer, pid, APP_UNINSTALL)
 		}
@@ -357,7 +361,7 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 							klog.WithError(err).Errorf("[registry] Failed registerAppInfo. pid is %d", e.Pid)
 							continue
 						}
-						err = c.AttachUprobes(r.tracer, e.Pid)
+						err = c.AttachUprobes(r.tracer, e.Pid, "Listen Open Event")
 						if err != nil {
 							klog.WithField("pid", e.Pid).WithError(err).Errorf("[AttachUprobes] [end] Failed attach stack trace!")
 						}
@@ -390,12 +394,15 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 					}
 					if common.IsOpenFilter() && common.IsFilterPid(e.Pid) {
 						c.WhiteSettingInfo.AppName = enums.TestApp
+						if os.Getenv("APP_NAME") != "" {
+							c.WhiteSettingInfo.AppName = os.Getenv("APP_NAME")
+						}
 						err := c.RegisterAppInfo(r, e.Pid)
 						if err != nil {
 							klog.WithError(err).Errorf("[registry] Failed registerAppInfo. pid is %d", e.Pid)
 							continue
 						}
-						err = c.AttachUprobes(r.tracer, e.Pid)
+						err = c.AttachUprobes(r.tracer, e.Pid, "Connection Open Event")
 						if err != nil {
 							klog.WithField("pid", e.Pid).WithError(err).Errorf("[AttachUprobes] [end] Failed attach stack trace!")
 						}
@@ -410,7 +417,7 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 						}
 					}
 				} else {
-					klog.Infoln("TCP connection from unknown container", e)
+					klog.Debugln("TCP connection from unknown container", e)
 				}
 			case ebpftracer.EventTypeListenClose:
 				if c := r.containersByPid[e.Pid]; c != nil {
@@ -439,7 +446,7 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 				}
 			case ebpftracer.EventTypeL7Request:
 
-				//fmt.Println("e.L7Request Payload:", string(e.L7Request.Payload))
+				fmt.Println("e.L7Request Payload:", string(e.L7Request.Payload))
 				if e.L7Request == nil {
 					continue
 				}

BIN
dist/package_dir/agents/NativeAgent/plugins/cloudwise-javacode-plugin-ssl-socket.jar


+ 12 - 0
ebpftracer/bindata_linux_arm64.go

@@ -6,13 +6,25 @@ package ebpftracer
 import (
 	"embed"
 	"fmt"
+	"github.com/coroot/coroot-node-agent/flags"
 	"golang.org/x/mod/semver"
+	"os"
 )
 
 //go:embed ebpf/bin/arm64
 var binData embed.FS
 
 func EbpfCode(v string) (string, []byte, error) {
+	if *flags.EbpfFilePath != "" {
+		filePath := *flags.EbpfFilePath
+		// Construct the full path to the desired file
+		data, err := os.ReadFile(filePath)
+		if err != nil {
+			return "", nil, err
+		}
+		return filePath, data, nil
+	}
+
 	var filePath string
 	var err error
 	versions := []string{"v5.12", "v5.6", "v4.20", "v4.16"}

+ 27 - 38
ebpftracer/ebpf/l7/l7.c

@@ -699,17 +699,14 @@ int trace_enter_write(void *ctx, __u64 fd, __u16 is_tls, char *buf, __u64 size,
 }
 
 static inline __attribute__((__always_inline__))
-int trace_enter_read(__u64 id, __u32 pid, __u64 fd, char *buf, __u64 *ret, __u64 iovlen) {
-    // struct connection_id cid = {};
-    // cid.pid = pid;
-    // cid.fd = fd;
-
-    // struct connection *conn = bpf_map_lookup_elem(&active_connections, &cid);
-    // if (!conn) {
-    //     // cw_bpf_debug("trace_enter_read no conn\n");
-    //     return 0;
-    // }
-    struct read_args args = {};
+int trace_enter_read(int _type , __u64 fd, char *buf, __u64 *ret, __u64 iovlen) {
+	__u64 id = bpf_get_current_pid_tgid();
+	__u32 pid = id >> 32;
+
+	if (load_filter_pid() != 0 && pid != load_filter_pid()) {
+		return 0;
+	}
+	struct read_args args = {};
     args.fd = fd;
     args.buf = buf;
     args.ret = ret;
@@ -726,10 +723,12 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
         return 0;
     }
 
+
     struct read_args *args = bpf_map_lookup_elem(&active_reads, &id);
     if (!args) {
         return 0;
     }
+
     struct l7_request_key k = {};
     k.pid = pid;
     k.fd = args->fd;
@@ -764,10 +763,11 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
         }
     }
 
-    struct l7_event *e = bpf_map_lookup_elem(&l7_event_heap, &zero);
+	struct l7_event *e = bpf_map_lookup_elem(&l7_event_heap, &zero);
     if (!e) {
         return 0;
     }
+
     e->fd = k.fd;
     e->pid = k.pid;
     e->protocol = PROTOCOL_UNKNOWN;
@@ -776,27 +776,16 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
     e->statement_id = 0;
     e->payload_size = 0;
     e->trace_id = 0;
+
 	__u8 b[8];
-	bpf_read(payload, b);
-//    __u32 k0 = 0;
-//    struct member_fields_offset *offset = members_offset__lookup(&k0);
-//    if (!offset)
-//        return -1;
-//    void *sk = get_socket_from_fd(args->fd, offset);
-//    struct conn_info_t *conn_info, __conn_info = { 0 };
-//    conn_info = &__conn_info;
-////
-//    init_conn_info(id >> 32, args->fd, &__conn_info, sk, offset);
-////
-//    infer_dns_message(payload, (int)PT_REGS_RC((struct pt_regs *)ctx),
-//                      conn_info);
+//	bpf_read(payload, b);
 
     struct connection_id cid = {};
     cid.pid = pid;
     cid.fd = args->fd;
     // 被调用方http入口
     // 作为服务端在走。coroot 原有逻辑是没有的
-    if (is_http_request(payload)) {
+	if (is_http_request(payload)) {
 
         //处理http请求之前,确认进程信息是否存在
         struct ebpf_proc_info *proc_info = bpf_map_lookup_elem(&proc_info_map, &pid);
@@ -846,7 +835,7 @@ int trace_exit_read(void *ctx, __u64 id, __u32 pid, __u16 is_tls, long int ret)
         e->protocol = PROTOCOL_TRACE;
         e->trace_id = trace_info.trace_id;
 	    cw_bpf_debug("\n");
-	    cw_bpf_debug("[Trace Start in l7][HTTP]pid:[%d]--[%lld]--trace_id:%llu\n", tid, bpf_ktime_get_ns(),trace_info.trace_id);
+		cw_bpf_debug("[Trace Start in l7][HTTP]pid:[%d]--[%lld]--trace_id:%llu\n", tid, bpf_ktime_get_ns(),trace_info.trace_id);
 	    cw_bpf_debug("[Trace Start in l7][Receive][HTTP]pid:[%d]|GOID:[%d]|FD:%d|Trace:%llu\n", tid, trace_info.trace_key.goid,k.fd);
         e->payload_size = ret;
         COPY_PAYLOAD(e->payload, ret, payload);
@@ -1268,34 +1257,34 @@ int sys_enter_sendto(struct trace_event_raw_sys_enter_rw__stub* ctx) {
 
 SEC("tracepoint/syscalls/sys_enter_read")
 int sys_enter_read(struct trace_event_raw_sys_enter_rw__stub* ctx) {
-    __u64 id = bpf_get_current_pid_tgid();
-    __u32 pid = id >> 32;
-    return trace_enter_read(id, pid, ctx->fd, ctx->buf, 0, 0);
+//    __u64 id = bpf_get_current_pid_tgid();
+//    __u32 pid = id >> 32;
+	return trace_enter_read(1, ctx->fd, ctx->buf, 0, 0);
 }
 
 SEC("tracepoint/syscalls/sys_enter_readv")
 int sys_enter_readv(struct trace_event_raw_sys_enter_rw__stub* ctx) {
-    __u64 id = bpf_get_current_pid_tgid();
-    __u32 pid = id >> 32;
-    return trace_enter_read(id, pid, ctx->fd, ctx->buf, 0, ctx->size);
+//    __u64 id = bpf_get_current_pid_tgid();
+//    __u32 pid = id >> 32;
+    return trace_enter_read(2, ctx->fd, ctx->buf, 0, ctx->size);
 }
 
 SEC("tracepoint/syscalls/sys_enter_recvmsg")
 int sys_enter_recvmsg(struct trace_event_raw_sys_enter_rw__stub* ctx) {
-    __u64 id = bpf_get_current_pid_tgid();
+//    __u64 id = bpf_get_current_pid_tgid();
     struct l7_user_msghdr msghdr = {};
     if (bpf_probe_read(&msghdr, sizeof(msghdr), (void *)ctx->buf)) {
         return 0;
     }
-    __u32 pid = id >> 32;
-    return trace_enter_read(id, pid, ctx->fd, (char*)msghdr.msg_iov, 0, msghdr.msg_iovlen);
+//    __u32 pid = id >> 32;
+	return trace_enter_read(3, ctx->fd, (char *) msghdr.msg_iov, 0, msghdr.msg_iovlen);
 }
 
 SEC("tracepoint/syscalls/sys_enter_recvfrom")
 int sys_enter_recvfrom(struct trace_event_raw_sys_enter_rw__stub* ctx) {
     __u64 id = bpf_get_current_pid_tgid();
-    __u32 pid = id >> 32;
-    return trace_enter_read(id, pid, ctx->fd, ctx->buf, 0, 0);
+//    __u32 pid = id >> 32;
+    return trace_enter_read(4, ctx->fd, ctx->buf, 0, 0);
 }
 
 SEC("tracepoint/syscalls/sys_exit_read")

+ 5 - 6
ebpftracer/ebpf/utrace/java/net/client.probe.bpf.c

@@ -60,14 +60,13 @@ int uprobe_Java_java_net_SocketOutputStream_socketWrite0(struct pt_regs *ctx) {
 
 	void *len_from_rbp_ptr = (void *) PT_LEN_REGS(ctx);
 
-	void *len_ptr = 0;
+	int len_val = 0;
 	cw_bpf_debug("[java client] address: len_from_rbp_ptr<0x%lx>\n", len_from_rbp_ptr);
 
-	bpf_probe_read(&len_ptr, sizeof(len_ptr), (void *) len_from_rbp_ptr);
-	cw_bpf_debug("[java client] [len_ptr] before addr<0x%lx>, %d \n", len_from_rbp_ptr, len_ptr);
-
-	if ((long) len_ptr != data_count) {
-		cw_bpf_debug("[java client] [len_ptr] check error.");
+	bpf_probe_read(&len_val, sizeof(len_val), (void *) len_from_rbp_ptr);
+	cw_bpf_debug("[java client] [len_val] before addr<0x%lx>, %d \n", len_from_rbp_ptr, len_val);
+	if (len_val != data_count) {
+		cw_bpf_debug("len check failed: len_val=%d data_count=%d", len_val, data_count);
 		return 0;
 	}
 

+ 1 - 1
ebpftracer/jvm.go

@@ -193,7 +193,7 @@ func (t *Tracer) AttachJavaNetWriteUprobes(pid uint32, rootfs string) ([]link.Li
 	klog.Infof("[jvm] ReleaseLibNetInfo :[%s]", utils.ToString(jvmInjector.ReleaseLibNetInfo))
 	klog.Infof("[jvm] DebugLibNetInfo :[%s]", utils.ToString(jvmInjector.DebugLibNetInfo))
 	if err != nil {
-		klog.WithError(err).Errorf("[jvm] inject.JvmInject error.")
+		klog.WithError(err).Errorf("[jvm] inject.JvmInject error. Rootfs = [%s]", rootfs)
 		return nil, err
 	}
 

+ 5 - 3
ebpftracer/stack.go

@@ -51,7 +51,7 @@ func (t *Tracer) AttachStackUprobes(path string, uprobes []tracer.Uprobe) []link
 }
 
 // JVM process stack
-func (t *Tracer) JattachJvm(pid uint32, appInfo AppInfo, whiteList, blackList string) error {
+func (t *Tracer) JattachJvm(pid uint32, appInfo AppInfo, whiteList, blackList, rootfs string) error {
 	klog.Infoln("[Jvm stack uprobe] Attach Start AttachJVMStackUprobes", pid)
 	// TODO tiny Agent 注入
 	// TODO copy agent到 jre conf/lib/plugins
@@ -70,7 +70,8 @@ func (t *Tracer) JattachJvm(pid uint32, appInfo AppInfo, whiteList, blackList st
 	} else {
 		stackRule = fmt.Sprintf("whiteStack=%s,blackStack=%s", whiteList, blackList)
 	}
-	nativeBasePath := utils.GetDefaultAgentsPath("NativeAgent")
+	//nativeBasePath := utils.GetDefaultAgentsPath("NativeAgent")
+	nativeBasePath := "/tmp/NativeAgent"
 	kvPairs := []string{
 		fmt.Sprintf("%s=%s", filepath.Join(nativeBasePath, "lib", "apmAgent.jar"), nativeBasePath),
 		fmt.Sprintf("%s=%d", "appId", appInfo.AppIdHash.IntVal),
@@ -98,7 +99,7 @@ func (t *Tracer) JattachJvm(pid uint32, appInfo AppInfo, whiteList, blackList st
 	return nil
 }
 
-func (t *Tracer) AttachJVMStackUprobes(pid uint32, appInfo AppInfo) ([]link.Link, error) {
+func (t *Tracer) AttachJVMStackUprobes(pid uint32, appInfo AppInfo, rootfs string) ([]link.Link, error) {
 
 	//path = utils.GetDefaultAgentsPath("NativeAgent", "libnativeAgent.so")
 	//tmp/NativeAgentSo2297066477572820801.tmp
@@ -107,6 +108,7 @@ func (t *Tracer) AttachJVMStackUprobes(pid uint32, appInfo AppInfo) ([]link.Link
 		klog.Error(err)
 		return nil, err
 	}
+	path = filepath.Join(rootfs, path)
 
 	setNodeEnter := "Java_com_cloudwise_agent_common_natives_TraceNative_setNodeEnter"
 	setNodeReturn := "Java_com_cloudwise_agent_common_natives_TraceNative_setNodeReturn"

+ 11 - 5
ebpftracer/tracer.go

@@ -157,12 +157,18 @@ type Tracer struct {
 func NewTracer(kernelVersion string, disableL7Tracing, disableE2ETracing, disableStackTracing bool) *Tracer {
 	if disableL7Tracing {
 		klog.Infoln("L7 tracing is disabled")
+	} else {
+		klog.Infoln("L7 tracing is enabled")
 	}
 	if disableE2ETracing {
-		klog.Infoln("L7 tracing is disabled")
+		klog.Infoln("e2e is disabled")
+	} else {
+		klog.Infoln("e2e is enabled")
 	}
 	if disableStackTracing {
 		klog.Infoln("L7 stack is disabled")
+	} else {
+		klog.Infoln("L7 stack is enabled")
 	}
 	return &Tracer{
 		kernelVersion:       kernelVersion,
@@ -762,8 +768,8 @@ func runEventsReader(name string, r *perf.Reader, ch chan<- Event, typ perfMapTy
 				ComponentDAddr: ipPort(v.ComponentDAddr, v.ComponentDport),
 			}
 			if req.Protocol == l7.ProtocolHTTP {
-				klog.Infof("runEventsReader ComponentSAddr.String %s", req.ComponentSAddr.String())
-				klog.Infof("runEventsReader ComponentDAddr.String %s", req.ComponentDAddr.String())
+				klog.Debugf("runEventsReader ComponentSAddr.String %s", req.ComponentSAddr.String())
+				klog.Debugf("runEventsReader ComponentDAddr.String %s", req.ComponentDAddr.String())
 			}
 			if v.TraceEnd == 1 {
 				req.ParentSpanContext.TraceIdFrom = hex.EncodeToString(v.TraceIdFrom[:])
@@ -773,8 +779,8 @@ func runEventsReader(name string, r *perf.Reader, ch chan<- Event, typ perfMapTy
 				req.ParentSpanContext.SpanIdFrom = hex.EncodeToString(v.SpanIdFrom[:])
 				req.SAddr = ipPort(v.SAddr, v.Sport)
 				req.DAddr = ipPort(v.DAddr, v.Dport)
-				klog.Infof("runEventsReader SAddr.String %s", req.SAddr.String())
-				klog.Infof("runEventsReader DAddr.String %s", req.DAddr.String())
+				klog.Debugf("runEventsReader SAddr.String %s", req.SAddr.String())
+				klog.Debugf("runEventsReader DAddr.String %s", req.DAddr.String())
 			}
 			switch {
 			case v.PayloadSize == 0:

+ 223 - 0
ebpftracer/tracer/inject/inject.go

@@ -0,0 +1,223 @@
+package inject
+
+import (
+	"bufio"
+	"debug/elf"
+	"fmt"
+	klog "github.com/sirupsen/logrus"
+	"io"
+	"io/fs"
+	"os"
+	"path/filepath"
+	"strings"
+	"syscall"
+)
+
+type LibNetInfo struct {
+	LibName      string
+	LibPath      string
+	FuncSymbol   InstInfo
+	InnerSymbol  InnerSymbolInfo
+	ProcLoadPath string
+	FileDeleted  bool
+	MapFile      string
+}
+
+type UprobeData struct {
+	Offset  int
+	Func    string
+	ELFPath string
+}
+
+type JvmInjector struct {
+	Pid               int
+	ReleaseLibNetInfo LibNetInfo
+	DebugLibNetInfo   LibNetInfo
+	RecodeInfo        LibNetInfo
+	// 原方法首个指令不为jmp | ReleaseLibNetInfo 读取无异常
+	PreCheck struct {
+		NeedInjectionCheck bool // 原指令校验 true表示可以继续执行注入
+		LoadingCheck       bool // true 表示加载成功
+		IoFdCheck          bool // fd地址校验
+		NetSendFuncCheck   bool // netsend校验
+		EbpfCanInjection   bool // 满足则注入ebpf
+	}
+	AfterCheck struct {
+		IoFdCheck        bool
+		NetSendFuncCheck bool
+	}
+	Uprobe UprobeData
+	Rootfs string
+}
+
+func FindLibBaseByPathFromProcMaps(pid int, libPath string) (uint64, string, error) {
+	mapsFile := fmt.Sprintf("/proc/%d/maps", pid)
+	file, err := os.Open(mapsFile)
+	if err != nil {
+		return 0, "", err
+	}
+	defer file.Close()
+	var start, end uint64
+	scanner := bufio.NewScanner(file)
+	for scanner.Scan() {
+		line := scanner.Text()
+		if strings.Contains(line, libPath) {
+			fmt.Sscanf(line, "%x-%x", &start, &end)
+			fields := strings.Fields(line)
+			if len(fields) > 5 {
+				path := fields[5]
+				if strings.HasSuffix(path, ".so") {
+					return start, path, nil
+				}
+			}
+		}
+	}
+
+	return 1, "", fmt.Errorf("library %s not found in process.", libPath)
+}
+
+func FindLibBaseFromProcMaps(pid int, libName string) (uint64, string, string, bool, error) {
+	mapsFile := fmt.Sprintf("/proc/%d/maps", pid)
+	file, err := os.Open(mapsFile)
+	if err != nil {
+		return 0, "", "", false, err
+	}
+	defer file.Close()
+	var start, end uint64
+	var deleted bool
+	scanner := bufio.NewScanner(file)
+	for scanner.Scan() {
+		line := scanner.Text()
+		if strings.Contains(line, "/"+libName) {
+			fmt.Sscanf(line, "%x-%x", &start, &end)
+			fields := strings.Fields(line)
+			if len(fields) > 5 {
+				path := fields[5]
+				if len(fields) > 6 && fields[6] == "(deleted)" {
+					deleted = true
+				}
+				if strings.HasSuffix(path, ".so") {
+					klog.Infof("[inject] found library in map %s", path)
+					return start, path, fmt.Sprintf("/proc/%d/map_files/%s", pid, fields[0]), deleted, nil
+				}
+			}
+		}
+	}
+
+	return 1, "", "", false, fmt.Errorf("[FindLibBaseFromProcMaps] library %s not found", libName)
+}
+
+func CopyFileAndMatchPermissions(srcFile, destFile, permFile string) error {
+	// 获取权限参考文件的信息
+	permInfo, err := os.Stat(permFile)
+	if err != nil {
+		return fmt.Errorf("failed to stat permission file: %w", err)
+	}
+	mode := permInfo.Mode()
+	uid, gid := -1, -1
+	if stat, ok := permInfo.Sys().(*syscall.Stat_t); ok {
+		uid = int(stat.Uid)
+		gid = int(stat.Gid)
+	}
+
+	srcInfo, err := os.Stat(srcFile)
+	if err != nil {
+		return fmt.Errorf("failed to stat source file/dir: %w", err)
+	}
+
+	if srcInfo.IsDir() {
+		// 复制整个目录
+		return filepath.WalkDir(srcFile, func(path string, d fs.DirEntry, err error) error {
+			if err != nil {
+				return err
+			}
+			relPath, err := filepath.Rel(srcFile, path)
+			if err != nil {
+				return err
+			}
+			targetPath := filepath.Join(destFile, relPath)
+
+			if d.IsDir() {
+				if err := os.MkdirAll(targetPath, mode); err != nil {
+					return fmt.Errorf("failed to create directory %s: %w", targetPath, err)
+				}
+				if uid >= 0 && gid >= 0 {
+					if err := os.Chown(targetPath, uid, gid); err != nil {
+						return fmt.Errorf("failed to set directory ownership: %w", err)
+					}
+				}
+			} else {
+				if err := copyOneFile(path, targetPath, mode, uid, gid); err != nil {
+					return fmt.Errorf("failed to copy file %s: %w", path, err)
+				}
+			}
+			return nil
+		})
+	} else {
+		// 复制单个文件
+		return copyOneFile(srcFile, destFile, mode, uid, gid)
+	}
+}
+
+func copyOneFile(src, dst string, mode os.FileMode, uid, gid int) error {
+	in, err := os.Open(src)
+	if err != nil {
+		return fmt.Errorf("failed to open source file: %w", err)
+	}
+	defer in.Close()
+
+	// 创建父目录
+	if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
+		return fmt.Errorf("failed to create parent directory: %w", err)
+	}
+
+	out, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
+	if err != nil {
+		return fmt.Errorf("failed to create destination file: %w", err)
+	}
+	defer out.Close()
+
+	if _, err := io.Copy(out, in); err != nil {
+		return fmt.Errorf("failed to copy file content: %w", err)
+	}
+
+	if uid >= 0 && gid >= 0 {
+		if err := out.Chown(uid, gid); err != nil {
+			return fmt.Errorf("failed to set file ownership: %w", err)
+		}
+	}
+	return nil
+}
+func GetFunctionOffset(libPath, functionName string) (elf.Symbol, error) {
+	elfFile, err := elf.Open(libPath)
+	if err != nil {
+		return elf.Symbol{}, fmt.Errorf("failed to open ELF file: %v", err)
+	}
+	defer elfFile.Close()
+
+	symbols, err := elfFile.DynamicSymbols()
+	if err != nil {
+		return elf.Symbol{}, fmt.Errorf("failed to read dynamic symbols: %v", err)
+	}
+
+	for _, sym := range symbols {
+		if sym.Name == functionName {
+			//fmt.Println("size:", sym.Size)
+			return sym, nil
+		}
+	}
+
+	//textSection := elfFile.Section(".text")
+	//if textSection == nil {
+	//	fmt.Println("textSection is null")
+	//	//return nil
+	//}
+	//textSectionData, err := textSection.Data()
+	//if err != nil {
+	//	fmt.Println("textSectionData error is", err)
+	//	//return nil
+	//}
+	//textSectionLen := uint64(len(textSectionData) - 1)
+
+	return elf.Symbol{}, fmt.Errorf("function %s not found", functionName)
+}

+ 16 - 86
ebpftracer/tracer/inject/inject_linux_amd64.go

@@ -16,7 +16,6 @@ import (
 	"github.com/coroot/coroot-node-agent/utils"
 	klog "github.com/sirupsen/logrus"
 	"golang.org/x/arch/x86/x86asm"
-	"io"
 	"os"
 	"path/filepath"
 	"strings"
@@ -46,43 +45,6 @@ type InnerSymbolInfo struct {
 	NET_Send   InstInfo
 }
 
-type LibNetInfo struct {
-	LibName      string
-	LibPath      string
-	FuncSymbol   InstInfo
-	InnerSymbol  InnerSymbolInfo
-	ProcLoadPath string
-	FileDeleted  bool
-	MapFile      string
-}
-
-type UprobeData struct {
-	Offset  int
-	Func    string
-	ELFPath string
-}
-
-type JvmInjector struct {
-	Pid               int
-	ReleaseLibNetInfo LibNetInfo
-	DebugLibNetInfo   LibNetInfo
-	RecodeInfo        LibNetInfo
-	// 原方法首个指令不为jmp | ReleaseLibNetInfo 读取无异常
-	PreCheck struct {
-		NeedInjectionCheck bool // 原指令校验 true表示可以继续执行注入
-		LoadingCheck       bool // true 表示加载成功
-		IoFdCheck          bool // fd地址校验
-		NetSendFuncCheck   bool // netsend校验
-		EbpfCanInjection   bool // 满足则注入ebpf
-	}
-	AfterCheck struct {
-		IoFdCheck        bool
-		NetSendFuncCheck bool
-	}
-	Uprobe UprobeData
-	Rootfs string
-}
-
 func (j *JvmInjector) findReleaseAddressInfoFromMem() error {
 	funcAbsAddress := j.ReleaseLibNetInfo.FuncSymbol.SymAddr
 	releaseFuncSym := InnerSymbolInfo{}
@@ -463,7 +425,7 @@ func findLibraryBasesList(pid int, libraryName string, libPath string) ([]uint64
 	return bases, nil
 }
 
-func (j *JvmInjector) findLibBaseFromProcMaps(libName string) (uint64, string, string, bool, error) {
+func (j *JvmInjector) findLibBaseFromProcMaps(pid int, libName string) (uint64, string, string, bool, error) {
 	mapsFile := fmt.Sprintf("/proc/%d/maps", j.Pid)
 	file, err := os.Open(mapsFile)
 	if err != nil {
@@ -558,7 +520,7 @@ func (j *JvmInjector) getFunctionOffset(libPath, functionName string) (elf.Symbo
 
 func (j *JvmInjector) InitProg() error {
 	// 获取release库的基地址
-	baseAddress, releaseSoFilePathInProc, mapFilesPath, deleted, err := j.findLibBaseFromProcMaps(j.ReleaseLibNetInfo.LibName)
+	baseAddress, releaseSoFilePathInProc, mapFilesPath, deleted, err := FindLibBaseFromProcMaps(j.Pid, j.ReleaseLibNetInfo.LibName)
 	//j.ReleaseLibNetInfo.LibPath = releaseSoFilePathInProc
 	j.ReleaseLibNetInfo.FileDeleted = deleted
 	j.ReleaseLibNetInfo.MapFile = mapFilesPath
@@ -581,13 +543,13 @@ func (j *JvmInjector) InitProg() error {
 
 	// find cwlibnet.so in proc maps
 	var readDebugSoPathInMaps string
-	_, readDebugSoPathInMaps, j.DebugLibNetInfo.MapFile, j.DebugLibNetInfo.FileDeleted, _ = j.findLibBaseFromProcMaps(j.DebugLibNetInfo.LibName)
+	_, readDebugSoPathInMaps, j.DebugLibNetInfo.MapFile, j.DebugLibNetInfo.FileDeleted, _ = FindLibBaseFromProcMaps(j.Pid, j.DebugLibNetInfo.LibName)
 	j.DebugLibNetInfo.LibPath = debugSoFilePhysicalPath
 	j.DebugLibNetInfo.ProcLoadPath = filepath.Join(jvmLibBaseDir, j.DebugLibNetInfo.LibName)
 	// condition create
 	pathFromProg := utils.GetDefaultLibsPath("jvm", j.DebugLibNetInfo.LibName)
 	if noFileErr != nil && readDebugSoPathInMaps == "" && !j.DebugLibNetInfo.FileDeleted {
-		err = copyFileAndMatchPermissions(pathFromProg, debugSoFilePhysicalPath, pJvmlibnetPhysicalPath)
+		err = CopyFileAndMatchPermissions(pathFromProg, debugSoFilePhysicalPath, pJvmlibnetPhysicalPath)
 		klog.Infof("[src:%s],[target:%s],[perm:%s]", pathFromProg, debugSoFilePhysicalPath, pJvmlibnetPhysicalPath)
 		if err != nil {
 			return err
@@ -600,7 +562,7 @@ func (j *JvmInjector) InitProg() error {
 	klog.Infof("[inject] Base address of [%s]:[%x]", j.ReleaseLibNetInfo.LibName, baseAddress)
 
 	// 获取函数的偏移量
-	functionSym, err := j.getFunctionOffset(pJvmlibnetPhysicalPath, functionName)
+	functionSym, err := GetFunctionOffset(pJvmlibnetPhysicalPath, functionName)
 
 	// 计算函数的实际内存地址
 	j.ReleaseLibNetInfo.FuncSymbol.SymAddr = baseAddress + functionSym.Value
@@ -631,7 +593,7 @@ func (j *JvmInjector) findDebugFuncContextFromLibPath() error {
 	//libName := j.DebugLibNetInfo.LibPath
 
 	// 获取release库的基地址
-	baseAddress, libPath, err := j.findLibBaseByPathFromProcMaps(j.DebugLibNetInfo.ProcLoadPath)
+	baseAddress, libPath, err := FindLibBaseByPathFromProcMaps(j.Pid, j.DebugLibNetInfo.ProcLoadPath)
 	klog.Infof("[inject] debug base address of [%s] : %x", libPath, baseAddress)
 	functionName := j.DebugLibNetInfo.FuncSymbol.SymName
 	//j.DebugLibNetInfo.LibPath = libPath
@@ -641,7 +603,7 @@ func (j *JvmInjector) findDebugFuncContextFromLibPath() error {
 	}
 
 	// 获取函数的偏移量
-	functionSym, err := j.getFunctionOffset(j.DebugLibNetInfo.LibPath, functionName)
+	functionSym, err := GetFunctionOffset(j.DebugLibNetInfo.LibPath, functionName)
 	// 计算函数的实际内存地址
 	j.DebugLibNetInfo.FuncSymbol.SymAddr = baseAddress + functionSym.Value
 	j.DebugLibNetInfo.FuncSymbol.SymSize = functionSym.Size
@@ -846,7 +808,7 @@ func JvmInject(jvmInjector *JvmInjector) error {
 		return err
 	}
 	printCodeData(jvmInjector.ReleaseLibNetInfo)
-	_type, _, err := jvmInjector.findLibBaseByPathFromProcMaps(jvmInjector.DebugLibNetInfo.ProcLoadPath)
+	_type, _, err := FindLibBaseByPathFromProcMaps(pid, jvmInjector.DebugLibNetInfo.ProcLoadPath)
 	if err != nil {
 		// load so
 		if _type == 1 {
@@ -861,6 +823,7 @@ func JvmInject(jvmInjector *JvmInjector) error {
 			}
 		}
 	} else {
+		klog.Infoln("[inject] so already loaded.")
 		jvmInjector.PreCheck.LoadingCheck = true
 	}
 
@@ -876,7 +839,13 @@ func JvmInject(jvmInjector *JvmInjector) error {
 	}
 
 	if !jvmInjector.validateAllPreCheck() {
-		klog.Infof("[inject] validate all pre check")
+		klog.Errorf("[inject] validateAllPreCheck failed: "+
+			"NeedInjectionCheck=%v, LoadingCheck=%v, IoFdCheck=%v, NetSendFuncCheck=%v",
+			jvmInjector.PreCheck.NeedInjectionCheck,
+			jvmInjector.PreCheck.LoadingCheck,
+			jvmInjector.PreCheck.IoFdCheck,
+			jvmInjector.PreCheck.NetSendFuncCheck,
+		)
 		return err
 	}
 	// 修改
@@ -959,42 +928,3 @@ func JvmInject(jvmInjector *JvmInjector) error {
 	}
 	return nil
 }
-
-func copyFileAndMatchPermissions(srcFile, destFile, permFile string) error {
-	// 获取权限文件的信息
-	permInfo, err := os.Stat(permFile)
-	if err != nil {
-		return fmt.Errorf("failed to stat permission file: %w", err)
-	}
-
-	// 打开源文件
-	src, err := os.Open(srcFile)
-	if err != nil {
-		return fmt.Errorf("failed to open source file: %w", err)
-	}
-	defer src.Close()
-
-	// 创建目标文件
-	dst, err := os.OpenFile(destFile, os.O_WRONLY|os.O_CREATE, permInfo.Mode())
-	if err != nil {
-		return fmt.Errorf("failed to create destination file: %w", err)
-	}
-	defer dst.Close()
-	// 复制文件内容
-	if _, err := io.Copy(dst, src); err != nil {
-		return fmt.Errorf("failed to copy file content: %w", err)
-	}
-
-	// 获取用户和组信息并设置
-	if stat, ok := permInfo.Sys().(*syscall.Stat_t); ok {
-		fmt.Println(stat.Uid)
-		fmt.Println(stat.Gid)
-		if err := dst.Chown(int(stat.Uid), int(stat.Gid)); err != nil {
-			return fmt.Errorf("failed to set file ownership: %w", err)
-		}
-	} else {
-		return fmt.Errorf("failed to retrieve ownership information")
-	}
-
-	return nil
-}

Fișier diff suprimat deoarece este prea mare
+ 535 - 233
ebpftracer/tracer/inject/inject_linux_arm64.go


BIN
ebpftracer/tracer/inject/lib/libhotpatch_arm64.a


+ 10 - 0
flags/flags.go

@@ -3,6 +3,7 @@ package flags
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/common-nighthawk/go-figure"
 	"github.com/coroot/coroot-node-agent/utils"
 	"github.com/coroot/coroot-node-agent/utils/modelse"
 	"github.com/jedib0t/go-pretty/v6/table"
@@ -67,6 +68,8 @@ var (
 
 	HostDirPathPrefix = kingpin.Flag("host-dir-path-prefix", "Set the prefix of path about the mount point of the host directory").Envar("HOST_DIR_PATH_PREFIX").Default("").String()
 	FuseTryMax        = kingpin.Flag("fuse_try_max", "The maximum number of the fuse operation try").Default("3").Envar("FUSE_TRY_MAX").Int()
+	// debug
+	Test = kingpin.Flag("test", "Only test").Default("false").Envar("TEST").Bool()
 )
 
 var AgentName = "euspace"
@@ -88,6 +91,13 @@ func init() {
 
 	kingpin.HelpFlag.Short('h').Hidden()
 	kingpin.Parse()
+	if *Test {
+		euspace := figure.NewFigure("TEST", "", true)
+		euspace.Print()
+	} else {
+		euspace := figure.NewColorFigure("Euspace", "slant", "blue", true)
+		euspace.Print()
+	}
 	if *Version {
 		ShowVersion()
 	}

+ 2 - 1
go.mod

@@ -16,8 +16,8 @@ require (
 	github.com/go-kit/log v0.2.1
 	github.com/go-logr/logr v1.4.1
 	github.com/go-sql-driver/mysql v1.8.1
-	github.com/gomodule/redigo v1.9.2
 	github.com/godbus/dbus/v5 v5.0.6
+	github.com/gomodule/redigo v1.9.2
 	github.com/grafana/pyroscope/ebpf v0.4.1
 	github.com/hashicorp/go-version v1.6.0
 	github.com/jedib0t/go-pretty/v6 v6.6.0
@@ -75,6 +75,7 @@ require (
 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect
 	github.com/cespare/xxhash/v2 v2.2.0 // indirect
 	github.com/cilium/workerpool v1.1.3 // indirect
+	github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
 	github.com/containerd/continuity v0.3.0 // indirect
 	github.com/containerd/fifo v1.0.0 // indirect
 	github.com/containerd/log v0.1.0 // indirect

+ 2 - 0
go.sum

@@ -183,6 +183,8 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH
 github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101 h1:7To3pQ+pZo0i3dsWEbinPNFs5gPSBOsJtx3wTT94VBY=
 github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
 github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
+github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ=
+github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w=
 github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE=
 github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU=
 github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU=

+ 7 - 0
kube/client.go

@@ -10,6 +10,8 @@ import (
 	v1 "k8s.io/api/core/v1"
 	"k8s.io/client-go/kubernetes"
 	"k8s.io/client-go/rest"
+	"k8s.io/klog/v2"
+	"os"
 	"strings"
 	"time"
 )
@@ -74,6 +76,11 @@ func GetWorkload(ns, pod string) (string, error) {
 }
 
 func GetNodeIpByCore(nodeName string) (string, error) {
+	ip := os.Getenv("node_ip")
+	if ip != "" {
+		klog.Info("[kube] get node ip by core:]", ip)
+		return ip, nil
+	}
 	client, err := GetKubeClient()
 	if err != nil {
 		return "", err

+ 1 - 1
main.go

@@ -322,7 +322,7 @@ func main() {
 		if err != nil {
 			return
 		}
-		log.Infoln("netdata is:", string(jsonData))
+		log.Debugln("netdata is:", string(jsonData))
 		// 创建请求
 		urlRoute := "/api/v2/ebpf/receive"
 

+ 0 - 143
manifests/cloudwise-apm-euspace.yaml

@@ -1,143 +0,0 @@
-apiVersion: v1
-kind: Namespace
-metadata:
-  name: cloudwise
----
-apiVersion: apps/v1
-kind: DaemonSet
-metadata:
-  name: cloudwise-apm-euspace
-  namespace: cloudwise
-spec:
-  selector:
-    matchLabels:
-      app: cloudwise-apm-euspace
-  template:
-    metadata:
-      annotations:
-        container.apparmor.security.beta.kubernetes.io/cloudwise-apm-euspace: unconfined
-      name: cloudwise-apm-euspace
-      namespace: cloudwise
-      labels:
-        app: cloudwise-apm-euspace
-    spec:
-      hostPID: true
-      nodeSelector:
-        kubernetes.io/os: linux
-        kubernetes.io/arch: amd64
-      containers:
-        - name: cloudwise-apm-euspace
-          image: harbor.cloudwise.com/apm/euspace_dev
-          imagePullPolicy: Always
-        # imagePullPolicy: IfNotPresent  
-          args: ["--listen", "0.0.0.0:8123", "--cgroupfs-root", "/host/sys/fs/cgroup","--run-in-container"]
-          ports:
-            - containerPort: 8123
-              name: http
-          securityContext:
-            privileged: true
-            runAsUser: 0
-          volumeMounts:
-            - name: sys-fs-cgroup
-              mountPath: /host/sys/fs/cgroup
-              readOnly: true
-            - name: sys-kernel-debug
-              mountPath: /sys/kernel/debug
-              readOnly: true
-            - name: host-usr
-              mountPath: /host/usr
-              readOnly: true
-              mountPropagation: HostToContainer
-            - name: host-var
-              mountPath: /host/var
-              readOnly: false
-              mountPropagation: HostToContainer
-            - name: host-run
-              mountPath: /host/run
-              readOnly: false
-              mountPropagation: HostToContainer
-            - name: host-tmp
-              mountPath: /host/tmp
-              readOnly: false
-              mountPropagation: HostToContainer
-          env:
-            - name: CONFIG_SERVER
-              value: '10.0.16.250:18080'
-            - name: DATA_SERVER
-              value: '10.0.16.250:18080'
-            - name: DISABLE_E2E_TRACING
-              value: 'false'
-            - name: DISABLE_STACK_TRACING
-              value: 'true'
-            - name: DISABLE_REG_HOST
-              value: 'false'
-            - name: CONSOLE_LOG
-              value: 'true'
-            - name: LOG_LEVEL
-              value: 'debug'
-            - name: SEND
-              value: '1'
-      volumes:
-        - name: sys-fs-cgroup
-          hostPath:
-            path: /sys/fs/cgroup
-        - name: sys-kernel-debug
-          hostPath:
-            path: /sys/kernel/debug
-        - name: host-usr
-          hostPath:
-            path: /usr  
-            type: Directory
-        - name: host-var
-          hostPath:
-            path: /var
-            type: Directory
-        - name: host-run
-          hostPath:
-            path: /run
-            type: Directory
-        - name: host-tmp
-          hostPath:
-            path: /tmp
-            type: Directory   
----
-kind: ClusterRole
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: euspace-agent-role
-rules:
-  - apiGroups: [""]
-    resources:
-      - nodes
-      - namespaces
-      - configmaps
-      - services
-      - pods
-      - replicationcontrollers
-    verbs: ["get", "list", "watch"]
-  - apiGroups: ["apps"]
-    resources:
-      - daemonsets
-      - deployments
-      - replicasets
-      - statefulsets
-    verbs: ["get", "list", "watch"]
-  - apiGroups: ["extensions", "networking.k8s.io"]
-    resources: ["ingresses"]
-    verbs: ["get", "list", "watch"]
-  - apiGroups: ["route.openshift.io"]
-    resources: ["routes"]
-    verbs: ["get", "list", "watch"]
----
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
-  name: cw-agent-view-binding
-subjects:
-  - kind: ServiceAccount
-    name: default
-    namespace: cloudwise
-roleRef:
-  kind: ClusterRole
-  name: euspace-agent-role
-  apiGroup: rbac.authorization.k8s.io

+ 0 - 52
manifests/coroot-node-agent.yaml

@@ -1,52 +0,0 @@
-apiVersion: v1
-kind: Namespace
-metadata:
-  name: coroot
-
----
-
-apiVersion: apps/v1
-kind: DaemonSet
-metadata:
-  labels:
-    app: coroot-node-agent
-  name: coroot-node-agent
-  namespace: coroot
-spec:
-  selector:
-    matchLabels:
-      app: coroot-node-agent
-  template:
-    metadata:
-      labels:
-        app: coroot-node-agent
-      annotations:
-        prometheus.io/scrape: 'true'
-        prometheus.io/port: '80'
-    spec:
-      tolerations:
-        - operator: Exists
-      hostPID: true
-      containers:
-        - name: coroot-node-agent
-          image: ghcr.io/coroot/coroot-node-agent
-          args: ["--cgroupfs-root", "/host/sys/fs/cgroup"]
-          ports:
-            - containerPort: 80
-              name: http
-          securityContext:
-            privileged: true
-          volumeMounts:
-            - mountPath: /host/sys/fs/cgroup
-              name: cgroupfs
-              readOnly: true
-            - mountPath: /sys/kernel/debug
-              name: debugfs
-              readOnly: false
-      volumes:
-        - hostPath:
-            path: /sys/fs/cgroup
-          name: cgroupfs
-        - hostPath:
-            path: /sys/kernel/debug
-          name: debugfs

+ 2 - 1
node/apm_host_info.go

@@ -25,11 +25,13 @@ func NewNodeInfo(name, kv, version string) (*NodeInfoT, error) {
 
 	var ip string
 	if *flags.RunInContainer {
+		klog.Infof("run in container.")
 		ip, err = kube.GetNodeIpByCore(name)
 		if err != nil {
 			return nil, err
 		}
 	} else {
+		klog.Infof("run standalone.")
 		ip, err = utils.GetRealIp()
 		if err != nil {
 			return nil, err
@@ -47,7 +49,6 @@ func NewNodeInfo(name, kv, version string) (*NodeInfoT, error) {
 		AgentVersion:  version,
 	}
 	utils.SaveNodeInfo(n)
-	klog.Infof("run standalone.")
 	return n, nil
 }
 

+ 1 - 0
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/client_apm.go

@@ -72,6 +72,7 @@ func (d *client) UploadApmTraces(ctx context.Context, rootData []otlptrace.RootD
 				}
 				msg := respJsonData.Msg
 				code := respJsonData.Code
+				klog.Infof("data/receive response body: %s\n", respData.String())
 				if msg != "send ok" || code != 1000 {
 					return fmt.Errorf("resp error msg:<%s> code:<%d>", msg, code)
 				}

+ 6 - 1
run.sh

@@ -25,4 +25,9 @@ CONFIG_SERVER=http://10.0.7.115:18080 DATA_SERVER=http://10.0.7.115:18080 TRACES
 
 # pid=`pidof java`
 # echo $pid
-# TRACES_ENDPOINT=http://10.0.12.192:18080/docp/api/v2/data/receive BIN_TYPE=java DBG_PATH="" SEND=1 FILTER_PID=$pid WHITE_LIST="handle*|addw.*" ./euspace  --listen="0.0.0.0:8124"
+# TRACES_ENDPOINT=http://10.0.12.192:18080/docp/api/v2/data/receive BIN_TYPE=java DBG_PATH="" SEND=1 FILTER_PID=$pid WHITE_LIST="handle*|addw.*" ./euspace  --listen="0.0.0.0:8124"
+
+SEND=1 FILTER_PID=112159 DISABLE_E2E_TRACING=false  CONFIG_SERVER=https://d189-116-204-36-103.ngrok-free.app DATA_SERVER=https://f5fe-116-204-36-103.ngrok-free.app ./euspace --console-log --log-level="debug"
+
+#WHITE_LIST=com.example.
+FILTER_PID=6054 COMMON_INI="" DISABLE_E2E_TRACING=false ./euspace --test --disable-reg-host --console-log --log-level="debug"

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff