diff --git a/Fix-for-popen-cannot-get-stderr.patch b/Fix-for-popen-cannot-get-stderr.patch deleted file mode 100644 index 8ea68753d935bb83180bef260fc202ad4d0e973b..0000000000000000000000000000000000000000 --- a/Fix-for-popen-cannot-get-stderr.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0f5572c6ee1847ac6b8d5fa892c83797ac4cbc6f Mon Sep 17 00:00:00 2001 -From: htpeng -Date: Wed, 29 Mar 2023 08:37:46 +0800 -Subject: [PATCH 27/30] Fix for popen() cannot get stderr - -Signed-off-by: htpeng ---- - src/probes/virtualized_infos.probe/virt_proc.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/probes/virtualized_infos.probe/virt_proc.c b/src/probes/virtualized_infos.probe/virt_proc.c -index d5972a5..b52c63e 100644 ---- a/src/probes/virtualized_infos.probe/virt_proc.c -+++ b/src/probes/virtualized_infos.probe/virt_proc.c -@@ -72,7 +72,7 @@ static int is_virsh_installed(void) - char line[LINE_BUF_LEN]; - int is_installed = 0; - -- if (do_read_line("which virsh", line) < 0) { -+ if (do_read_line("which virsh 2>&1", line) < 0) { - ERROR("[VIRT_PROC] find virsh failed.\n"); - return -1; - } -@@ -199,4 +199,4 @@ int virt_proc_init(void) - { - g_host_type_is_pm = 0; - is_host_type_pm(&g_host_type_is_pm); --} -\ No newline at end of file -+} --- -2.33.0 - diff --git a/Fix-segmentation-fault-of-gala-gopher-cmd.patch b/Fix-segmentation-fault-of-gala-gopher-cmd.patch deleted file mode 100644 index d50190e294324acddb2824f07aef4e0fd52a6726..0000000000000000000000000000000000000000 --- a/Fix-segmentation-fault-of-gala-gopher-cmd.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 5dca2b18cda90ef8cb66cff7b1f860062f248021 Mon Sep 17 00:00:00 2001 -From: Vchanger -Date: Wed, 19 Apr 2023 14:20:52 +0800 -Subject: [PATCH] Fix segmentation fault of gala-gopher cmd - ---- - src/daemon/main.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/daemon/main.c b/src/daemon/main.c -index 60a509c..bb39f08 100644 ---- a/src/daemon/main.c -+++ b/src/daemon/main.c -@@ -65,6 +65,7 @@ static int CmdProcessing(int argc, char *argv[]) - static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, - {"config_path", required_argument, 0, 'c'}, -+ {NULL, 0, 0, NULL} - }; - - char short_options[] = { --- -2.33.0 - diff --git a/adapt-block_rq_issue-tracepoint-args-in-kernel-5.10.patch b/adapt-block_rq_issue-tracepoint-args-in-kernel-5.10.patch deleted file mode 100644 index 96e80203895fc6d12d1615733467973dcdce632f..0000000000000000000000000000000000000000 --- a/adapt-block_rq_issue-tracepoint-args-in-kernel-5.10.patch +++ /dev/null @@ -1,28 +0,0 @@ -From ebc4a770ef1657c93fadf48d40294d3cb7e1cb29 Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Thu, 27 Apr 2023 16:59:17 +0800 -Subject: [PATCH] adapt block_rq_issue tracepoint args in kernel-5.10 - ---- - src/probes/extends/ebpf.probe/src/ioprobe/io_trace_bpf.h | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/probes/extends/ebpf.probe/src/ioprobe/io_trace_bpf.h b/src/probes/extends/ebpf.probe/src/ioprobe/io_trace_bpf.h -index 2109c87..f24078d 100644 ---- a/src/probes/extends/ebpf.probe/src/ioprobe/io_trace_bpf.h -+++ b/src/probes/extends/ebpf.probe/src/ioprobe/io_trace_bpf.h -@@ -315,7 +315,11 @@ static __always_inline struct io_latency_s* get_io_latency(struct io_trace_s* io - KRAWTRACE(block_rq_issue, bpf_raw_tracepoint_args) - { - struct io_trace_s *io_trace = NULL; -+#if (CURRENT_KERNEL_VERSION >= KERNEL_VERSION(5, 10, 0)) -+ struct request* req = (struct request *)ctx->args[0]; -+#else - struct request* req = (struct request *)ctx->args[1]; -+#endif - - io_trace = get_io_trace(req); - if (io_trace == NULL) { --- -2.33.0 - diff --git a/bugfix-The-log-time-is-not-the-local-time.patch b/bugfix-The-log-time-is-not-the-local-time.patch deleted file mode 100644 index d8ebd0c3851d2cec473dd521367801884c887452..0000000000000000000000000000000000000000 --- a/bugfix-The-log-time-is-not-the-local-time.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 57ab187ddd2915d0eaff2b472e22fb15e7374c09 Mon Sep 17 00:00:00 2001 -From: sjxur -Date: Sun, 23 Apr 2023 17:49:27 +0800 -Subject: [PATCH] bugfix:The log time is not the local time - -Conficts: del part of change comment code - ---- - src/common/logs.cpp | 2 +- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/common/logs.cpp b/src/common/logs.cpp -index fc338c3..f8c0c35 100644 ---- a/src/common/logs.cpp -+++ b/src/common/logs.cpp -@@ -383,7 +383,7 @@ static int append_debug_logger(struct log_mgr_s * mgr) - - SharedAppenderPtr append(new RollingFileAppender(g_debug_abs_path, DEBUG_LOGS_FILESIZE, 1, true, true)); - -- log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%m/%d/%y %H:%M:%S} - %m"); -+ log4cplus::tstring pattern = LOG4CPLUS_TEXT("%D{%m/%d/%y %H:%M:%S} - %m"); - append->setLayout(std::unique_ptr(new log4cplus::PatternLayout(pattern))); - - g_debug_logger.addAppender(append); --- -2.33.0 - diff --git a/bugfix-add-check-whether-cadvisor-is-installed.patch b/bugfix-add-check-whether-cadvisor-is-installed.patch deleted file mode 100644 index b9671d686270630d96b44fed99f58a3f6ea08591..0000000000000000000000000000000000000000 --- a/bugfix-add-check-whether-cadvisor-is-installed.patch +++ /dev/null @@ -1,84 +0,0 @@ -From b5fae1956af6c3c7f151bbf8919eb1c1a69a28ba Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Wed, 29 Mar 2023 09:26:34 +0800 -Subject: [PATCH 28/30] bugfix:add check whether cadvisor is installed - ---- - src/common/container.c | 2 +- - .../cadvisor.probe/cadvisor_probe.py | 19 +++++++++++++++---- - 2 files changed, 16 insertions(+), 5 deletions(-) - -diff --git a/src/common/container.c b/src/common/container.c -index c5b64a4..7d6ab27 100644 ---- a/src/common/container.c -+++ b/src/common/container.c -@@ -117,7 +117,7 @@ static bool __is_dockerd() - static bool __is_isulad() - { - if (__is_install_rpm("/bin/rpm -ql iSulad")) { -- return __is_service_running("/usr/bin/systemctl service iSulad"); { -+ return __is_service_running("/usr/bin/systemctl status isulad"); { - current_docker_command = ISULAD; - return true; - } -diff --git a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -index 8b65117..81226d0 100644 ---- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -@@ -16,7 +16,7 @@ CONTAINER_NAME_LEN = 64 - CONTAINER_STATUS_RUNNING = 0 - FILTER_BY_TASKPROBE = "task" - PROJECT_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # /opt/gala-gopher/ --PATTERN = re.compile(r'/[a-z0-9]+') -+PATTERN = re.compile(r'[/-][a-z0-9]+') - COUNTER = "counter" - LABEL = "label" - g_meta = None -@@ -248,6 +248,10 @@ class CadvisorProbe(Probe): - return False - - def start_cadvisor(self): -+ p = subprocess.Popen("which cadvisor", stdout=subprocess.PIPE, shell=True) -+ p.communicate(timeout=5) -+ if p.returncode != 0: -+ raise Exception('[cadvisor_probe] cAdvisor not installed') - p = subprocess.Popen("/usr/bin/ps -ef | /usr/bin/grep /usr/bin/cadvisor | /usr/bin/grep -v grep | \ - /usr/bin/awk '{print $2}'", stdout=subprocess.PIPE, shell=True) - (rawout, serr) = p.communicate(timeout=5) -@@ -310,7 +314,13 @@ class CadvisorProbe(Probe): - g_metric[table_name] = dict() - - metric_str = libconf.loads(line[(line.index("{") + 1):line.index("} ")]) -- if metric_str.id.startswith("/system.slice"): -+ ''' -+ docker use systemd as cgroupfs in k8s, cadvisor metric id like: -+ {id="/system.slice/docker-1044qbdeeedqdff...scope"} -+ normal metric_id like: -+ {id="/docker/1044qbdeeedqdff..."} -+ ''' -+ if metric_str.id.startswith("/system.slice") and 'docker-' not in metric_str.id: - continue - if metric_str.id.startswith("/user.slice"): - continue -@@ -388,7 +398,8 @@ if __name__ == "__main__": - cadvisor_probe = CadvisorProbe(object_lib, container_lib, params.port) - try: - cadvisor_probe.start_cadvisor() -- except ParamException as e: -+ except Exception as e: -+ print(e) - cadvisor_running_flag = False - basic_probe = BasicLabelProbe(object_lib, container_lib) - -@@ -401,7 +412,7 @@ if __name__ == "__main__": - basic_probe.get_basic_infos() - if cadvisor_running_flag: - try: -- cadvisor_probe.get_metrics(s, params.port) -+ cadvisor_probe.get_metrics(s, cadvisor_probe.port) - except Exception as e: - print("[cadvisor_probe]get metrics failed. Err: %s" % repr(e)) - s = requests.Session() --- -2.33.0 - diff --git a/bugfix-fix-gala-gopher-h-print-err.patch b/bugfix-fix-gala-gopher-h-print-err.patch deleted file mode 100644 index 24c7faa46379d8f14eba594f3c653195580fca3f..0000000000000000000000000000000000000000 --- a/bugfix-fix-gala-gopher-h-print-err.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 8cdc9f0c63f897240f1325faf287250c19e3b57a Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Mon, 8 May 2023 17:25:24 +0800 -Subject: [PATCH] bugfix: fix gala-gopher -h print err - ---- - res/event_multy_language.rc | 2 +- - src/daemon/main.c | 6 +++--- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/res/event_multy_language.rc b/res/event_multy_language.rc -index 0fb255b..04d580e 100644 ---- a/res/event_multy_language.rc -+++ b/res/event_multy_language.rc -@@ -228,7 +228,7 @@ events_en_US = - } - ); - --events_chinese = -+events_zh_CN = - ( - { - entity_name = "cpu", -diff --git a/src/daemon/main.c b/src/daemon/main.c -index bb39f08..5007486 100644 ---- a/src/daemon/main.c -+++ b/src/daemon/main.c -@@ -87,12 +87,12 @@ static int CmdProcessing(int argc, char *argv[]) - int option_index = 0; - cmd = getopt_long(argc, argv, short_options, long_options, &option_index); - if (cmd == -1) -- break; -+ return -1; - - switch (cmd) { - case 'h': -- ShowUsage(); -- break; -+ // print usage later -+ return -1; - case 'c': - ret = ParseConfigPath(optarg); - break; --- -2.33.0 - diff --git a/bugfix-fix-system_proc-collect-data-err.patch b/bugfix-fix-system_proc-collect-data-err.patch deleted file mode 100644 index f6b53c9f8297b29ca2034df74747b552009f239a..0000000000000000000000000000000000000000 --- a/bugfix-fix-system_proc-collect-data-err.patch +++ /dev/null @@ -1,163 +0,0 @@ -From 3bc3d1d20a220ab3a0a9093059289cc841bd45e2 Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Mon, 27 Mar 2023 11:38:26 +0800 -Subject: [PATCH 26/30] bugfix: fix system_proc collect data err - ---- - src/daemon/daemon.c | 2 +- - .../ebpf.probe/src/lvsprobe/trace_lvs.bpf.c | 2 +- - .../cadvisor.probe/cadvisor_probe.py | 4 ++++ - src/probes/system_infos.probe/system_net.c | 4 ++-- - src/probes/system_infos.probe/system_procs.c | 18 +++++++++++++----- - src/probes/system_infos.probe/system_procs.h | 11 +---------- - 6 files changed, 22 insertions(+), 19 deletions(-) - -diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c -index f3ab821..b10ca60 100644 ---- a/src/daemon/daemon.c -+++ b/src/daemon/daemon.c -@@ -26,7 +26,7 @@ - #include "daemon.h" - #include "object.h" - --#define RM_MAP_CMD "/usr/bin/find %s/* | /usr/bin/grep -v '%s\\|%s\\|%s' | /usr/bin/xargs rm -f" -+#define RM_MAP_CMD "/usr/bin/find %s/* 2> /dev/null | /usr/bin/grep -v '%s\\|%s\\|%s' | /usr/bin/xargs rm -f" - static const ResourceMgr *resouce_msg; - - #if GALA_GOPHER_INFO("inner func declaration") -diff --git a/src/probes/extends/ebpf.probe/src/lvsprobe/trace_lvs.bpf.c b/src/probes/extends/ebpf.probe/src/lvsprobe/trace_lvs.bpf.c -index cc2747c..ceb6548 100644 ---- a/src/probes/extends/ebpf.probe/src/lvsprobe/trace_lvs.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/lvsprobe/trace_lvs.bpf.c -@@ -187,7 +187,7 @@ KPROBE(ip_vs_conn_expire, pt_regs) - value_p = bpf_map_lookup_elem(&lvs_link_map, &key); - if (value_p == (void *)0) { - bpf_printk("===LVS ubind dest not in hash map.\n"); -- return; -+ return 0; - } - value_p->state = IP_VS_TCP_S_CLOSE; - value_p->close_ts = bpf_ktime_get_ns(); -diff --git a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -index 65db0f5..8b65117 100644 ---- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -@@ -200,6 +200,10 @@ class BasicLabelProbe(Probe): - self.container_lib.get_all_container.restype = POINTER(ContainerTbl) - tbl_p = self.container_lib.get_all_container() - -+ if not tbl_p: -+ print("[cadvisor_probe] no active containers in system") -+ return 0 -+ - for i in range(tbl_p.contents.num): - if tbl_p.contents.cs[i].status != CONTAINER_STATUS_RUNNING: - continue -diff --git a/src/probes/system_infos.probe/system_net.c b/src/probes/system_infos.probe/system_net.c -index 0962a9b..ce5cc04 100644 ---- a/src/probes/system_infos.probe/system_net.c -+++ b/src/probes/system_infos.probe/system_net.c -@@ -99,7 +99,7 @@ int system_tcp_probe(void) - /* output */ - (void)nprobe_fprintf(stdout, "|%s|%s|%llu|%llu|%llu|%llu|%llu|\n", - METRICS_TCP_NAME, -- "/proc/dev/snmp", -+ "/proc/net/snmp", - g_snmp_stats.tcp_curr_estab, - (g_snmp_stats.tcp_in_segs > temp.tcp_in_segs) ? (g_snmp_stats.tcp_in_segs - temp.tcp_in_segs) : 0, - (g_snmp_stats.tcp_out_segs > temp.tcp_out_segs) ? (g_snmp_stats.tcp_out_segs - temp.tcp_out_segs) : 0, -@@ -109,7 +109,7 @@ int system_tcp_probe(void) - - (void)nprobe_fprintf(stdout, "|%s|%s|%llu|%llu|\n", - METRICS_UDP_NAME, -- "/proc/dev/snmp", -+ "/proc/net/snmp", - (g_snmp_stats.udp_in_datagrams > temp.udp_in_datagrams) ? - (g_snmp_stats.udp_in_datagrams - temp.udp_in_datagrams) : 0, - (g_snmp_stats.udp_out_datagrams > temp.udp_out_datagrams) ? -diff --git a/src/probes/system_infos.probe/system_procs.c b/src/probes/system_infos.probe/system_procs.c -index d2d3c9a..1c32f53 100644 ---- a/src/probes/system_infos.probe/system_procs.c -+++ b/src/probes/system_infos.probe/system_procs.c -@@ -27,7 +27,7 @@ - #define PROC_STAT "/proc/%s/stat" - #define PROC_START_TIME_CMD "/usr/bin/cat /proc/%s/stat | awk '{print $22}'" - #define PROC_FD "/proc/%s/fd" --#define PROC_FD_CNT_CMD "/usr/bin/ls -l /proc/%s/fd 2>/dev/null | wc -l 2>/dev/null" -+#define PROC_FD_CNT_CMD "/usr/bin/ls /proc/%s/fd 2>/dev/null | wc -l 2>/dev/null" - #define PROC_IO "/proc/%s/io" - #define PROC_IO_CMD "/usr/bin/cat /proc/%s/io" - #define PROC_SMAPS "/proc/%s/smaps_rollup" -@@ -459,6 +459,10 @@ static int get_proc_mss(const char *pid, proc_info_t *proc_info) - u32 value = 0; - char fname_or_cmd[LINE_BUF_LEN]; - char line[LINE_BUF_LEN]; -+ char key[LINE_BUF_LEN]; -+ char smap_key_list[PROC_MSS_MAX][LINE_BUF_LEN] = {"Shared_Clean:", "Shared_Dirty:", "Private_Clean:", -+ "Private_Dirty:", "Referenced:", "LazyFree:", "Swap:", "SwapPss:"}; -+ int smap_index = 0; - - fname_or_cmd[0] = 0; - (void)snprintf(fname_or_cmd, LINE_BUF_LEN, PROC_SMAPS, pid); -@@ -471,8 +475,9 @@ static int get_proc_mss(const char *pid, proc_info_t *proc_info) - if (f == NULL) { - goto out; - } -- while (!feof(f) && (index < PROC_MSS_MAX)) { -+ while (!feof(f)) { - line[0] = 0; -+ key[0] = 0; - if (fgets(line, LINE_BUF_LEN, f) == NULL) { - goto out; - } -@@ -481,12 +486,15 @@ static int get_proc_mss(const char *pid, proc_info_t *proc_info) - continue; - } - value = 0; -- int ret = sscanf(line, "%*s %lu %*s", &value); -+ int ret = sscanf(line, "%s %lu %*s", key, &value); - if (ret < 1) { - goto out; - } -- do_set_proc_mss(proc_info, value, index); -- index++; -+ if (strcmp(smap_key_list[smap_index], key) != 0) { -+ continue; -+ } -+ do_set_proc_mss(proc_info, value, smap_index); -+ smap_index++; - } - out: - if (f != NULL) { -diff --git a/src/probes/system_infos.probe/system_procs.h b/src/probes/system_infos.probe/system_procs.h -index 9c9a77d..58cf4f8 100644 ---- a/src/probes/system_infos.probe/system_procs.h -+++ b/src/probes/system_infos.probe/system_procs.h -@@ -50,23 +50,14 @@ enum proc_stat_e { - }; - - enum proc_mss_e { -- PROC_MSS_RESIDENT = 0, -- PROC_MSS_SHARED_CLEAN, -+ PROC_MSS_SHARED_CLEAN = 0, - PROC_MSS_SHARED_DIRTY, - PROC_MSS_PRIVATE_CLEAN, - PROC_MSS_PROVATE_DIRTY, - PROC_MSS_REFERENCED, -- PROC_MSS_ANONYMOUS, - PROC_MSS_LAZYFREE, -- PROC_MSS_ANONYMOUS_THP, - PROC_MSS_SWAP, -- PROC_MSS_SHARED_HUGETLB, -- PROC_MSS_PRIVATE_HUGETLB, -- PROC_MSS_PSS, -- PROC_MSS_PSS_LOCKED, - PROC_MSS_SWAP_PSS, -- PROC_MSS_CHECK_SHNEM_SWAP, -- - PROC_MSS_MAX - }; - --- -2.33.0 - diff --git a/bugfix-zombie-task.patch b/bugfix-zombie-task.patch deleted file mode 100644 index 8805d7ae1be299296399cdf751f516acfc8d3cbd..0000000000000000000000000000000000000000 --- a/bugfix-zombie-task.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 40c9ea4431e3e2aecfa54dcc48bef55f602be497 Mon Sep 17 00:00:00 2001 -From: luzhihao -Date: Thu, 11 May 2023 14:41:19 +0800 -Subject: [PATCH] bugfix: zombie task. - ---- - src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.c | 1 + - src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c | 1 + - src/probes/extends/ebpf.probe/src/sliprobe/redissli.c | 1 + - src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c | 3 +++ - 4 files changed, 6 insertions(+) - -diff --git a/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.c b/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.c -index ac8484e..8f5513f 100644 ---- a/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.c -+++ b/src/probes/extends/ebpf.probe/src/ksliprobe/ksliprobe.c -@@ -162,6 +162,7 @@ static int init_conn_mgt_process(int msg_evt_map_fd) - fprintf(stderr, "Failed to create connection read/write message event handler thread.\n"); - return -1; - } -+ (void)pthread_detach(msg_evt_hdl_thd); - printf("Connection read/write message event handler thread successfully started!\n"); - - return 0; -diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c -index 34e749c..bee69b9 100644 ---- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c -+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c -@@ -194,6 +194,7 @@ static int init_conn_mgt_process(int msg_evt_map_fd) - fprintf(stderr, "Failed to create connection read/write message event handler thread.\n"); - return -1; - } -+ (void)pthread_detach(msg_evt_hdl_thd); - printf("Connection read/write message event handler thread successfully started!\n"); - - return 0; -diff --git a/src/probes/extends/ebpf.probe/src/sliprobe/redissli.c b/src/probes/extends/ebpf.probe/src/sliprobe/redissli.c -index 19c6fb7..e9b8591 100644 ---- a/src/probes/extends/ebpf.probe/src/sliprobe/redissli.c -+++ b/src/probes/extends/ebpf.probe/src/sliprobe/redissli.c -@@ -131,6 +131,7 @@ static int init_conn_mgt_process(int cmd_evt_map_fd) - fprintf(stderr, "Failed to create connection command event handler thread.\n"); - return -1; - } -+ (void)pthread_detach(cmd_evt_hdl_thd); - printf("Connection command event handler thread successfully started!\n"); - - return 0; -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c -index f050c27..41ad62e 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c -@@ -1386,6 +1386,7 @@ cleanup: - ERROR("[STACKPROBE]: attach memleak bpf failed %d\n", err); - return -1; - } -+ (void)pthread_detach(uprobe_attach_thd); - #endif - - INFO("[STACKPROBE]: attach memleak bpf succeed.\n"); -@@ -1576,6 +1577,7 @@ static void init_wr_flame_pthreads(struct svg_stack_trace_s *svg_st, const char - g_stop = 1; - return; - } -+ (void)pthread_detach(wr_flame_thd); - INFO("[STACKPROBE]: %s wr_flame_pthread successfully started!\n", flame_name); - - return; -@@ -1641,6 +1643,7 @@ static void init_java_support_proc(StackprobeConfig *conf) - ERROR("[STACKPROBE]: Failed to create java_support_pthread.\n"); - return; - } -+ (void)pthread_detach(attach_thd); - INFO("[STACKPROBE]: java_support_pthread successfully started!\n"); - - return; --- -2.33.0 - diff --git a/cadvisor_probe-convert-container_id-type-to-bytes.patch b/cadvisor_probe-convert-container_id-type-to-bytes.patch deleted file mode 100644 index eb0b7f14923db9f2dcc8728f7e46502e73826f06..0000000000000000000000000000000000000000 --- a/cadvisor_probe-convert-container_id-type-to-bytes.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 921f54938ae1f5b4d3d9486832c98896aaa88ddf Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Thu, 27 Apr 2023 09:24:12 +0800 -Subject: [PATCH] cadvisor_probe:convert container_id type to bytes - ---- - .../cadvisor.probe/cadvisor_probe.py | 20 +++++++++++-------- - 1 file changed, 12 insertions(+), 8 deletions(-) - -diff --git a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -index 81226d0..3f87134 100644 ---- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py -@@ -220,15 +220,17 @@ class BasicLabelProbe(Probe): - - self.get_all_containers() - for container_id in self.container_ids: -+ # ctype c_char_p is bytes in python3, convert str to bytes -+ container_id_bytes = str.encode(container_id) - g_metric[table_name][container_id] = dict() - g_metric[table_name][container_id]['container_id'] = container_id -- g_metric[table_name][container_id]['proc_id'] = self.get_container_pid(container_id) -- g_metric[table_name][container_id]['name'] = self.get_container_name(container_id) -- g_metric[table_name][container_id]['cpucg_inode'] = self.get_container_cpucg_inode(container_id) -- g_metric[table_name][container_id]['memcg_inode'] = self.get_container_memcg_inode(container_id) -- g_metric[table_name][container_id]['pidcg_inode'] = self.get_container_pidcg_inode(container_id) -- g_metric[table_name][container_id]['mnt_ns_id'] = self.get_container_mntns_id(container_id) -- g_metric[table_name][container_id]['net_ns_id'] = self.get_container_netns_id(container_id) -+ g_metric[table_name][container_id]['proc_id'] = self.get_container_pid(container_id_bytes) -+ g_metric[table_name][container_id]['name'] = self.get_container_name(container_id_bytes) -+ g_metric[table_name][container_id]['cpucg_inode'] = self.get_container_cpucg_inode(container_id_bytes) -+ g_metric[table_name][container_id]['memcg_inode'] = self.get_container_memcg_inode(container_id_bytes) -+ g_metric[table_name][container_id]['pidcg_inode'] = self.get_container_pidcg_inode(container_id_bytes) -+ g_metric[table_name][container_id]['mnt_ns_id'] = self.get_container_mntns_id(container_id_bytes) -+ g_metric[table_name][container_id]['net_ns_id'] = self.get_container_netns_id(container_id_bytes) - g_metric[table_name][container_id]['value'] = '0' - - -@@ -334,7 +336,9 @@ class CadvisorProbe(Probe): - g_metric[table_name][hashed_metric_str]['container_id'] = container_id - - metric_name = line[line.index("_") + 1:line.index("{")] -- value = line[(line.index(" ") + 1):self.find_2nd_index(line, " ")] -+ value_start_index = line.index("}") + 1 -+ value_end_index = value_start_index + self.find_2nd_index(line[value_start_index:], " ") -+ value = line[value_start_index:value_end_index] - try: - if g_meta[table_name][metric_name] == COUNTER: - if metric_name in g_metric[table_name][hashed_metric_str]: --- -2.33.0 - diff --git a/change-return-type-of-uprobe-from-void-to-int.patch b/change-return-type-of-uprobe-from-void-to-int.patch deleted file mode 100644 index bd277a5513902e1a5389b0f4ae779d1a092c1568..0000000000000000000000000000000000000000 --- a/change-return-type-of-uprobe-from-void-to-int.patch +++ /dev/null @@ -1,629 +0,0 @@ -From 7e2c2a1364b0e26098927ad5e976b6f9cddb5744 Mon Sep 17 00:00:00 2001 -From: wo_cow -Date: Mon, 20 Mar 2023 14:51:22 +0800 -Subject: [PATCH 19/30] change return type of uprobe from void to int - ---- - .../src/dnsmasqprobe/trace_dnsmasq.bpf.c | 2 +- - .../src/haproxyprobe/trace_haproxy.bpf.c | 6 ++-- - .../ebpf.probe/src/httpprobe/sslprobe.bpf.c | 17 ++++++----- - .../ebpf.probe/src/include/__bpf_usr.h | 17 ++++++----- - .../src/nginxprobe/nginx_probe.bpf.c | 29 ++++++++++--------- - .../src/pgsliprobe/pgsli_uprobe.bpf.c | 10 +++---- - .../ebpf.probe/src/sliprobe/redissli.bpf.c | 26 ++++++++++------- - .../src/stackprobe/stack_bpf/memleak.bpf.c | 24 +++++++++++++-- - .../ebpf.probe/src/taskprobe/glibc.bpf.c | 2 ++ - 9 files changed, 81 insertions(+), 52 deletions(-) - -diff --git a/src/probes/extends/ebpf.probe/src/dnsmasqprobe/trace_dnsmasq.bpf.c b/src/probes/extends/ebpf.probe/src/dnsmasqprobe/trace_dnsmasq.bpf.c -index 7338fce..cc49723 100644 ---- a/src/probes/extends/ebpf.probe/src/dnsmasqprobe/trace_dnsmasq.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/dnsmasqprobe/trace_dnsmasq.bpf.c -@@ -63,5 +63,5 @@ UPROBE(send_from, pt_regs) - /* update hash map */ - bpf_map_update_elem(&dns_query_link_map, &key, &value, BPF_ANY); - -- return; -+ return 0; - } -\ No newline at end of file -diff --git a/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.bpf.c b/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.bpf.c -index 6280ce8..ff0c9e1 100644 ---- a/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.bpf.c -@@ -127,7 +127,7 @@ UPROBE(back_establish, pt_regs) - /* update hash map */ - bpf_map_update_elem(&haproxy_link_map, &key, &value, BPF_ANY); - -- return; -+ return 0; - } - - UPROBE(stream_free, pt_regs) -@@ -142,7 +142,7 @@ UPROBE(stream_free, pt_regs) - value_p = bpf_map_lookup_elem(&haproxy_link_map, &key); - if (value_p == (void *)0) { - bpf_printk("===haproxy free stream not in hash map.\n"); -- return; -+ return 0; - } - /* update link state */ - value_p->state = SI_ST_CLO; -@@ -150,5 +150,5 @@ UPROBE(stream_free, pt_regs) - /* update hash map */ - bpf_map_update_elem(&haproxy_link_map, &key, value_p, BPF_ANY); - -- return; -+ return 0; - } -\ No newline at end of file -diff --git a/src/probes/extends/ebpf.probe/src/httpprobe/sslprobe.bpf.c b/src/probes/extends/ebpf.probe/src/httpprobe/sslprobe.bpf.c -index 00e41e8..478baae 100644 ---- a/src/probes/extends/ebpf.probe/src/httpprobe/sslprobe.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/httpprobe/sslprobe.bpf.c -@@ -72,23 +72,24 @@ UPROBE_RET(SSL_read, pt_regs, CTX_USER) - - if (PROBE_GET_PARMS(SSL_read, ctx, val, CTX_USER) < 0 || (int)PT_REGS_RC(ctx) < REQ_BUF_SIZE) { - bpf_printk("SSL_read fail..."); -- return; -+ return 0; - } - key.tgid = bpf_get_current_pid_tgid() >> TGID_LSHIFT_LEN; - ssl_st_p = (struct ssl_st*)PROBE_PARM1(val); - key.skfd = get_fd_from_ssl(ssl_st_p, MSG_READ); - data = bpf_map_lookup_elem(&conn_map, &key); - if (data == NULL || data->status == READY_FOR_SEND) { -- return; -+ return 0; - } - bpf_probe_read(buf, REQ_BUF_SIZE, (const char *)PROBE_PARM2(val)); - data->method = parse_req_method(buf); - if (data->method == HTTP_UNKNOWN) { - data->status = READY_FOR_RECVIVE; -- return; -+ return 0; - } - data->status = READY_FOR_SEND; - data->recvtime = bpf_ktime_get_ns(); -+ return 0; - } - - UPROBE_RET(SSL_write, pt_regs, CTX_USER) -@@ -102,23 +103,23 @@ UPROBE_RET(SSL_write, pt_regs, CTX_USER) - - if (PROBE_GET_PARMS(SSL_write, ctx, val, CTX_USER) < 0 || (int)PT_REGS_RC(ctx) <= REQ_BUF_SIZE - 1) { - bpf_printk("SSL_write fail..."); -- return; -+ return 0; - } - ckey.tgid = bpf_get_current_pid_tgid() >> TGID_LSHIFT_LEN ; - ssl_st_p = (struct ssl_st*)PROBE_PARM1(val); - ckey.skfd = get_fd_from_ssl(ssl_st_p, MSG_WRITE); - cdata = bpf_map_lookup_elem(&conn_map, &ckey); - if (cdata == NULL || cdata->status == READY_FOR_RECVIVE) { -- return; -+ return 0; - } - - cskey.sk = (struct sock *)cdata->sock; - if (cskey.sk == 0) { -- return; -+ return 0; - } - csdata = (struct conn_samp_data_t *)bpf_map_lookup_elem(&conn_samp_map, &cskey); - if (csdata == NULL) { -- return; -+ return 0; - } - csdata->method = cdata->method; - csdata->status = READY_FOR_SKBSENT; -@@ -128,5 +129,5 @@ UPROBE_RET(SSL_write, pt_regs, CTX_USER) - cdata->status = READY_FOR_RECVIVE; - cdata->recvtime = 0; - cdata->method = HTTP_UNKNOWN; -- return; -+ return 0; - } -\ No newline at end of file -diff --git a/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h b/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h -index 95e7160..75ac747 100644 ---- a/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h -+++ b/src/probes/extends/ebpf.probe/src/include/__bpf_usr.h -@@ -53,40 +53,41 @@ - if (ret < 0) { \ - bpf_printk("---UPROBE_RET[" #func "] push failed.\n"); \ - } \ -+ return 0; \ - } while (0) - - #if (CURRENT_LIBBPF_VERSION >= LIBBPF_VERSION(0, 8)) - #define UPROBE(func, type) \ - bpf_section("uprobe") \ -- void ubpf_##func(struct type *ctx) -+ int ubpf_##func(struct type *ctx) - - #define URETPROBE(func, type) \ - bpf_section("uretprobe") \ -- void ubpf_ret_##func(struct type *ctx) -+ int ubpf_ret_##func(struct type *ctx) - #define UPROBE_RET(func, type, prog_id) \ - bpf_section("uprobe") \ -- void __uprobe_bpf_##func(struct type *ctx) { \ -+ int __uprobe_bpf_##func(struct type *ctx) { \ - UPROBE_PARMS_STASH(func, ctx, prog_id); \ - } \ - \ - bpf_section("uretprobe") \ -- void __uprobe_ret_bpf_##func(struct type *ctx) -+ int __uprobe_ret_bpf_##func(struct type *ctx) - #else - #define UPROBE(func, type) \ - bpf_section("uprobe/" #func) \ -- void ubpf_##func(struct type *ctx) -+ int ubpf_##func(struct type *ctx) - - #define URETPROBE(func, type) \ - bpf_section("uretprobe/" #func) \ -- void ubpf_ret_##func(struct type *ctx) -+ int ubpf_ret_##func(struct type *ctx) - #define UPROBE_RET(func, type, prog_id) \ - bpf_section("uprobe/" #func) \ -- void __uprobe_bpf_##func(struct type *ctx) { \ -+ int __uprobe_bpf_##func(struct type *ctx) { \ - UPROBE_PARMS_STASH(func, ctx, prog_id); \ - } \ - \ - bpf_section("uretprobe/" #func) \ -- void __uprobe_ret_bpf_##func(struct type *ctx) -+ int __uprobe_ret_bpf_##func(struct type *ctx) - #endif - - #endif -diff --git a/src/probes/extends/ebpf.probe/src/nginxprobe/nginx_probe.bpf.c b/src/probes/extends/ebpf.probe/src/nginxprobe/nginx_probe.bpf.c -index 159966d..a710d07 100644 ---- a/src/probes/extends/ebpf.probe/src/nginxprobe/nginx_probe.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/nginxprobe/nginx_probe.bpf.c -@@ -66,19 +66,19 @@ UPROBE(ngx_http_upstream_handler, pt_regs) - - struct ngx_connection_s *c = (struct ngx_connection_s *)_(evt->data); - if (c == (void *)0) -- return; -+ return 0; - - struct ngx_http_request_s *r = (struct ngx_http_request_s *)_(c->data); - if (r == (void *)0) -- return; -+ return 0; - - struct ngx_http_upstream_s *u = (struct ngx_http_upstream_s *)_(r->upstream); - if (u == (void *)0) -- return; -+ return 0; - - c = (struct ngx_connection_s *)_(r->connection); - if (c == (void *)0) -- return; -+ return 0; - - struct ngx_metric metric = {0}; - -@@ -92,17 +92,17 @@ UPROBE(ngx_http_upstream_handler, pt_regs) - ngx_str_t *p_name; - bpf_probe_read_user(&p_name, sizeof(void **), &(u->peer.name)); - if (p_name == (void *)0) -- return; -+ return 0; - - unsigned char *dt; - bpf_probe_read_user(&dt, sizeof(void **), &(p_name->data)); - if (dt == (void *)0) -- return; -+ return 0; - - bpf_probe_read_user_str(metric.dst_ip_str, INET6_ADDRSTRLEN, dt); - - bpf_map_update_elem(&hs, &(metric.src_ip), &metric, BPF_ANY); -- return; -+ return 0; - } - - UPROBE(ngx_stream_proxy_init_upstream, pt_regs) -@@ -112,6 +112,7 @@ UPROBE(ngx_stream_proxy_init_upstream, pt_regs) - struct ngx_stream_session_s *s = (struct ngx_stream_session_s *)PT_REGS_PARM1(ctx); - - bpf_map_update_elem(¶_hs, &tid, &s, BPF_ANY); -+ return 0; - } - - URETPROBE(ngx_stream_proxy_init_upstream, pt_regs) -@@ -132,7 +133,7 @@ URETPROBE(ngx_stream_proxy_init_upstream, pt_regs) - t = (struct ngx_stream_session_s **)bpf_map_lookup_elem(¶_hs, &tid); - if (t == (void *)0) { - bpf_printk("bpf_map_lookup_elem para_hs tid:%lu failed\n", tid); -- return; -+ return 0; - } - - s = *t; -@@ -147,24 +148,24 @@ URETPROBE(ngx_stream_proxy_init_upstream, pt_regs) - bpf_probe_read_user(&stream, sizeof(void **), &(s->upstream)); - if (stream == (void *)0) { - bpf_printk("stream null:%p\n", stream); -- return; -+ return 0; - } - - p_name = _(stream->peer.name); - if (p_name == (void *)0) { - bpf_printk("peer.name null\n"); -- return; -+ return 0; - } - - unsigned char *dt = _(p_name->data); - if (dt == (void *)0) { - bpf_printk("name->data null\n"); -- return; -+ return 0; - } - bpf_probe_read_user_str(metric.dst_ip_str, INET6_ADDRSTRLEN, dt); - bpf_map_update_elem(&hs, &(metric.src_ip), &metric, BPF_ANY); - -- return; -+ return 0; - } - - UPROBE(ngx_close_connection, pt_regs) -@@ -179,9 +180,9 @@ UPROBE(ngx_close_connection, pt_regs) - bpf_copy_ip_addr(client_addr, &src_ip); - metric = (struct ngx_metric *)bpf_map_lookup_elem(&hs, &src_ip); - if (metric == (void *)0) -- return; -+ return 0; - - metric->is_finish = 1; - bpf_map_update_elem(&hs, &src_ip, metric, BPF_ANY); -- return; -+ return 0; - } -\ No newline at end of file -diff --git a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsli_uprobe.bpf.c b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsli_uprobe.bpf.c -index 2630ce9..eb1241c 100644 ---- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsli_uprobe.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsli_uprobe.bpf.c -@@ -77,29 +77,29 @@ UPROBE(SSL_read, pt_regs) - - URETPROBE(SSL_read, pt_regs) - { -- u32 tgid __maybe_unused = bpf_get_current_pid_tgid() >> INT_LEN; - struct probe_val val; - if (PROBE_GET_PARMS(SSL_read, ctx, val, PROG_SSL_READ) < 0) { -- return; -+ return 0; - } - - struct ssl_st* ssl_st_p = (struct ssl_st*)PROBE_PARM1(val); - int fd = get_fd_from_ssl(ssl_st_p, MSG_READ); - if (fd < 0) { -- return; -+ return 0; - } - - process_rdwr_msg(fd, (const char *)PROBE_PARM2(val), (int)PT_REGS_RC(ctx), MSG_READ, ctx); -+ return 0; - } - - UPROBE(SSL_write, pt_regs) - { -- u32 tgid __maybe_unused = bpf_get_current_pid_tgid() >> INT_LEN; - struct ssl_st* ssl_st_p = (struct ssl_st*)PT_REGS_PARM1(ctx); - int fd = get_fd_from_ssl(ssl_st_p, MSG_WRITE); - if (fd < 0) { -- return; -+ return 0; - } - - process_rdwr_msg(fd, (char *)PT_REGS_PARM2(ctx), (int)PT_REGS_PARM3(ctx), MSG_WRITE, ctx); -+ return 0; - } -diff --git a/src/probes/extends/ebpf.probe/src/sliprobe/redissli.bpf.c b/src/probes/extends/ebpf.probe/src/sliprobe/redissli.bpf.c -index 207ac00..f3f609c 100644 ---- a/src/probes/extends/ebpf.probe/src/sliprobe/redissli.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/sliprobe/redissli.bpf.c -@@ -126,17 +126,18 @@ UPROBE(readQueryFromClient, pt_regs) - conn_data = create_conn_from_client(c); - } - if (conn_data == (void *)0) { -- return; -+ return 0; - } - - // 当前周期已有采样数据时,不更新客户端连接 - if (conn_data->cmd_nums > 0) { -- return; -+ return 0; - } - - conn_data->last_read_ts_nsec = ts_nsec; - conn_data->rd_bufsize = 0; - conn_data->rd_listsize = 0; -+ return 0; - } - - // 监控 redis 命令处理函数,获取命令的元数据信息 -@@ -152,12 +153,12 @@ UPROBE(processCommand, pt_regs) - - conn_data = get_conn_from_client(c); - if (conn_data == (void *)0) { -- return; -+ return 0; - } - - // 当前周期已有采样数据时,后续数据不再处理 - if (conn_data->cmd_nums > 0) { -- return; -+ return 0; - } - - // 添加一个新请求 -@@ -189,13 +190,13 @@ URETPROBE(processCommand, pt_regs) - u64 cur_listpos; - - if (PROBE_GET_PARMS(processCommand, ctx, val, PROG_PROCESSCOMMAND) < 0) { -- return; -+ return 0; - } - c = (client *)PROBE_PARM1(val); - - conn_data = get_conn_from_client(c); - if (conn_data == (void *)0) { -- return; -+ return 0; - } - - cmd = &(conn_data->cmds[0]); -@@ -215,6 +216,7 @@ URETPROBE(processCommand, pt_regs) - cmd->end_ts_nsec = ts_nsec; - cmd->finished = 1; - } -+ return 0; - } - - // 监控 writeToClient 事件,获取应答消息离开应用层的时间点 -@@ -227,7 +229,7 @@ UPROBE(writeToClient, pt_regs) - - conn_data = get_conn_from_client(c); - if (conn_data == (void *)0) { -- return; -+ return 0; - } - conn_data->cur_bufpos = _(c->bufpos); - conn_data->cur_listpos = _(c->reply_bytes); -@@ -258,13 +260,13 @@ URETPROBE(writeToClient, pt_regs) - u64 period; - - if (PROBE_GET_PARMS(writeToClient, ctx, val, PROG_WRITETOCLIENT) < 0) { -- return; -+ return 0; - } - c = (client *)PROBE_PARM1(val); - - conn_data = get_conn_from_client(c); - if (conn_data == (void *)0) { -- return; -+ return 0; - } - - // 更新客户端连接已处理的响应字节数 -@@ -278,7 +280,7 @@ URETPROBE(writeToClient, pt_regs) - } - - if (conn_data->cmd_nums == 0) { -- return; -+ return 0; - } - - // 当已处理的响应字节数大于 redis 请求的写入位置时,则该请求在应用层处理完毕,记录该请求的结束时间点 -@@ -302,6 +304,7 @@ URETPROBE(writeToClient, pt_regs) - conn_data->last_smp_ts_nsec = ts_nsec; - conn_data->cmd_nums = 0; - } -+ return 0; - } - - // 端口 redis 客户端连接 -@@ -317,7 +320,7 @@ UPROBE(freeClient, pt_regs) - init_conn_key(&conn_key, fd, tgid); - conn_data = (struct conn_data_t *)bpf_map_lookup_elem(&conn_map, &conn_key); - if (conn_data == (void *)0) { -- return; -+ return 0; - } - - if (conn_data->cmd_nums > 0 && conn_data->cmds[0].finished) { -@@ -325,4 +328,5 @@ UPROBE(freeClient, pt_regs) - } - - bpf_map_delete_elem(&conn_map, &conn_key); -+ return 0; - } -\ No newline at end of file -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c b/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c -index 280b614..a7759d6 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/memleak.bpf.c -@@ -185,6 +185,7 @@ UPROBE(malloc, pt_regs) - { - u64 size = (u64)PT_REGS_PARM1(ctx); - alloc_enter(size); -+ return 0; - } - - URETPROBE(malloc, pt_regs) -@@ -192,6 +193,7 @@ URETPROBE(malloc, pt_regs) - - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(calloc, pt_regs) -@@ -199,12 +201,14 @@ UPROBE(calloc, pt_regs) - u64 nmemb = (u64)PT_REGS_PARM1(ctx); - u64 size = (u64)PT_REGS_PARM2(ctx); - alloc_enter(nmemb * size); -+ return 0; - } - - URETPROBE(calloc, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(realloc, pt_regs) -@@ -214,24 +218,28 @@ UPROBE(realloc, pt_regs) - - free_enter(ctx, ptr); - alloc_enter(size); -+ return 0; - } - - URETPROBE(realloc, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(mmap, pt_regs) - { - u64 size = (u64)PT_REGS_PARM2(ctx); - alloc_enter(size); -+ return 0; - } - - URETPROBE(mmap, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(posix_memalign, pt_regs) -@@ -241,6 +249,7 @@ UPROBE(posix_memalign, pt_regs) - u64 pid = bpf_get_current_pid_tgid(); - bpf_map_update_elem(&memalign_allocate, &pid, &memptr, BPF_ANY); - alloc_enter(size); -+ return 0; - } - - URETPROBE(posix_memalign, pt_regs) -@@ -249,72 +258,83 @@ URETPROBE(posix_memalign, pt_regs) - u64 addr; - u64 *memptr = (u64 *)bpf_map_lookup_elem(&memalign_allocate, &pid); - if (memptr == 0) -- return; -+ return 0; - bpf_map_delete_elem(&memalign_allocate, &pid); - - if (bpf_probe_read_user(&addr, sizeof(u64), &memptr)) -- return; -+ return 0; - - alloc_exit(ctx, addr); -+ return 0; - } - - UPROBE(valloc, pt_regs) - { - u64 size = (u64)PT_REGS_PARM1(ctx); - alloc_enter(size); -+ return 0; - } - - URETPROBE(valloc, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(memalign, pt_regs) - { - u64 size = (u64)PT_REGS_PARM1(ctx); - alloc_enter(size); -+ return 0; - } - - URETPROBE(memalign, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(pvalloc, pt_regs) - { - u64 size = (u64)PT_REGS_PARM1(ctx); - alloc_enter(size); -+ return 0; - } - - URETPROBE(pvalloc, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(aligned_alloc, pt_regs) - { - u64 size = (u64)PT_REGS_PARM2(ctx); - alloc_enter(size); -+ return 0; - } - - URETPROBE(aligned_alloc, pt_regs) - { - u64 ret = (u64)PT_REGS_RC(ctx); - alloc_exit(ctx, ret); -+ return 0; - } - - UPROBE(free, pt_regs) - { - u64 size = (u64)PT_REGS_PARM2(ctx); - free_enter(ctx, size); -+ return 0; - } - - UPROBE(munmap, pt_regs) - { - u64 size = (u64)PT_REGS_PARM1(ctx); - free_enter(ctx, size); -+ return 0; - } - -diff --git a/src/probes/extends/ebpf.probe/src/taskprobe/glibc.bpf.c b/src/probes/extends/ebpf.probe/src/taskprobe/glibc.bpf.c -index 3487b22..d4e4373 100644 ---- a/src/probes/extends/ebpf.probe/src/taskprobe/glibc.bpf.c -+++ b/src/probes/extends/ebpf.probe/src/taskprobe/glibc.bpf.c -@@ -72,11 +72,13 @@ static __always_inline void update_gethostname_res(struct pt_regs* ctx) - UPROBE(func, pt_regs) \ - { \ - start_fn(); \ -+ return 0; \ - } \ - \ - URETPROBE(func, pt_regs) \ - { \ - stop_fn(ctx); \ -+ return 0; \ - } - - UPROBE_GLIBC(getaddrinfo, store_dns_op_start_ts, update_gethostname_res) --- -2.33.0 - diff --git a/fix-access-violation.patch b/fix-access-violation.patch deleted file mode 100644 index d436299bd4bfeec6445333e4512a98c67e8fbf1e..0000000000000000000000000000000000000000 --- a/fix-access-violation.patch +++ /dev/null @@ -1,39 +0,0 @@ -From e724fefbd1cbaa610894eab418b3721e798a9c1f Mon Sep 17 00:00:00 2001 -From: wo_cow -Date: Mon, 8 May 2023 19:41:04 +0800 -Subject: [PATCH] fix access violation - ---- - src/common/container.c | 2 +- - src/common/container.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/common/container.c b/src/common/container.c -index c7981a1..fc081d3 100644 ---- a/src/common/container.c -+++ b/src/common/container.c -@@ -486,7 +486,7 @@ int get_elf_path(unsigned int pid, char elf_path[], int max_path_len, const char - { - char cmd[COMMAND_LEN] = {0}; - char elf_relative_path[PATH_LEN] = {0}; -- char container_id[CONTAINER_ABBR_ID_LEN] = {0}; -+ char container_id[CONTAINER_ABBR_ID_LEN + 1] = {0}; - char container_path[PATH_LEN] = {0}; - - // 1. get elf_path -diff --git a/src/common/container.h b/src/common/container.h -index b2dade9..e06a64b 100644 ---- a/src/common/container.h -+++ b/src/common/container.h -@@ -29,7 +29,7 @@ enum container_status_e { - - typedef struct container_info_s { - enum container_status_e status; -- char abbrContainerId[CONTAINER_ID_LEN]; -+ char abbrContainerId[CONTAINER_ID_LEN + 1]; - } container_info; - - typedef struct container_tbl_s { --- -2.33.0 - diff --git a/fix-add-default-data-of-event-conf.patch b/fix-add-default-data-of-event-conf.patch deleted file mode 100644 index b1d234f6bc646157e189837067dc475d15f2e85c..0000000000000000000000000000000000000000 --- a/fix-add-default-data-of-event-conf.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 76b7748bd24ab02ac8f26917e590a41fd185c1e7 Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Fri, 12 May 2023 14:38:18 +0800 -Subject: [PATCH] fix:add default data of event conf - ---- - src/common/event.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/common/event.c b/src/common/event.c -index 17fda5c..af98d07 100644 ---- a/src/common/event.c -+++ b/src/common/event.c -@@ -27,9 +27,9 @@ - #endif - - static struct evt_ts_hash_t *g_evt_head = NULL; --static unsigned int g_evt_period = 0; -+static unsigned int g_evt_period = 600; - static EventsConfig *g_evt_conf; --static char g_lang_type[MAX_EVT_GRP_NAME_LEN]; -+static char g_lang_type[MAX_EVT_GRP_NAME_LEN] = "zh_CN"; - - static void hash_clear_older_evt(time_t cur_time); - static unsigned int hash_count_evt(void); --- -2.33.0 - diff --git a/fix-change-license-software-name.patch b/fix-change-license-software-name.patch deleted file mode 100644 index c05c79dc6b1879d99f98104a8a76c7657c84f5ff..0000000000000000000000000000000000000000 --- a/fix-change-license-software-name.patch +++ /dev/null @@ -1,401 +0,0 @@ -From ecdfe5a9a67568bbfdd99d478ad425e66fa2d5e6 Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Tue, 9 May 2023 09:15:02 +0800 -Subject: [PATCH] fix: change license software name - ---- - src/common/event.c | 2 +- - src/common/kern_config.c | 2 +- - src/egress/egress.c | 2 +- - src/egress/egress.h | 2 +- - src/ingress/ingress.c | 2 +- - src/ingress/ingress.h | 2 +- - src/lib/base.h | 2 +- - src/lib/config/config.c | 2 +- - src/lib/config/config.h | 2 +- - src/lib/fifo/fifo.c | 2 +- - src/lib/fifo/fifo.h | 2 +- - src/lib/imdb/imdb.c | 2 +- - src/lib/imdb/imdb.h | 2 +- - src/lib/imdb/metrics.c | 2 +- - src/lib/kafka/kafka.c | 2 +- - src/lib/kafka/kafka.h | 2 +- - src/lib/meta/meta.c | 2 +- - src/lib/meta/meta.h | 2 +- - src/lib/probe/extend_probe.c | 2 +- - src/lib/probe/extend_probe.h | 2 +- - src/lib/probe/nprobe_fprintf.h | 2 +- - src/lib/probe/probe.c | 2 +- - src/lib/probe/probe.h | 2 +- - src/probes/event.probe/event.c | 2 +- - src/probes/event.probe/event.h | 2 +- - .../extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c | 2 +- - src/resource/resource.c | 2 +- - src/resource/resource.h | 2 +- - src/web_server/web_server.c | 2 +- - src/web_server/web_server.h | 2 +- - 30 files changed, 30 insertions(+), 30 deletions(-) - -diff --git a/src/common/event.c b/src/common/event.c -index 31eb899..17fda5c 100644 ---- a/src/common/event.c -+++ b/src/common/event.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/common/kern_config.c b/src/common/kern_config.c -index 2615652..3d8a22f 100644 ---- a/src/common/kern_config.c -+++ b/src/common/kern_config.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/egress/egress.c b/src/egress/egress.c -index 0935d82..ec2484b 100644 ---- a/src/egress/egress.c -+++ b/src/egress/egress.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/egress/egress.h b/src/egress/egress.h -index 316c1af..0c40bfe 100644 ---- a/src/egress/egress.h -+++ b/src/egress/egress.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/ingress/ingress.c b/src/ingress/ingress.c -index 51a17c8..d7b5f64 100644 ---- a/src/ingress/ingress.c -+++ b/src/ingress/ingress.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/ingress/ingress.h b/src/ingress/ingress.h -index 927b5ed..da6ee87 100644 ---- a/src/ingress/ingress.h -+++ b/src/ingress/ingress.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/base.h b/src/lib/base.h -index a5d9c21..3d97816 100644 ---- a/src/lib/base.h -+++ b/src/lib/base.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/config/config.c b/src/lib/config/config.c -index d8ce2a5..ac836cb 100644 ---- a/src/lib/config/config.c -+++ b/src/lib/config/config.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/config/config.h b/src/lib/config/config.h -index 6eefc69..30af00a 100644 ---- a/src/lib/config/config.h -+++ b/src/lib/config/config.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/fifo/fifo.c b/src/lib/fifo/fifo.c -index 7b5d784..be4a90a 100644 ---- a/src/lib/fifo/fifo.c -+++ b/src/lib/fifo/fifo.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/fifo/fifo.h b/src/lib/fifo/fifo.h -index 88d445a..ae2b03c 100644 ---- a/src/lib/fifo/fifo.h -+++ b/src/lib/fifo/fifo.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/imdb/imdb.c b/src/lib/imdb/imdb.c -index 453c1fe..51508b2 100644 ---- a/src/lib/imdb/imdb.c -+++ b/src/lib/imdb/imdb.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/imdb/imdb.h b/src/lib/imdb/imdb.h -index 4d93c40..7832ea6 100644 ---- a/src/lib/imdb/imdb.h -+++ b/src/lib/imdb/imdb.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/imdb/metrics.c b/src/lib/imdb/metrics.c -index 64f6335..89c75f5 100644 ---- a/src/lib/imdb/metrics.c -+++ b/src/lib/imdb/metrics.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/kafka/kafka.c b/src/lib/kafka/kafka.c -index a240cd4..b6d4a4e 100644 ---- a/src/lib/kafka/kafka.c -+++ b/src/lib/kafka/kafka.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/kafka/kafka.h b/src/lib/kafka/kafka.h -index 1e5c52a..bbe921a 100644 ---- a/src/lib/kafka/kafka.h -+++ b/src/lib/kafka/kafka.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/meta/meta.c b/src/lib/meta/meta.c -index 12b3576..632741a 100644 ---- a/src/lib/meta/meta.c -+++ b/src/lib/meta/meta.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/meta/meta.h b/src/lib/meta/meta.h -index 2be952d..809b8a0 100644 ---- a/src/lib/meta/meta.h -+++ b/src/lib/meta/meta.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/probe/extend_probe.c b/src/lib/probe/extend_probe.c -index c7de9ed..8c989ce 100644 ---- a/src/lib/probe/extend_probe.c -+++ b/src/lib/probe/extend_probe.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/probe/extend_probe.h b/src/lib/probe/extend_probe.h -index cd7721f..204e5d6 100644 ---- a/src/lib/probe/extend_probe.h -+++ b/src/lib/probe/extend_probe.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/probe/nprobe_fprintf.h b/src/lib/probe/nprobe_fprintf.h -index 400626c..97e2f72 100644 ---- a/src/lib/probe/nprobe_fprintf.h -+++ b/src/lib/probe/nprobe_fprintf.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/probe/probe.c b/src/lib/probe/probe.c -index fb9bfdb..ab84fd3 100644 ---- a/src/lib/probe/probe.c -+++ b/src/lib/probe/probe.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/lib/probe/probe.h b/src/lib/probe/probe.h -index 31fdf20..8faabca 100644 ---- a/src/lib/probe/probe.h -+++ b/src/lib/probe/probe.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/probes/event.probe/event.c b/src/probes/event.probe/event.c -index 37578de..7d0f8ca 100644 ---- a/src/probes/event.probe/event.c -+++ b/src/probes/event.probe/event.c -@@ -1,6 +1,6 @@ - /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/probes/event.probe/event.h b/src/probes/event.probe/event.h -index 42fc824..b52ae86 100644 ---- a/src/probes/event.probe/event.h -+++ b/src/probes/event.probe/event.h -@@ -1,6 +1,6 @@ - /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c -index ed6ae19..05d93fb 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/resource/resource.c b/src/resource/resource.c -index 730ecd7..8d62265 100644 ---- a/src/resource/resource.c -+++ b/src/resource/resource.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/resource/resource.h b/src/resource/resource.h -index 4308e1e..b5f4edb 100644 ---- a/src/resource/resource.h -+++ b/src/resource/resource.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/web_server/web_server.c b/src/web_server/web_server.c -index d65abca..4d8141a 100644 ---- a/src/web_server/web_server.c -+++ b/src/web_server/web_server.c -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 -diff --git a/src/web_server/web_server.h b/src/web_server/web_server.h -index f436988..f3c53ee 100644 ---- a/src/web_server/web_server.h -+++ b/src/web_server/web_server.h -@@ -1,6 +1,6 @@ - /****************************************************************************** - * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. -- * iSulad licensed under the Mulan PSL v2. -+ * gala-gopher licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 --- -2.33.0 - diff --git a/fix-fix-fd-leakage-problem.patch b/fix-fix-fd-leakage-problem.patch deleted file mode 100644 index c6aa5dec54e9ee4d5c3a7f261e442d0931ef16f2..0000000000000000000000000000000000000000 --- a/fix-fix-fd-leakage-problem.patch +++ /dev/null @@ -1,96 +0,0 @@ -From 80629a576c18dbf132cd9d6a3a6bfc7ae3af516d Mon Sep 17 00:00:00 2001 -From: algorithmofdish -Date: Wed, 26 Apr 2023 16:58:02 +0800 -Subject: [PATCH] fix: fix fd leakage problem - -Conficts: src/probes/extends/ebpf.probe/src/{lib->stackprobe}/java_support.c - ---- - src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.c | 4 ++++ - src/probes/extends/ebpf.probe/src/stackprobe/java_support.c | 2 ++ - test/test_probes/test_probes.c | 6 ++++++ - 3 files changed, 12 insertions(+) - -diff --git a/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.c b/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.c -index 39e1827..cc5e771 100644 ---- a/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.c -+++ b/src/probes/extends/ebpf.probe/src/haproxyprobe/trace_haproxy.c -@@ -55,8 +55,12 @@ static void get_host_ip(const unsigned char *value, unsigned short family) - } - - fp = popen(cmd, "r"); -+ if (fp == NULL) { -+ return; -+ } - if (fgets(buffer, INET6_ADDRSTRLEN, fp) == NULL) { - printf("Fail get_host_ip.\n"); -+ (void)pclose(fp); - return ; - } - (void)pclose(fp); -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c b/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c -index 1aacb99..4a2c736 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c -@@ -211,6 +211,7 @@ static int __check_proc_to_attach(int proc_obj_map_fd) - - while (fgets(line, sizeof(line), f)) { - if (sscanf(line, "%d", &pid) != 1) { -+ (void)pclose(f); - return -1; - } - if (proc_obj_map_fd != 0) { // whitelist_enable -@@ -241,6 +242,7 @@ static int __check_proc_to_attach(int proc_obj_map_fd) - } - - } -+ (void)pclose(f); - return ret; - } - -diff --git a/test/test_probes/test_probes.c b/test/test_probes/test_probes.c -index 6f23117..3c608ca 100644 ---- a/test/test_probes/test_probes.c -+++ b/test/test_probes/test_probes.c -@@ -332,14 +332,17 @@ void TestSystemProcProbe(void) - snprintf(cmd, COMMAND_LEN - 1, "touch /tmp/gala-gopher-app.conf"); - f = popen(cmd, "r"); - CU_ASSERT(f != NULL); -+ (void)pclose(f); - - snprintf(cmd, COMMAND_LEN - 1, "echo \'application = ({ comm = \"sleep\", cmdline = \"\"})\' >/tmp/gala-gopher-app.conf"); - f = popen(cmd, "r"); - CU_ASSERT(f != NULL); -+ (void)pclose(f); - - snprintf(cmd, COMMAND_LEN - 1, "sleep 60 &"); - f = popen(cmd, "r"); - CU_ASSERT(f != NULL); -+ (void)pclose(f); - - system_proc_init(¶ms.task_whitelist); - CU_ASSERT(¶ms.task_whitelist != NULL); -@@ -353,10 +356,12 @@ void TestSystemProcProbe(void) - snprintf(cmd, COMMAND_LEN - 1, "rm -rf /tmp/gala-gopher-app.conf"); - f = popen(cmd, "r"); - CU_ASSERT(f != NULL); -+ (void)pclose(f); - - snprintf(cmd, COMMAND_LEN - 1, "rm -rf /sys/fs/bpf/gala-gopher"); - f = popen(cmd, "r"); - CU_ASSERT(f != NULL); -+ (void)pclose(f); - - ProbeDestroy(g_probe); - system_proc_destroy(); -@@ -388,6 +393,7 @@ void TestEventProbe(void) - snprintf(cmd, COMMAND_LEN - 1, "echo \"%s\" >> /var/log/messages", EVENT_ERR_CODE); - f = popen(cmd, "r"); - CU_ASSERT(f != NULL); -+ pclose(f); - - g_probe = ProbeCreate(); - CU_ASSERT(g_probe != NULL); --- -2.33.0 - diff --git a/fix-fix-install-error.patch b/fix-fix-install-error.patch deleted file mode 100644 index b1dbe9dca6f637ea890d24a244e3a54337f79ec9..0000000000000000000000000000000000000000 --- a/fix-fix-install-error.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 2408b163c4c0a2fdfeac4e710b24391e87b9f6a5 Mon Sep 17 00:00:00 2001 -From: dowzyx -Date: Wed, 10 May 2023 11:20:25 +0800 -Subject: [PATCH] fix: fix install error - ---- - build/install.sh | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/build/install.sh b/build/install.sh -index d92f135..fce8aeb 100755 ---- a/build/install.sh -+++ b/build/install.sh -@@ -37,7 +37,9 @@ function install_daemon_bin() - echo "${GOPHER_BIN_FILE} not exist. please check if build success." - exit 1 - fi -- -+ if [ ! -d ${GOPHER_BIN_TARGET_DIR} ]; then -+ mkdir -p ${GOPHER_BIN_TARGET_DIR} -+ fi - # install gala-gopher bin - cp -f ${GOPHER_BIN_FILE} ${GOPHER_BIN_TARGET_DIR} - echo "install ${GOPHER_BIN_FILE} success." -@@ -65,7 +67,7 @@ function install_conf() - - # install gala-gopher.conf - if [ ! -d ${GOPHER_CONF_TARGET_DIR} ]; then -- mkdir ${GOPHER_CONF_TARGET_DIR} -+ mkdir -p ${GOPHER_CONF_TARGET_DIR} - fi - cp -f ${GOPHER_CONF_FILE} ${GOPHER_CONF_TARGET_DIR} - echo "install ${GOPHER_CONF_FILE} success." --- -2.33.0 - diff --git a/fix-httpprobe-find-libssl-path.patch b/fix-httpprobe-find-libssl-path.patch deleted file mode 100644 index a95b2bad45a78462fd9a8fed139c63eb18f985ef..0000000000000000000000000000000000000000 --- a/fix-httpprobe-find-libssl-path.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 78afbbed90b312ff308b5be0fba24d42a3f122ca Mon Sep 17 00:00:00 2001 -From: xietangxin -Date: Thu, 13 Apr 2023 14:35:00 +0800 -Subject: [PATCH] fix httpprobe find libssl path - ---- - src/daemon/daemon.c | 2 +- - src/probes/extends/ebpf.probe/src/httpprobe/httpprobe.c | 6 ++++-- - 2 files changed, 5 insertions(+), 3 deletions(-) - -diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c -index b10ca60..3b16a75 100644 ---- a/src/daemon/daemon.c -+++ b/src/daemon/daemon.c -@@ -172,7 +172,7 @@ static void DaemonKeeplive(int sig) - (void)pthread_detach(probe->tid); - - INFO("[DAEMON] keeplive create probe(%s) thread.\n", probe->name); -- break; -+ continue; - } - } - return; -diff --git a/src/probes/extends/ebpf.probe/src/httpprobe/httpprobe.c b/src/probes/extends/ebpf.probe/src/httpprobe/httpprobe.c -index 477fe43..e64a706 100644 ---- a/src/probes/extends/ebpf.probe/src/httpprobe/httpprobe.c -+++ b/src/probes/extends/ebpf.probe/src/httpprobe/httpprobe.c -@@ -42,6 +42,7 @@ - #define APACHE_PATH "which httpd" - #define NGINX_SSL_PATH "ldd $(which nginx) | grep libssl | awk '{print $3}'" - #define APACHE_SSL_PATH "ldd /etc/httpd/modules/mod_ssl.so | grep libssl | awk '{print $3}'" -+#define HTTPD_SSL_PATH "/etc/httpd/modules/mod_ssl.so" - - #define LOAD_HTTP_PROBE(probe_name, end, load) \ - OPEN(probe_name, end, load); \ -@@ -81,8 +82,9 @@ static void get_libssl_path(char *nginx_sslpath, char *apache_sslpath) - } - pclose(f1); - f1 = popen(APACHE_PATH, "r"); -- if (fgets(buf, PATH_LEN, f1) != NULL && strlen(buf) > 0 && !(buf[strlen(buf) - 1] = 0) && access(buf, F_OK) == 0) { -- if ((f2 = popen(NGINX_SSL_PATH, "r")) != NULL && fgets(apache_sslpath, PATH_LEN, f2) != NULL) { -+ if (fgets(buf, PATH_LEN, f1) != NULL && strlen(buf) > 0 && !(buf[strlen(buf) - 1] = 0) && -+ access(buf, F_OK) == 0 && access(HTTPD_SSL_PATH, F_OK) == 0) { -+ if ((f2 = popen(APACHE_SSL_PATH, "r")) != NULL && fgets(apache_sslpath, PATH_LEN, f2) != NULL) { - if (strlen(apache_sslpath) != 0) { - apache_sslpath[strlen(apache_sslpath) - 1] = 0; - } --- -2.33.0 - diff --git a/fix-modify-unit-of-some-metrics-to-second.patch b/fix-modify-unit-of-some-metrics-to-second.patch deleted file mode 100644 index 62a08d121f4de3af995e373de75645e96d48aa3a..0000000000000000000000000000000000000000 --- a/fix-modify-unit-of-some-metrics-to-second.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 9ad26e3d4abfb78e99b8d75da384e36badbde75a Mon Sep 17 00:00:00 2001 -From: dowzyx -Date: Thu, 16 Mar 2023 16:09:07 +0800 -Subject: [PATCH 23/30] fix: modify unit of some metrics to second - ---- - .../extends/java.probe/jvm.probe/jvm_probe.meta | 14 +++++++------- - .../jvm.probe/src/agent/JvmProbeAgent.java | 13 +++++++------ - 2 files changed, 14 insertions(+), 13 deletions(-) - -diff --git a/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta b/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta -index bb9d01a..d80341a 100755 ---- a/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta -+++ b/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta -@@ -18,12 +18,12 @@ measurements: - name: "runtime", - }, - { -- description: "....", -+ description: "JVM implementation vender.", - type: "label", - name: "vendor", - }, - { -- description: "....", -+ description: "the JVM implementation version.", - type: "label", - name: "version", - }, -@@ -163,7 +163,7 @@ measurements: - name: "tgid", - }, - { -- description: "....", -+ description: "name representing a memory pool.", - type: "key", - name: "pool", - }, -@@ -210,8 +210,8 @@ measurements: - name: "tgid", - }, - { -- description: "....", -- type: "label", -+ description: "name representing a buffer pool.", -+ type: "key", - name: "pool", - }, - { -@@ -242,8 +242,8 @@ measurements: - name: "tgid", - }, - { -- description: "....", -- type: "label", -+ description: "name representing a GC.", -+ type: "key", - name: "gc", - }, - { -diff --git a/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java b/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -index 488c73c..d7f635d 100644 ---- a/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -+++ b/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -@@ -22,7 +22,7 @@ import java.lang.reflect.InvocationTargetException; - public class JvmProbeAgent { - - private static final int MSEC_PER_SEC = 1000; -- private static final int NSEC_PER_SEC = 1000000; -+ private static final int NSEC_PER_SEC = 1000000000; - private static final String METRIC_FILE_NAME = "jvm-metrics.txt"; - private static String pid; - private static String nspid; -@@ -79,10 +79,11 @@ public class JvmProbeAgent { - } - - private static void processCollector(RuntimeMXBean runtimeBean, OperatingSystemMXBean osBean) { -- long processStartTime = runtimeBean.getStartTime(); // ms -+ long processStartTime = runtimeBean.getStartTime(); // ms - try { -- Long processCpuTime = callLongGetter(osBean.getClass().getMethod("getProcessCpuTime"), osBean); // ns -- writeMetricRecords(String.format("|jvm_process|%s|%d|%d|\n", pid, processStartTime, processCpuTime)); -+ Long processCpuTime = callLongGetter(osBean.getClass().getMethod("getProcessCpuTime"), osBean); // ns -+ writeMetricRecords(String.format("|jvm_process|%s|%f|%f|\n", -+ pid, ((double)processStartTime / MSEC_PER_SEC), ((double)processCpuTime / NSEC_PER_SEC))); - } catch (Exception e) { - //System.out.println("error"); - } -@@ -169,8 +170,8 @@ public class JvmProbeAgent { - // gc - private static void gcCollector(List garbageCollectors) { - for (GarbageCollectorMXBean gc : garbageCollectors) { -- writeMetricRecords(String.format("|jvm_gc|%s|%s|%d|%d|\n", -- pid, gc.getName(), gc.getCollectionCount(), gc.getCollectionTime())); // ms -+ writeMetricRecords(String.format("|jvm_gc|%s|%s|%d|%f|\n", -+ pid, gc.getName(), gc.getCollectionCount(), ((double)gc.getCollectionTime() / MSEC_PER_SEC))); - } - } - --- -2.33.0 - diff --git a/fix-prepare_dependence.patch b/fix-prepare_dependence.patch deleted file mode 100644 index b7673de612ef9ead39299c35c11f4605eeeddaaf..0000000000000000000000000000000000000000 --- a/fix-prepare_dependence.patch +++ /dev/null @@ -1,47 +0,0 @@ -From cabacb208974b002f01268e988a0b32062d0f730 Mon Sep 17 00:00:00 2001 -From: sjxur -Date: Wed, 19 Apr 2023 16:32:20 +0800 -Subject: [PATCH] fix prepare_dependence - ---- - build/build.sh | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -diff --git a/build/build.sh b/build/build.sh -index d66da9a..696a902 100755 ---- a/build/build.sh -+++ b/build/build.sh -@@ -228,6 +228,30 @@ function prepare_dependence() - return 1 - fi - -+ yum install -y libbpf-devel -+ if [ $? -ne 0 ];then -+ echo "Error: Failed to install libbpf-devel." -+ return 1 -+ fi -+ -+ yum install -y clang -+ if [ $? -ne 0 ];then -+ echo "Error: Failed to install clang." -+ return 1 -+ fi -+ -+ yum install -y llvm -+ if [ $? -ne 0 ];then -+ echo "Error: Failed to install llvm." -+ return 1 -+ fi -+ -+ yum install -y java-1.8.0-openjdk-devel -+ if [ $? -ne 0 ];then -+ echo "Error: Failed to install java-1.8.0-openjdk-devel" -+ return 1 -+ fi -+ - return 0 - } - --- -2.33.0 - diff --git a/gala-gopher-1.0.2.tar.gz b/gala-gopher-2.0.1.tar.gz similarity index 30% rename from gala-gopher-1.0.2.tar.gz rename to gala-gopher-2.0.1.tar.gz index 9d80446259883cf1280361272c25de09ff35ae45..4964a4ff7bd0990219a8739c7cf5eadc51644459 100644 Binary files a/gala-gopher-1.0.2.tar.gz and b/gala-gopher-2.0.1.tar.gz differ diff --git a/gala-gopher.spec b/gala-gopher.spec index a26e48dd7da63d1ba26e94e2502d35f14fd682ae..7e5529f1d993fed7b65680b515ca9c7892117b44 100644 --- a/gala-gopher.spec +++ b/gala-gopher.spec @@ -1,47 +1,99 @@ #needsrootforbuild %define __os_install_post %{nil} -%define vmlinux_ver 5.10.0-126.0.0.66.oe2203.%{_arch} +%define without_baseinfo 0 +%define without_virt 0 +%define without_flamegraph 0 +%define without_l7 0 +%define without_tcp 0 +%define without_socket 0 +%define without_io 0 +%define without_proc 0 +%define without_jvm 0 +%define without_postgre_sli 0 +%define without_opengauss_sli 0 +%define without_nginx 1 +%define without_tprofiling 0 +%define without_kafka 1 +%define without_hw 1 +%define without_ksli 0 +%define without_container 0 +%define without_sermant 1 + +%define disable_report_event 0 +%define disable_kafka_channel 0 +%define disable_flamegraph_svg 0 + Summary: Intelligent ops toolkit for openEuler Name: gala-gopher -Version: 1.0.2 -Release: 4 +Version: 2.0.1 +Release: 1 License: Mulan PSL v2 URL: https://gitee.com/openeuler/gala-gopher Source: %{name}-%{version}.tar.gz BuildRoot: %{_builddir}/%{name}-%{version} -BuildRequires: systemd cmake gcc-c++ elfutils-devel libcurl-devel -BuildRequires: clang >= 10.0.1 llvm java-1.8.0-openjdk-devel -BuildRequires: libconfig-devel librdkafka-devel libmicrohttpd-devel -BuildRequires: libbpf-devel >= 2:0.3 uthash-devel log4cplus-devel -BuildRequires: CUnit CUnit-devel dmidecode junit ethtool bpftool procps-ng iproute -Requires: bash glibc elfutils bpftool dmidecode -Requires: python3-psycopg2 python3-yaml flamegraph iproute libcurl -Requires: libbpf >= 2:0.3 kmod net-tools ethtool cadvisor python3-libconf python3-requests - -Patch1: refactor-modify-jvmprobe-to-support-pod.patch -Patch2: change-return-type-of-uprobe-from-void-to-int.patch -Patch3: fix-modify-unit-of-some-metrics-to-second.patch -Patch4: bugfix-fix-system_proc-collect-data-err.patch -Patch5: Fix-for-popen-cannot-get-stderr.patch -Patch6: bugfix-add-check-whether-cadvisor-is-installed.patch -Patch7: stackprobe-fix-inaccurate-call-stack-count.-add-samp.patch -Patch8: fix-httpprobe-find-libssl-path.patch -Patch9: Fix-segmentation-fault-of-gala-gopher-cmd.patch -Patch10: fix-prepare_dependence.patch -Patch11: bugfix-The-log-time-is-not-the-local-time.patch -Patch12: fix-fix-fd-leakage-problem.patch -Patch13: cadvisor_probe-convert-container_id-type-to-bytes.patch -Patch14: adapt-block_rq_issue-tracepoint-args-in-kernel-5.10.patch -Patch15: modify-desc-from-chinese-to-english.patch -Patch16: bugfix-fix-gala-gopher-h-print-err.patch -Patch17: fix-change-license-software-name.patch -Patch18: fix-fix-install-error.patch -Patch19: bugfix-zombie-task.patch -Patch20: fix-add-default-data-of-event-conf.patch -Patch21: fix-access-violation.patch -Patch22: ioprobe-fix-command-injection.patch +BuildRequires: systemd cmake gcc-c++ elfutils-devel clang llvm bpftool >= 6.8 +BuildRequires: libconfig-devel libevent-devel openssl-devel libbpf-devel >= 2:0.8 uthash-devel +BuildRequires: jsoncpp-devel git libstdc++-devel +# for DT +#BuildRequires: CUnit-devel + +%if !0%{?disable_kafka_channel} +BuildRequires: librdkafka-devel +%endif +%if !0%{?without_flamegraph} +BuildRequires: libcurl-devel +%endif +%if !0%{?without_jvm} +BuildRequires: java-1.8.0-openjdk-devel +%endif +%if !0%{?without_l7} +BuildRequires: jsoncpp-devel java-1.8.0-openjdk-devel +%endif + +Requires: bash gawk procps-ng glibc elfutils libbpf >= 2:0.8 +Requires: libconfig libevent iproute jsoncpp libstdc++ + +%if !0%{?disable_kafka_channel} +Requires: librdkafka +%endif + +%if !0%{?without_baseinfo} +Requires: ethtool systemd iproute +%endif + +%if !0%{?without_virt} +Requires: systemd +%endif +%if !0%{?without_tcp} +Requires: iproute conntrack-tools +%endif +%if !0%{?without_proc} +Requires: kmod +%endif +%if !0%{?without_flamegraph} +%if !0%{?disable_flamegraph_svg} +Requires: flamegraph +%endif +Requires: libcurl +%endif +%if !0%{?without_opengauss_sli} +Requires: python3-psycopg2 python3-yaml net-tools +%endif +%if !0%{?without_container} +Requires: cadvisor python3-libconf python3-requests net-tools util-linux +%endif +%if !0%{?without_postgre_sli} +Requires: iproute +%endif +%if !0%{?without_l7} +Requires: jsoncpp conntrack-tools +%endif +%if !0%{?without_tprofiling} +Requires: lsof +%endif + %description gala-gopher is a low-overhead eBPF-based probes framework @@ -49,30 +101,65 @@ gala-gopher is a low-overhead eBPF-based probes framework %prep %autosetup -n %{name}-%{version} -p1 + %build +BUILD_OPTS=( + -DENABLE_BASEINFO=%[0%{?without_baseinfo}?0:1] + -DENABLE_VIRT=%[0%{?without_virt}?0:1] + + -DENABLE_FLAMEGRAPH=%[0%{?without_flamegraph}?0:1] + -DENABLE_L7=%[0%{?without_l7}?0:1] + -DENABLE_TCP=%[0%{?without_tcp}?0:1] + -DENABLE_SOCKET=%[0%{?without_tcp}?0:1] + -DENABLE_IO=%[0%{?without_io}?0:1] + -DENABLE_PROC=%[0%{?without_proc}?0:1] + -DENABLE_JVM=%[0%{?without_jvm}?0:1] + -DENABLE_POSTGRE_SLI=%[0%{?without_postgre_sli}?0:1] + -DENABLE_OPENGAUSS_SLI=%[0%{?without_opengauss_sli}?0:1] + -DENABLE_NGINX=%[0%{?without_nginx}?0:1] + -DENABLE_TPROFILING=%[0%{?without_tprofiling}?0:1] + -DENABLE_KAFKA=%[0%{?without_kafka}?0:1] + -DENABLE_HW=%[0%{?without_hw}?0:1] + -DENABLE_KSLI=%[0%{?without_ksli}?0:1] + -DENABLE_CONTAINER=%[0%{?without_cadvisor}?0:1] + -DENABLE_SERMANT=%[0%{?without_sermant}?0:1] + + -DENABLE_REPORT_EVENT=%[0%{?disable_report_event}?0:1] + -DKAFKA_CHANNEL=%[0%{?disable_kafka_channel}?0:1] + -DFLAMEGRAPH_SVG=%[0%{?disable_flamegraph_svg}?0:1] +) + pushd build -sh build.sh --release %{vmlinux_ver} +export PATH=$PATH:/usr/lib64/llvm12/bin +sh build.sh --debug "${BUILD_OPTS[@]}" popd %check -pushd test -sh test_modules.sh -sh test_extend_probes.sh -sh test_probes.sh -popd +# pushd test +# sh test_modules.sh "${BUILD_OPTS[@]}" +# popd %install install -d %{buildroot}/etc/gala-gopher install -d %{buildroot}/opt/gala-gopher install -d %{buildroot}%{_bindir} +install -d %{buildroot}/usr/libexec/gala-gopher/ mkdir -p %{buildroot}/usr/lib/systemd/system install -m 0600 service/gala-gopher.service %{buildroot}/usr/lib/systemd/system/gala-gopher.service pushd build -sh install.sh %{buildroot}%{_bindir} %{buildroot}/opt/gala-gopher %{buildroot}/etc/gala-gopher +sh install.sh %{buildroot}%{_bindir} %{buildroot}/opt/gala-gopher %{buildroot}/etc/gala-gopher %{buildroot}/usr/libexec/gala-gopher/ %{buildroot}/opt/gala-gopher popd %post %systemd_post gala-gopher.service +if [ -d /var/log/gala-gopher ]; then + othermode=$(expr $(stat -L -c "%a" /var/log/gala-gopher) % 10) + if [ $othermode -ne 0 ]; then + chmod 750 /var/log/gala-gopher + chmod 750 /var/log/gala-gopher/debug + chmod 640 /var/log/gala-gopher/debug/gopher.log + fi +fi %preun %systemd_preun gala-gopher.service @@ -84,23 +171,26 @@ fi %systemd_postun_with_restart gala-gopher.service %files -%defattr(-,root,root) -%dir /opt/gala-gopher -%dir /opt/gala-gopher/extend_probes -%dir /opt/gala-gopher/meta -%dir /opt/gala-gopher/lib -%{_bindir}/* -/opt/gala-gopher/extend_probes/* -/opt/gala-gopher/meta/* -/opt/gala-gopher/lib/* -/etc/gala-gopher/res/event_multy_language.rc -%config(noreplace) /etc/gala-gopher/*.conf -%config(noreplace) /etc/gala-gopher/extend_probes/*.conf -%exclude /opt/gala-gopher/extend_probes/*.pyc -%exclude /opt/gala-gopher/extend_probes/*.pyo -/usr/lib/systemd/system/gala-gopher.service +%attr(0750,root,root) %dir /opt/gala-gopher +%attr(0550,root,root) %dir /opt/gala-gopher/extend_probes +%attr(0750,root,root) %dir /opt/gala-gopher/meta +%attr(0750,root,root) %dir /opt/gala-gopher/btf +%attr(0550,root,root) %dir /opt/gala-gopher/lib +%attr(0550,root,root) %{_bindir}/* +%attr(0550,root,root) /opt/gala-gopher/extend_probes/* +%attr(0640,root,root) /opt/gala-gopher/meta/* +#%attr(0640,root,root) /opt/gala-gopher/btf/* +%attr(0550,root,root) /opt/gala-gopher/lib/* +%attr(0640,root,root) %config(noreplace) /etc/gala-gopher/probes.init +%attr(0640,root,root) %config(noreplace) /etc/gala-gopher/*.conf +%attr(0640,root,root) %config(noreplace) /etc/gala-gopher/extend_probes/*.conf +%attr(0600,root,root) /usr/lib/systemd/system/gala-gopher.service +%attr(0550,root,root) /usr/libexec/gala-gopher/init_probes.sh %changelog +* Wed Apr 24 2024 Tangxin Xie - 2.0.0-1 +- Update to 2.0.1 + * Fri Mar 8 2024 Zhen Chen - 1.0.2-4 - fix command injection in ioprobe diff --git a/ioprobe-fix-command-injection.patch b/ioprobe-fix-command-injection.patch deleted file mode 100644 index fb67da03dfb4d80df570bf3b29b3fcef802d5008..0000000000000000000000000000000000000000 --- a/ioprobe-fix-command-injection.patch +++ /dev/null @@ -1,93 +0,0 @@ -From e37d4df29ff7191bff516f30a0640ed1a0791264 Mon Sep 17 00:00:00 2001 -From: Vchanger -Date: Mon, 4 Mar 2024 20:22:55 +0800 -Subject: [PATCH] ioprobe: fix command injection - ---- - src/common/common.h | 1 + - src/common/util.c | 24 +++++++++++++++++++ - .../extends/ebpf.probe/src/ioprobe/ioprobe.c | 8 ++++++- - 3 files changed, 32 insertions(+), 1 deletion(-) - -diff --git a/src/common/common.h b/src/common/common.h -index e7a8dee..5965444 100644 ---- a/src/common/common.h -+++ b/src/common/common.h -@@ -196,5 +196,6 @@ int __snprintf(char **buf, const int bufLen, int *remainLen, const char *format, - char is_digit_str(const char *s); - int get_system_uuid(char *buffer, unsigned int size); - int copy_file(const char *dst_file, const char *src_file); -+int check_path_for_security(const char *path); - - #endif -diff --git a/src/common/util.c b/src/common/util.c -index 98d5b12..9f7c861 100644 ---- a/src/common/util.c -+++ b/src/common/util.c -@@ -22,6 +22,9 @@ - #include - #include "common.h" - -+const char* command_injection_characters[] = {"|", ";", "&", "$", ">", "<", "(", ")", "./", "/.", "?", "*", -+ "\'", "`", "[", "]", "\\", "!", "\n"}; -+ - char *get_cur_date(void) - { - /* return date str, ex: 2021/05/17 */ -@@ -240,5 +243,26 @@ int copy_file(const char *dst_file, const char *src_file) { - free(buffer); - fclose(fp1); - fclose(fp2); -+ return 0; -+} -+ -+/* -+ * Check the path to avoid command injection -+ * @path: path executed as command -+ */ -+int check_path_for_security(const char *path) -+{ -+ if (path == NULL || strlen(path) == 0) { -+ return 0; -+ } -+ -+ int command_injection_characters_len = sizeof(command_injection_characters) / sizeof(command_injection_characters[0]); -+ -+ for (int i = 0; i < command_injection_characters_len; ++i) { -+ if (strstr(path, command_injection_characters[i])) { -+ return 1; -+ } -+ } -+ - return 0; - } -\ No newline at end of file -diff --git a/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c b/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c -index af7b1ea..dc809dd 100644 ---- a/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c -+++ b/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c -@@ -108,7 +108,7 @@ static char* __get_first_letter_pos(char *buf) - pos++; - p = buf + pos; - } -- -+ - if (pos >= len) { - return NULL; - } -@@ -166,6 +166,12 @@ static int get_devt(char *dev_name, int *major, int *minor) - - sys_file[0] = 0; - (void)snprintf(sys_file, PATH_LEN, "/sys/block/%s/dev", dev_name); -+ -+ if (check_path_for_security(sys_file)) { -+ fprintf(stderr, "invalid dev name\n", dev_name); -+ return -1; -+ } -+ - if (access(sys_file, 0)) { - sys_file[0] = 0; - (void)snprintf(sys_file, PATH_LEN, "/sys/block/*/%s/../dev", dev_name); --- -2.33.0 - diff --git a/modify-desc-from-chinese-to-english.patch b/modify-desc-from-chinese-to-english.patch deleted file mode 100644 index f46aff00d2f522f5be4cedafc9d99dca7af4d662..0000000000000000000000000000000000000000 --- a/modify-desc-from-chinese-to-english.patch +++ /dev/null @@ -1,25 +0,0 @@ -From c1787926da3435a53de49fc3ff70122f38509952 Mon Sep 17 00:00:00 2001 -From: dowzyx -Date: Fri, 28 Apr 2023 11:23:24 +0800 -Subject: [PATCH] modify desc from chinese to english - ---- - .../extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java b/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -index d7f635d..e421983 100644 ---- a/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -+++ b/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -@@ -72,7 +72,7 @@ public class JvmProbeAgent { - - private static void infoCollector(RuntimeMXBean runtimeBean) { - String jvmName = runtimeBean.getVmName(); -- String jvmVersion = runtimeBean.getVmVersion(); // 原始的为getSpecVersion(); -+ String jvmVersion = runtimeBean.getVmVersion(); // or getSpecVersion(); - String jvmVender = runtimeBean.getVmVendor(); - - writeMetricRecords(String.format("|jvm_info|%s|%s|%s|%s|%d|\n", pid, jvmName, jvmVender, jvmVersion, 1)); --- -2.33.0 - diff --git a/refactor-modify-jvmprobe-to-support-pod.patch b/refactor-modify-jvmprobe-to-support-pod.patch deleted file mode 100644 index 0b4f528603c436a29da1e9f98fdab3aa4114f694..0000000000000000000000000000000000000000 --- a/refactor-modify-jvmprobe-to-support-pod.patch +++ /dev/null @@ -1,1191 +0,0 @@ -From 5b8ecf7c24ca91a37b2073d4ee1a462f7aab5760 Mon Sep 17 00:00:00 2001 -From: dowzyx -Date: Thu, 9 Mar 2023 20:30:06 +0800 -Subject: [PATCH 16/30] refactor: modify jvmprobe to support pod - ---- - src/probes/extends/java.probe/build.sh | 100 +++--- - src/probes/extends/java.probe/install.sh | 5 +- - .../jvm.probe/config/META-INF/MANIFEST.MF | 1 - - .../java.probe/jvm.probe/jvm_probe.meta | 231 ++++++++++--- - .../java.probe/jvm.probe/src/JvmProbe.java | 305 +++++++++++++----- - .../extends/java.probe/jvm.probe/src/Vm.java | 173 ---------- - .../jvm.probe/src/agent/JvmProbeAgent.java | 188 +++++++++++ - .../src/agent/config/META-INF/MANIFEST.MF | 6 + - 8 files changed, 657 insertions(+), 352 deletions(-) - delete mode 100644 src/probes/extends/java.probe/jvm.probe/src/Vm.java - create mode 100644 src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java - create mode 100644 src/probes/extends/java.probe/jvm.probe/src/agent/config/META-INF/MANIFEST.MF - -diff --git a/src/probes/extends/java.probe/build.sh b/src/probes/extends/java.probe/build.sh -index 0ea7782..3c6f4e0 100755 ---- a/src/probes/extends/java.probe/build.sh -+++ b/src/probes/extends/java.probe/build.sh -@@ -4,95 +4,79 @@ PRJ_DIR=$(dirname $(readlink -f "$0")) - BUILD_FILES=${PRJ_DIR}/jvm.probe - cd ${BUILD_FILES} - --function find_jars() -+function find_cmd_jar() - { -- if [ -z $JAVA_HOME ]; -- then -- # find jdk -- clink_path=$(echo $(ls -lrt $javac_link) | awk -F " " '{print $NF}' ) -- link_path=$(echo $(ls -lrt $clink_path) | awk -F " " '{print $NF}' ) -- jdk_path=$(dirname $(dirname $link_path)) -- dir=$jdk_path -- else -- dir=$JAVA_HOME -- fi -- -- #tools.jar -- if [ -e $dir/lib/tools.jar ]; -- then -- mkdir -p lib -- cp $dir/lib/tools.jar lib/ -- else -- echo "Error: tools.jar not found" -- return 1 -- fi -- -- #management.jar -- if [ -e $dir/jre/lib/management-agent.jar ]; -+ if [ -z $(which jar 2>/dev/null) ]; - then -- cp $dir/jre/lib/management-agent.jar lib/ -- else -- echo "Error: management-agent.jar not found" -+ echo "Error: jar command not found" - return 1 -- fi -- -- return 0 -+ else -+ return 0 -+ fi - } - --function make_probe_jar() -+function make_probe_agent_jar() - { -- mkdir -p tmp -- cd tmp -- javac -cp ../lib/tools.jar ../src/*.java -d ./ -+ mkdir -p tmp -+ cd tmp -+ javac ../src/agent/JvmProbeAgent.java -d ./ -+ cd .. -+ jar cfm JvmProbeAgent.jar src/agent/config/META-INF/MANIFEST.MF -C tmp/ . - -- if [ -z $(which jar 2>/dev/null) ]; -- then -- echo "Error: jar command not found" -- return 1 -- else -- jar xf ../lib/tools.jar #>/dev/null 2>&1 -- cp ../lib/management-agent.jar ./ -- cd .. -- jar cfm JvmProbe.jar config/META-INF/MANIFEST.MF -C tmp/ . #2>/dev/null -- fi -+ rm -rf tmp 2>/dev/null -+ return 0 -+} -+ -+function make_probe_jar() -+{ -+ mkdir -p tmp -+ cd tmp/ -+ javac ../src/JvmProbe.java -d . -+ cd .. -+ jar cfm JvmProbe.jar config/META-INF/MANIFEST.MF -C tmp/ . - -- rm -rf tmp 2>/dev/null -- -- return 0 -+ rm -rf tmp 2>/dev/null -+ return 0 - } - - function compile_clean() - { -- rm -rf lib 2>/dev/null -- rm -rf tmp 2>/dev/null -+ rm -rf tmp 2>/dev/null - } - - if [ "$1" == "-c" -o "$1" == "--clean" ]; - then - compile_clean -+ rm -f *.jar 2>/dev/null - exit - fi - - java_link=$(which java 2>/dev/null) - javac_link=$(which javac 2>/dev/null) -- --if [ -z $java_link ] || [ -z $javac_link ]; -+ -+if [ -z $java_link ] || [ -z $javac_link ]; - then - echo "Error: java and javac : command not found" - exit 1 --else -- find_jars -+else -+ find_cmd_jar - if [ $? -eq 1 ]; - then -- exit 1 -- fi -- -+ exit 1 -+ fi -+ -+ make_probe_agent_jar -+ if [ $? -eq 1 ]; -+ then -+ exit 1 -+ fi -+ - make_probe_jar - if [ $? -eq 1 ]; - then -- exit 1 -+ exit 1 - fi -- -+ - compile_clean - exit - fi -diff --git a/src/probes/extends/java.probe/install.sh b/src/probes/extends/java.probe/install.sh -index ee653b5..4111fb3 100755 ---- a/src/probes/extends/java.probe/install.sh -+++ b/src/probes/extends/java.probe/install.sh -@@ -2,6 +2,7 @@ - PROGRAM=$0 - PRJ_DIR=$(dirname $(readlink -f "$0")) - INSTALL_FILES="jvm.probe/JvmProbe.jar" -+INSTALL_FILES+=" jvm.probe/JvmProbeAgent.jar" - - while getopts ":b:c:" opt - do -@@ -15,6 +16,8 @@ done - cd ${PRJ_DIR} - if [ ${INSTALL_PATH} ]; then - mkdir -p ${INSTALL_PATH} -- \cp ${INSTALL_FILES} ${INSTALL_PATH} -+ for file in ${INSTALL_FILES}; do -+ cp ${file} ${INSTALL_PATH} -+ done - fi - -diff --git a/src/probes/extends/java.probe/jvm.probe/config/META-INF/MANIFEST.MF b/src/probes/extends/java.probe/jvm.probe/config/META-INF/MANIFEST.MF -index 9f2a9af..fd73d72 100644 ---- a/src/probes/extends/java.probe/jvm.probe/config/META-INF/MANIFEST.MF -+++ b/src/probes/extends/java.probe/jvm.probe/config/META-INF/MANIFEST.MF -@@ -1,5 +1,4 @@ - Manifest-Version: 1.0 --Class-Path: management-agent.jar - Created-By: 1.8.0_333 (Oracle Corporation) - Main-Class: JvmProbe - -diff --git a/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta b/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta -index bcce601..bb9d01a 100755 ---- a/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta -+++ b/src/probes/extends/java.probe/jvm.probe/jvm_probe.meta -@@ -3,100 +3,259 @@ version = "1.0.0" - measurements: - ( - { -- table_name: "jvm", -+ table_name: "jvm_info", - entity_name: "jvm", - fields: - ( - { -- description: "ID of current java process ", -+ description: "ID of current java process.", - type: "key", - name: "tgid", - }, - { -- description: "pkg_name-java_main_class", -+ description: "JVM runtime Environment.", - type: "label", -- name: "pkg_name_main_class", -+ name: "runtime", - }, - { -- description: "JVM specification version ", -+ description: "....", - type: "label", -- name: "jvm_version", -+ name: "vendor", - }, - { -- description: "JVM implementation name ", -+ description: "....", - type: "label", -- name: "jvm_type", -+ name: "version", - }, - { -- description: "Garbage collectors` average usage", -+ description: "a fixed num 1 as metric", - type: "gauge", -- name: "gc_activity_util", -+ name: "info", -+ } -+ ) -+ }, -+ { -+ table_name: "jvm_process", -+ entity_name: "jvm", -+ fields: -+ ( -+ { -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", - }, - { -- description: "Garbage collector collection counts", -+ description: "Start time of the process since unix epoch in seconds.", - type: "gauge", -- name: "gc_total_count", -+ name: "process_start_time_seconds", - }, - { -- description: "Total garbage collector collection time", -+ description: "Total user and system CPU time spent in seconds.", - type: "gauge", -- name: "gc_total_seconds", -+ name: "process_cpu_seconds_total", - }, -+ ) -+ }, -+ { -+ table_name: "jvm_class", -+ entity_name: "jvm", -+ fields: -+ ( - { -- description: "Process start time in seconds", -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", -+ }, -+ { -+ description: "Start time of the process since unix epoch in seconds.", - type: "gauge", -- name: "process_start_time_seconds", -+ name: "classes_currently_loaded", - }, - { -- description: "Process run time in seconds", -+ description: "Total user and system CPU time spent in seconds.", - type: "gauge", -- name: "process_run_time_seconds", -+ name: "classes_loaded_total", -+ }, -+ ) -+ }, -+ { -+ table_name: "jvm_thread", -+ entity_name: "jvm", -+ fields: -+ ( -+ { -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", - }, - { -- description: "The number of threads in the current process", -+ description: "Current thread count of a JVM.", - type: "gauge", - name: "threads_current", - }, - { -- description: "The peak number of threads of the java process", -+ description: "Daemon thread count of a JVM.", -+ type: "gauge", -+ name: "threads_daemon", -+ }, -+ { -+ description: "Peak thread count of a JVM.", - type: "gauge", - name: "threads_peak", - }, - { -- description: "Deadlocked JVM thread number", -+ description: "Started thread count of a JVM.", -+ type: "gauge", -+ name: "threads_started_total", -+ }, -+ { -+ description: "Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers.", - type: "gauge", - name: "threads_deadlocked", - }, -+ ) -+ }, -+ { -+ table_name: "jvm_mem", -+ entity_name: "jvm", -+ fields: -+ ( -+ { -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", -+ }, -+ { -+ description: "type of JVM memory type: heap or noheap.", -+ type: "key", -+ name: "area", -+ }, - { -- description: "Used bytes of JVM _Heap memory area", -+ description: "Used bytes of a given JVM memory area.", - type: "gauge", -- name: "heap_memory_bytes_used", -+ name: "memory_bytes_used", - }, - { -- description: "JVM _Heap occupation", -+ description: "Committed (bytes) of a given JVM memory area.", - type: "gauge", -- name: "heap_occuped_percent", -+ name: "memory_bytes_committed", - }, - { -- description: "Used bytes of JVM _NonHeap memory area", -+ description: "Max (bytes) of a given JVM memory area.", - type: "gauge", -- name: "nonheap_memory_bytes_used", -+ name: "memory_bytes_max", - }, - { -- description: "JVM _NonHeap occupation", -+ description: "Initial bytes of a given JVM memory area.", - type: "gauge", -- name: "nonheap_occuped_percent", -+ name: "memory_bytes_init", - }, -+ ) -+ }, -+ { -+ table_name: "jvm_mem_pool", -+ entity_name: "jvm", -+ fields: -+ ( - { -- description: "The total capacity of the JVM buffer pools", -- type: "gauge", -- name: "buffer_pool_total_size", -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", - }, - { -- description: "the memory that the JVM uses for buffer pools", -- type: "gauge", -- name: "buffer_pool_used_bytes", -- } -+ description: "....", -+ type: "key", -+ name: "pool", -+ }, -+ { -+ description: "Used bytes of a given JVM memory pool.", -+ type: "gauge", -+ name: "memory_pool_bytes_used", -+ }, -+ { -+ description: "Committed bytes of a given JVM memory pool.", -+ type: "gauge", -+ name: "memory_pool_bytes_committed", -+ }, -+ { -+ description: "Max bytes of a given JVM memory pool.", -+ type: "gauge", -+ name: "memory_pool_bytes_max", -+ }, -+ { -+ description: "Used bytes after last collection of a given JVM memory pool.", -+ type: "gauge", -+ name: "memory_pool_collection_used_bytes", -+ }, -+ { -+ description: "Committed after last collection bytes of a given JVM memory pool.", -+ type: "gauge", -+ name: "memory_pool_collection_committed_bytes", -+ }, -+ { -+ description: "Max bytes after last collection of a given JVM memory pool.", -+ type: "gauge", -+ name: "memory_pool_collection_max_bytes", -+ }, -+ ) -+ }, -+ { -+ table_name: "jvm_buf_pool", -+ entity_name: "jvm", -+ fields: -+ ( -+ { -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", -+ }, -+ { -+ description: "....", -+ type: "label", -+ name: "pool", -+ }, -+ { -+ description: "Used bytes of a given JVM buffer pool.", -+ type: "gauge", -+ name: "buffer_pool_used_bytes", -+ }, -+ { -+ description: "Used buffers of a given JVM buffer pool.", -+ type: "gauge", -+ name: "buffer_pool_used_buffers", -+ }, -+ { -+ description: "Bytes capacity of a given JVM buffer pool.", -+ type: "gauge", -+ name: "buffer_pool_capacity_bytes", -+ }, -+ ) -+ }, -+ { -+ table_name: "jvm_gc", -+ entity_name: "jvm", -+ fields: -+ ( -+ { -+ description: "ID of current java process.", -+ type: "key", -+ name: "tgid", -+ }, -+ { -+ description: "....", -+ type: "label", -+ name: "gc", -+ }, -+ { -+ description: "Collection count of a given JVM garbage collector.", -+ type: "gauge", -+ name: "gc_collection_seconds_count", -+ }, -+ { -+ description: "Time spent in a given JVM garbage collector in seconds.", -+ type: "gauge", -+ name: "gc_collection_seconds_sum", -+ }, - ) - } - ) -diff --git a/src/probes/extends/java.probe/jvm.probe/src/JvmProbe.java b/src/probes/extends/java.probe/jvm.probe/src/JvmProbe.java -index 9c67f17..81d64ba 100644 ---- a/src/probes/extends/java.probe/jvm.probe/src/JvmProbe.java -+++ b/src/probes/extends/java.probe/jvm.probe/src/JvmProbe.java -@@ -1,83 +1,222 @@ --import com.sun.tools.attach.*; --import java.io.File; --import java.io.IOException; --import java.io.InputStream; --import java.nio.file.Files; --import java.nio.file.StandardCopyOption; --import java.util.List; --import java.util.HashMap; --import java.util.concurrent.ExecutorService; --import java.util.concurrent.Executors; --import java.util.concurrent.TimeUnit; -- --public class JvmProbe { -- -- public static List virtualMachineDescriptors; -- public static ExecutorService executorService; -- public static int time = 5; -- public static String agentPath; -- final static String agent = "management-agent.jar"; -- -- public static void main(String[] args) { -- ArgsParse(args); -- try { -- agentPath = getTemporaryRes(agent); -- } catch (IOException e) { -- System.out.println(e.getMessage()); -- System.exit(1); -- } -- -- while (true) { -- try { -- probe(); -- TimeUnit.SECONDS.sleep(time); -- } catch (InterruptedException e) { -- System.out.println(e.getMessage()); -- } -- } -- } -- -- public static void ArgsParse(String[] args) { -- int argsLen = args.length; -- HashMap argsMap = new HashMap<>(); -- for (int i = 0; i < argsLen / 2; i++) { -- argsMap.put(args[i], args[i + 1]); -- } -- //set -- if (argsMap.containsKey("-t")) { -- time = Integer.parseInt(argsMap.get("-t")); -- } -- } -- -- public static void probe() { -- virtualMachineDescriptors = VirtualMachine.list(); -- if (executorService == null) { -- executorService = Executors.newFixedThreadPool(5); -- } -- -- for (VirtualMachineDescriptor virtualMachineDescriptor : virtualMachineDescriptors) { -- executorService.submit(() -> { -- try { -- Vm vm = new Vm(virtualMachineDescriptor, agentPath); -- vm.getData(); -- } catch (IOException | AgentLoadException | AttachNotSupportedException | AgentInitializationException e) { -- System.out.println(e.getMessage()); -- } -- }); -- } -- } -- -- public static String getTemporaryRes(String resource) throws IOException { -- //read embedded resource from this JAR -- InputStream inputStream = JvmProbe.class.getResourceAsStream(resource); -- if(inputStream == null){ -- throw new IOException("Resource not found in the JAR"); -- } -- // create a temporary file -- File temporaryFile = File.createTempFile("resource", null); -- temporaryFile.deleteOnExit(); -- // Copy the resource data into the temporary file -- Files.copy(inputStream, temporaryFile.toPath(), StandardCopyOption.REPLACE_EXISTING); -- return temporaryFile.getAbsolutePath(); -- } --} -+import java.io.IOException; -+import java.io.File; -+import java.util.List; -+import java.util.ArrayList; -+import java.util.Map; -+import java.util.HashMap; -+import java.util.concurrent.TimeUnit; -+import java.lang.Process; -+import java.lang.ProcessBuilder; -+import java.io.BufferedReader; -+import java.io.InputStreamReader; -+import java.io.FileInputStream; -+import java.nio.file.Files; -+import java.nio.file.StandardCopyOption; -+ -+public class JvmProbe { -+ -+ private static String PROC_COMM_CMD = "/usr/bin/cat /proc/%d/comm 2> /dev/null"; -+ private static String PROC_STATUS_CMD = -+ "/usr/bin/cat /proc/%s/status 2> /dev/null | grep -w NStgid | awk -F ' ' '{print $NF}'"; -+ private static String BPFTOOL_DUMP_PROCMAP_CMD = -+ "bpftool map dump pinned /sys/fs/bpf/probe/proc_map 2> /dev/null | grep key | awk -F ' ' '{print $5$4$3$2}'"; -+ // jvm_attach load instrument false "/tmp/JvmProbeAgent.jar=," -+ private static String ATTACH_CMD = "%s %s %s load instrument false \"%s=%s,%s\""; -+ private final static String ATTACH_BIN_PATH = "/opt/gala-gopher/extend_probes/jvm_attach"; -+ private final static String HOST_JAR_DIR = "/opt/gala-gopher/extend_probes"; -+ private final static String NS_TMP_DIR = "/tmp"; -+ private final static String AGENT_JAR_NAME = "JvmProbeAgent.jar"; -+ private static final String METRIC_FILE_NAME = "jvm-metrics.txt"; -+ private static int period = 5; -+ -+ private static class ProcessInfo { -+ String pid; -+ String nspid; -+ } -+ -+ private static void argsParse(String[] args) { -+ int argsLen = args.length; -+ HashMap argsMap = new HashMap<>(); -+ for (int i = 0; i < argsLen / 2; i++) { -+ argsMap.put(args[i], args[i + 1]); -+ } -+ //set -+ if (argsMap.containsKey("-t")) { -+ period = Integer.parseInt(argsMap.get("-t")); -+ } -+ } -+ -+ private static Boolean detactProcIsJava(int procId) throws IOException { -+ List commandList = new ArrayList<>(); -+ commandList.add("sh"); -+ commandList.add("-c"); -+ commandList.add(String.format(PROC_COMM_CMD, procId)); -+ -+ ProcessBuilder pb = new ProcessBuilder(commandList); -+ Process process = pb.start(); -+ -+ BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); -+ String line = null; -+ while ((line = br.readLine()) != null) { -+ if (line.equals("java")) { -+ return true; -+ } -+ } -+ return false; -+ } -+ -+ private static List checkProcessToAttach() throws IOException, InterruptedException { -+ List pidList = new ArrayList<>(); -+ List commandList = new ArrayList<>(); -+ commandList.add("sh"); -+ commandList.add("-c"); -+ commandList.add(BPFTOOL_DUMP_PROCMAP_CMD); -+ -+ ProcessBuilder pb = new ProcessBuilder(commandList); -+ Process process = pb.start(); -+ int ret = process.waitFor(); -+ if (ret != 0) { -+ System.out.println("Process exited with code: " + ret + " cmd: " + commandList); -+ return pidList; // empty list -+ } -+ BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); -+ String line = null; -+ while ((line = br.readLine()) != null) { -+ int decimal = Integer.decode(String.format("0x%s", line)); -+ if (detactProcIsJava(decimal)) { -+ pidList.add(decimal); -+ } -+ } -+ -+ return pidList; -+ } -+ -+ private static ProcessInfo setEffectiveId(String pid) throws IOException { -+ ProcessInfo attachInfo = new ProcessInfo(); -+ List commandList = new ArrayList<>(); -+ commandList.add("sh"); -+ commandList.add("-c"); -+ commandList.add(String.format(PROC_STATUS_CMD, pid)); -+ -+ ProcessBuilder pb = new ProcessBuilder(commandList); -+ Process process = pb.start(); -+ -+ BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); -+ String line = null; -+ while ((line = br.readLine()) != null) { -+ attachInfo.nspid = line; -+ } -+ -+ attachInfo.pid = pid; -+ return attachInfo; -+ } -+ -+ private static void setJarFileToTmp(String Pid) throws IOException { -+ File nsAgentPath = new File(String.format("/proc/%s/root%s/%s", Pid, NS_TMP_DIR, AGENT_JAR_NAME)); -+ File hostAgentJarPath = new File(String.format("%s/%s", HOST_JAR_DIR, AGENT_JAR_NAME)); -+ -+ Files.copy(hostAgentJarPath.toPath(), nsAgentPath.toPath(), StandardCopyOption.REPLACE_EXISTING); -+ } -+ -+ private static Boolean getNsJarPath(ProcessInfo attachInfo) { -+ if (attachInfo.nspid.equals(attachInfo.pid)) { -+ return true; -+ } -+ return false; -+ } -+ -+ private static void delTmpFile(File file) { -+ if (file.delete() != true) { -+ System.out.println("delete file failed.\n"); -+ } -+ } -+ -+ private static int doAttach(ProcessInfo attachInfo) throws IOException, InterruptedException { -+ int ret = -1; -+ List commandList = new ArrayList<>(); -+ if (attachInfo.pid == null || attachInfo.nspid == null) { -+ System.out.println("attach failed becase null pid or nspid"); -+ return -1; -+ } -+ String nsJarPath; -+ if (getNsJarPath(attachInfo)) { -+ nsJarPath = String.format("/proc/%s/root%s/%s", attachInfo.pid, NS_TMP_DIR, AGENT_JAR_NAME); -+ } else { -+ nsJarPath = String.format("%s/%s", NS_TMP_DIR, AGENT_JAR_NAME); -+ } -+ -+ commandList.add("sh"); -+ commandList.add("-c"); -+ commandList.add(String.format(ATTACH_CMD, -+ ATTACH_BIN_PATH, attachInfo.pid, attachInfo.nspid, nsJarPath, attachInfo.pid, attachInfo.nspid)); -+ -+ ProcessBuilder pb = new ProcessBuilder(commandList); -+ Process process = pb.start(); -+ ret = process.waitFor(); -+ if (ret != 0) { -+ System.out.println("Program attach exited with code: " + ret + " command: " + commandList); -+ } -+ -+ return ret; -+ } -+ -+ private static int readMetricFile(ProcessInfo attachInfo) throws IOException { -+ File jvmMetricFile = new File(String.format("/proc/%s/root/tmp/%s", attachInfo.pid, METRIC_FILE_NAME)); -+ if (!jvmMetricFile.exists()) { -+ System.out.printf("Proc[%s] has no jvm metric file in /tmp path.\n", attachInfo.pid); -+ return 0; -+ } -+ -+ InputStreamReader streamReader = new InputStreamReader(new FileInputStream(jvmMetricFile)); -+ BufferedReader br = new BufferedReader(streamReader); -+ String line = null; -+ while ((line = br.readLine()) != null) { -+ System.out.println(line); -+ } -+ -+ // del metric file after read -+ if (jvmMetricFile.delete() != true) { -+ System.out.println("delete jvm metric file failed.\n"); -+ return -1; -+ } -+ -+ return 0; -+ } -+ -+ private static void probe() throws IOException, InterruptedException { -+ List jvmProcList = checkProcessToAttach(); -+ System.out.println(jvmProcList); -+ -+ for (int i = 0; i < jvmProcList.size(); i++) { -+ ProcessInfo attachInfo = setEffectiveId(jvmProcList.get(i).toString()); -+ try { -+ setJarFileToTmp(attachInfo.pid); -+ } catch (IOException e) { -+ System.out.println("copy host_jar to ns_tmp failed, err: %s" + e.getMessage()); -+ continue; -+ } -+ doAttach(attachInfo); -+ readMetricFile(attachInfo); -+ } -+ } -+ -+ public static void main(String[] args) { -+ argsParse(args); -+ while (true) { -+ try { -+ probe(); -+ } catch (IOException e) { -+ System.out.println(e.getMessage()); -+ } catch (InterruptedException e) { -+ System.out.println(e.getMessage()); -+ } -+ // sleep -+ try { -+ TimeUnit.SECONDS.sleep(period); -+ } catch (InterruptedException e) { -+ System.out.println(e.getMessage()); -+ } -+ } -+ } -+ -+} -diff --git a/src/probes/extends/java.probe/jvm.probe/src/Vm.java b/src/probes/extends/java.probe/jvm.probe/src/Vm.java -deleted file mode 100644 -index 61d111d..0000000 ---- a/src/probes/extends/java.probe/jvm.probe/src/Vm.java -+++ /dev/null -@@ -1,173 +0,0 @@ --import com.sun.tools.attach.*; --import javax.management.MBeanServerConnection; --import javax.management.remote.JMXConnector; --import javax.management.remote.JMXConnectorFactory; --import javax.management.remote.JMXServiceURL; --import java.io.IOException; --import java.lang.management.*; --import java.util.List; --import java.util.concurrent.TimeUnit; -- -- --public class Vm { -- public VirtualMachineDescriptor virtualMachineDescriptor; -- public MBeanServerConnection mBeanServerConnection; -- public JMXConnector connector; -- public final String canonicalPath; -- public StringBuilder res; -- -- final String localConnectorAddress = "com.sun.management.jmxremote.localConnectorAddress"; -- -- public Vm(VirtualMachineDescriptor virtualMachineDescriptor,String canonicalPath) throws AgentLoadException, IOException, AttachNotSupportedException, AgentInitializationException { -- this.virtualMachineDescriptor = virtualMachineDescriptor; -- this.canonicalPath = canonicalPath; -- getTargetVmConnection(virtualMachineDescriptor.id()); -- res = new StringBuilder(); -- } -- -- private void getTargetVmConnection(String vmId) throws IOException, AttachNotSupportedException, AgentLoadException, AgentInitializationException { -- -- VirtualMachine virtualMachine = VirtualMachine.attach(vmId); -- virtualMachine.loadAgent(canonicalPath); -- -- String connectorAddress = (String) virtualMachine.getAgentProperties().get(localConnectorAddress); -- virtualMachine.detach(); -- this.connector = JMXConnectorFactory.connect(new JMXServiceURL(connectorAddress)); -- this.mBeanServerConnection = connector.getMBeanServerConnection(); -- } -- -- public void getData() { -- try { -- getInfo(this.mBeanServerConnection); -- } catch (IOException e) { -- System.out.println(e.getMessage()); -- } finally { -- try { -- connector.close(); -- } catch (IOException e) { -- System.out.println(e.getMessage()); -- } -- } -- } -- -- private void getInfo(MBeanServerConnection connection) throws IOException { -- RuntimeMXBean runtimeMXBean = ManagementFactory.newPlatformMXBeanProxy( -- connection, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); -- com.sun.management.OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.newPlatformMXBeanProxy(connection, -- ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, com.sun.management.OperatingSystemMXBean.class); -- List garbageCollectorMXBeans = ManagementFactory.getPlatformMXBeans( -- connection,GarbageCollectorMXBean.class); -- ThreadMXBean threadMXBean = ManagementFactory.newPlatformMXBeanProxy( -- connection, ManagementFactory.THREAD_MXBEAN_NAME, ThreadMXBean.class); -- MemoryMXBean memoryMXBean = ManagementFactory.newPlatformMXBeanProxy( -- connection, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class); -- List pools = ManagementFactory.getPlatformMXBeans( -- connection,BufferPoolMXBean.class); -- // tid % mainclass -- String jvmPid = virtualMachineDescriptor.id(); -- String[] split = virtualMachineDescriptor.displayName().split(" "); -- String pkgNameMainClass = split[0]; -- res.append(String.format("|jvm|%s|%s|", jvmPid, pkgNameMainClass)); -- -- // vesion % type -- String jvmVersion = runtimeMXBean.getSpecVersion(); -- String jvmType = runtimeMXBean.getVmName(); -- res.append(String.format("%s|%s|", jvmVersion, jvmType)); -- -- // gc -- double gcDetail = getGarbageCollectionUsage(runtimeMXBean, operatingSystemMXBean, garbageCollectorMXBeans); -- long gc_counts = getTotalGarbageCollectionCount(garbageCollectorMXBeans); -- long gc_time_ms = getTotalGarbageCollectionTime(garbageCollectorMXBeans); -- res.append(String.format("%.2f|%d|%d|", gcDetail, gc_counts, gc_time_ms)); -- // process & thread -- Long processStartTimeSeconds = runtimeMXBean.getStartTime(); -- Long processCpuSecondsTotal = runtimeMXBean.getUptime(); -- -- int threadsCurrent = threadMXBean.getThreadCount(); -- int threadsPeak = threadMXBean.getPeakThreadCount(); -- int threadsDeadlocked = 0; -- if(threadMXBean.findDeadlockedThreads() != null) { -- threadsDeadlocked = threadMXBean.findDeadlockedThreads().length; -- } -- -- res.append(String.format("%d|%d|%d|%d|%d|", processStartTimeSeconds, processCpuSecondsTotal, threadsCurrent, threadsPeak, threadsDeadlocked)); -- -- // heap -- double heap_occupied = 100.0 * Double.valueOf(memoryMXBean.getHeapMemoryUsage().getCommitted()) / memoryMXBean.getHeapMemoryUsage().getMax(); -- long heap_used = memoryMXBean.getHeapMemoryUsage().getUsed(); -- res.append(String.format("%d|%.2f|", heap_used, heap_occupied)); -- -- // noheap -- long noheap_used = memoryMXBean.getNonHeapMemoryUsage().getUsed(); -- double noheap_occupied = memoryMXBean.getNonHeapMemoryUsage().getMax(); -- if(noheap_occupied > 0) { -- noheap_occupied = 100.0 * Double.valueOf(memoryMXBean.getNonHeapMemoryUsage().getCommitted()) / noheap_occupied; -- res.append(String.format("%d|%.2f|", noheap_used, noheap_occupied)); -- } -- else { -- res.append(String.format("%d|%.0f|", noheap_used,noheap_occupied)); -- } -- // bufferpool -- long bf_capacity = getTotalBufferPoolsCapacity(pools); -- long bf_used = getTotalBufferPoolsUsed(pools); -- res.append(String.format("%d|%d|\n", bf_capacity, bf_used)); -- System.out.printf(res.toString()); -- } -- -- private long getTotalGarbageCollectionCount(List garbageCollectorMXBeans) { -- long gc_count=0; -- for(GarbageCollectorMXBean gc :garbageCollectorMXBeans) { -- gc_count +=gc.getCollectionCount(); -- } -- return gc_count; -- } -- -- private long getTotalGarbageCollectionTime(List gcmList) { -- long total_ms=0; -- for(GarbageCollectorMXBean gc :gcmList) { -- total_ms += gc.getCollectionTime(); -- } -- return total_ms; -- } -- -- private double getGarbageCollectionUsage(RuntimeMXBean runtime, com.sun.management.OperatingSystemMXBean os, List gcmList) { -- // the uptime of the Java virtual machine -- long prevUpTime = runtime.getUptime(); -- // the approximate accumulated collection elapsed time -- long prevProcessGcTime = getTotalGarbageCollectionTime(gcmList); -- // the number of processors available to the Java virtual machine -- int processorCount = os.getAvailableProcessors(); -- try { -- TimeUnit.SECONDS.sleep(1); -- } catch (InterruptedException e) { -- System.out.println(e.getMessage()); -- System.exit(1); -- } -- -- long upTime = runtime.getUptime(); -- long processGcTime = getTotalGarbageCollectionTime(gcmList); -- long upTimeDiff = upTime - prevUpTime; -- long processGcTimeDiff = processGcTime - prevProcessGcTime; -- -- double gcDetail = (processGcTimeDiff * 100.0 / processorCount / upTimeDiff); -- return gcDetail; -- } -- -- private long getTotalBufferPoolsCapacity(List bufferpools) { -- long total_bytes = 0; -- for (BufferPoolMXBean bpool : bufferpools) { -- total_bytes += bpool.getTotalCapacity(); -- } -- return total_bytes; -- } -- -- private long getTotalBufferPoolsUsed(List bufferpools) { -- long total_bytes = 0; -- for (BufferPoolMXBean bpool : bufferpools) { -- total_bytes += bpool.getMemoryUsed(); -- } -- return total_bytes; -- } -- --} -- -diff --git a/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java b/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -new file mode 100644 -index 0000000..488c73c ---- /dev/null -+++ b/src/probes/extends/java.probe/jvm.probe/src/agent/JvmProbeAgent.java -@@ -0,0 +1,188 @@ -+package agent; -+ -+import java.util.List; -+import java.io.IOException; -+import java.io.BufferedWriter; -+import java.io.File; -+import java.io.FileWriter; -+import java.lang.management.ManagementFactory; -+import com.sun.management.OperatingSystemMXBean; -+import java.lang.management.RuntimeMXBean; -+import java.lang.management.ThreadMXBean; -+import java.lang.management.ClassLoadingMXBean; -+import java.lang.management.MemoryMXBean; -+import java.lang.management.MemoryUsage; -+import java.lang.management.MemoryPoolMXBean; -+import java.lang.management.BufferPoolMXBean; -+import java.lang.management.GarbageCollectorMXBean; -+import java.lang.reflect.Method; -+import java.lang.reflect.InvocationTargetException; -+ -+ -+public class JvmProbeAgent { -+ -+ private static final int MSEC_PER_SEC = 1000; -+ private static final int NSEC_PER_SEC = 1000000; -+ private static final String METRIC_FILE_NAME = "jvm-metrics.txt"; -+ private static String pid; -+ private static String nspid; -+ -+ private static String getMetricFilePath() { -+ String filePath = String.format("/proc/%s/root/tmp/%s", nspid, METRIC_FILE_NAME); -+ return filePath; -+ } -+ -+ private static void writeMetricRecords(String record) { -+ try { -+ File file = new File(getMetricFilePath()); -+ if (!file.exists()) { -+ file.createNewFile(); -+ } -+ FileWriter fw = new FileWriter(file.getAbsoluteFile(), true); -+ BufferedWriter bw = new BufferedWriter(fw); -+ bw.write(record); -+ bw.close(); -+ } catch (IOException e) { -+ e.printStackTrace(); -+ } -+ } -+ -+ private static void getJmxInfo() throws IOException { -+ RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); -+ OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); -+ ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); -+ ClassLoadingMXBean clBean = ManagementFactory.getClassLoadingMXBean(); -+ MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); -+ MemoryUsage heapUsage = memoryBean.getHeapMemoryUsage(); -+ MemoryUsage nonHeapUsage = memoryBean.getNonHeapMemoryUsage(); -+ List memPoolBeans = ManagementFactory.getMemoryPoolMXBeans(); -+ List bufPoolBeans = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class); -+ List garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans(); -+ -+ infoCollector(runtimeBean); -+ processCollector(runtimeBean, osBean); -+ classCollector(clBean); -+ threadCollector(threadBean); -+ memoryAreaCollector(heapUsage, "heap"); -+ memoryAreaCollector(nonHeapUsage, "nonheap"); -+ memoryPoolCollector(memPoolBeans); -+ bufferPoolCollector(bufPoolBeans); -+ gcCollector(garbageCollectors); -+ } -+ -+ private static void infoCollector(RuntimeMXBean runtimeBean) { -+ String jvmName = runtimeBean.getVmName(); -+ String jvmVersion = runtimeBean.getVmVersion(); // 原始的为getSpecVersion(); -+ String jvmVender = runtimeBean.getVmVendor(); -+ -+ writeMetricRecords(String.format("|jvm_info|%s|%s|%s|%s|%d|\n", pid, jvmName, jvmVender, jvmVersion, 1)); -+ } -+ -+ private static void processCollector(RuntimeMXBean runtimeBean, OperatingSystemMXBean osBean) { -+ long processStartTime = runtimeBean.getStartTime(); // ms -+ try { -+ Long processCpuTime = callLongGetter(osBean.getClass().getMethod("getProcessCpuTime"), osBean); // ns -+ writeMetricRecords(String.format("|jvm_process|%s|%d|%d|\n", pid, processStartTime, processCpuTime)); -+ } catch (Exception e) { -+ //System.out.println("error"); -+ } -+ } -+ -+ private static Long callLongGetter(Method method, Object obj) throws InvocationTargetException { -+ try { -+ return (Long) method.invoke(obj); -+ } catch (IllegalAccessException e) { -+ // Expected, the declaring class or interface might not be public. -+ } -+ -+ for (Class clazz : method.getDeclaringClass().getInterfaces()) { -+ try { -+ Method interfaceMethod = clazz.getMethod(method.getName(), method.getParameterTypes()); -+ Long result = callLongGetter(interfaceMethod, obj); -+ if (result != null) { -+ return result; -+ } -+ } catch (NoSuchMethodException e) { -+ // Expected, class might implement multiple, unrelated interfaces. -+ } -+ } -+ return null; -+ } -+ -+ // thread -+ private static void threadCollector(ThreadMXBean threadBean) { -+ int currentThreadCnt = threadBean.getThreadCount(); -+ int daemonThreadCnt = threadBean.getDaemonThreadCount(); -+ int peakThreadCnt = threadBean.getPeakThreadCount(); -+ long startThreadCnt = threadBean.getTotalStartedThreadCount(); -+ long cycleThreadDeadlocked = 0; -+ long[] deadlocks = threadBean.findDeadlockedThreads(); -+ if (deadlocks != null && deadlocks.length > 0) { -+ cycleThreadDeadlocked = deadlocks.length; -+ } -+ writeMetricRecords(String.format("|jvm_thread|%s|%d|%d|%d|%d|%d|\n", -+ pid, currentThreadCnt, daemonThreadCnt, peakThreadCnt, startThreadCnt, cycleThreadDeadlocked)); -+ } -+ -+ private static void classCollector(ClassLoadingMXBean clBean) { -+ int currentClassCnt = clBean.getLoadedClassCount(); -+ long totalClassCnt = clBean.getTotalLoadedClassCount(); -+ writeMetricRecords(String.format("|jvm_class|%s|%d|%d|\n", pid, currentClassCnt, totalClassCnt)); -+ } -+ -+ // memory -+ private static void memoryAreaCollector(MemoryUsage memUsage, String area) { -+ long memUsed = memUsage.getUsed(); -+ long memCommitted = memUsage.getCommitted(); -+ long memMax = memUsage.getMax(); -+ long memInit = memUsage.getInit(); -+ writeMetricRecords(String.format("|jvm_mem|%s|%s|%d|%d|%d|%d|\n", pid, area, memUsed, memCommitted, memMax, memInit)); -+ } -+ -+ // memory_pool -+ private static void memoryPoolCollector(List poolBeans) { -+ for (final MemoryPoolMXBean pool : poolBeans) { -+ MemoryUsage poolUsage = pool.getUsage(); -+ if (poolUsage != null) { -+ writeMetricRecords(String.format("|jvm_mem_pool|%s|%s|%d|%d|%d|", -+ pid, pool.getName(), poolUsage.getUsed(), poolUsage.getCommitted(), poolUsage.getMax())); -+ } -+ MemoryUsage colPoolUsage = pool.getCollectionUsage(); -+ if (colPoolUsage != null) { -+ writeMetricRecords(String.format("%d|%d|%d|", -+ colPoolUsage.getUsed(), colPoolUsage.getCommitted(), colPoolUsage.getMax())); -+ } else { -+ writeMetricRecords(String.format("-1|-1|-1|")); -+ } -+ writeMetricRecords(String.format("\n")); -+ } -+ } -+ -+ // buffer_pool -+ private static void bufferPoolCollector(List bufferPools) { -+ for (BufferPoolMXBean pool : bufferPools) { -+ writeMetricRecords(String.format("|jvm_buf_pool|%s|%s|%d|%d|%d|\n", -+ pid, pool.getName(), pool.getMemoryUsed(), pool.getCount(), pool.getTotalCapacity())); -+ } -+ } -+ -+ // gc -+ private static void gcCollector(List garbageCollectors) { -+ for (GarbageCollectorMXBean gc : garbageCollectors) { -+ writeMetricRecords(String.format("|jvm_gc|%s|%s|%d|%d|\n", -+ pid, gc.getName(), gc.getCollectionCount(), gc.getCollectionTime())); // ms -+ } -+ } -+ -+ -+ public static void agentmain(String agentArgs) { -+ String[] argStr = agentArgs.split("[,]"); -+ pid = argStr[0]; -+ nspid = argStr[1]; -+ try { -+ getJmxInfo(); -+ } catch (IOException e) { -+ System.out.println(e.getMessage()); -+ } -+ } -+} -diff --git a/src/probes/extends/java.probe/jvm.probe/src/agent/config/META-INF/MANIFEST.MF b/src/probes/extends/java.probe/jvm.probe/src/agent/config/META-INF/MANIFEST.MF -new file mode 100644 -index 0000000..2d6f14f ---- /dev/null -+++ b/src/probes/extends/java.probe/jvm.probe/src/agent/config/META-INF/MANIFEST.MF -@@ -0,0 +1,6 @@ -+Manifest-Version: 1.0 -+Created-By: 1.8.0_272 (Oracle Corporation) -+Agent-Class: agent.JvmProbeAgent -+Can-Retransform-Classes: true -+Can-Redefine-Classes: true -+ --- -2.33.0 - diff --git a/stackprobe-fix-inaccurate-call-stack-count.-add-samp.patch b/stackprobe-fix-inaccurate-call-stack-count.-add-samp.patch deleted file mode 100644 index fd607f9f998e6eb9efd1fde28a17811ea6222f87..0000000000000000000000000000000000000000 --- a/stackprobe-fix-inaccurate-call-stack-count.-add-samp.patch +++ /dev/null @@ -1,668 +0,0 @@ -From f084483fae4e051b872a4bc812ffa3dc73039c76 Mon Sep 17 00:00:00 2001 -From: wo_cow -Date: Fri, 31 Mar 2023 19:07:09 +0800 -Subject: [PATCH 29/30] stackprobe: fix inaccurate call stack count. add - sample_perioud param - ---- - .../src/stackprobe/conf/stackprobe.conf | 1 + - .../src/stackprobe/conf/stackprobe_conf.h | 3 + - .../src/stackprobe/conf/stackprobe_config.c | 11 ++ - .../ebpf.probe/src/stackprobe/flame_graph.c | 77 +------- - .../ebpf.probe/src/stackprobe/flame_graph.h | 5 +- - .../ebpf.probe/src/stackprobe/java_support.c | 2 +- - .../src/stackprobe/jvmti/jvm_agent.c | 2 +- - .../extends/ebpf.probe/src/stackprobe/stack.h | 3 +- - .../src/stackprobe/stack_bpf/stackprobe_bpf.h | 4 +- - .../ebpf.probe/src/stackprobe/stackprobe.c | 177 +++++++++++++----- - .../ebpf.probe/src/stackprobe/stackprobe.h | 2 + - .../extends/ebpf.probe/src/stackprobe/svg.h | 9 + - .../ebpf.probe/src/stackprobe/symbol.c | 1 - - 13 files changed, 175 insertions(+), 122 deletions(-) - -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf -index 0b3d0ac..4d50eb2 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf -@@ -2,6 +2,7 @@ general = - { - whitelist_enable = false; - period = 180; # unit is second -+ sample_period = 10; # unit is ms - log_dir = "/var/log/gala-gopher/stacktrace/logs"; - svg_dir = "/var/log/gala-gopher/stacktrace"; - flame_dir = "/var/log/gala-gopher/flamegraph"; -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_conf.h b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_conf.h -index d872b4d..a1b9913 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_conf.h -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_conf.h -@@ -23,6 +23,8 @@ - #define PROC_MAX_RANGE 64 - #define PERIOD_MAX 600 - #define PERIOD_MIN 30 -+#define SAMPLE_PERIOD_MAX 1000 -+#define SAMPLE_PERIOD_MIN 10 - - typedef enum { - SWITCH_ON = 0, -@@ -31,6 +33,7 @@ typedef enum { - - typedef struct { - int period; -+ int samplePeriod; - char logDir[PATH_LEN]; - char svgDir[PATH_LEN]; - char flameDir[PATH_LEN]; -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c -index 282cbbd..ed6ae19 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe_config.c -@@ -184,6 +184,17 @@ static int configLoadGeneral(void *config, config_setting_t *settings) - } - generalConfig->period = intVal; - -+ ret = config_setting_lookup_int(settings, "sample_period", &intVal); -+ if (ret == 0) { -+ ERROR("[STACKPROBE]: load config for general sample_period failed.\n"); -+ return -1; -+ } -+ if (intVal < SAMPLE_PERIOD_MIN || intVal > SAMPLE_PERIOD_MAX) { -+ ERROR("[STACKPROBE]: Please check config for general sample_period, val shold inside 10~1000.\n"); -+ return -1; -+ } -+ generalConfig->samplePeriod = intVal; -+ - ret = config_setting_lookup_string(settings, "log_dir", &strVal); - if (ret == 0) { - ERROR("[STACKPROBE]: load config for general log_dir failed.\n"); -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.c b/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.c -index fd03699..cb70ec0 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.c -@@ -25,7 +25,6 @@ - #include - #include - #include --#include - - #ifdef BPF_PROG_KERN - #undef BPF_PROG_KERN -@@ -38,16 +37,7 @@ - #include "bpf.h" - #include "flame_graph.h" - --#define POST_MAX_STEP_SIZE 1048576 // 1M --static int g_post_max = POST_MAX_STEP_SIZE; -- --struct post_info_s { -- int post_flag; -- int remain_size; -- char *buf_start; -- char *buf; -- CURL *curl; --}; -+extern int g_post_max; - - struct MemoryStruct { - char *memory; -@@ -108,13 +98,6 @@ static FILE *__open_flame_graph_fp(struct stack_svg_mng_s *svg_mng) - return sfg->fp; - } - --static FILE *__get_flame_graph_fp(struct stack_svg_mng_s *svg_mng) --{ -- struct stack_flamegraph_s *sfg; -- -- sfg = &(svg_mng->flame_graph); -- return sfg->fp; --} - - static void __mkdir_flame_graph_path(struct stack_svg_mng_s *svg_mng) - { -@@ -192,51 +175,7 @@ static void __reopen_flame_graph_file(struct stack_svg_mng_s *svg_mng) - __set_flame_graph_flags(svg_mng, FLAME_GRAPH_NEW); - } - --#define HISTO_TMP_LEN (2 * STACK_SYMBS_LEN) --static char __histo_tmp_str[HISTO_TMP_LEN]; -- --static int __do_wr_stack_histo(struct stack_svg_mng_s *svg_mng, -- struct stack_trace_histo_s *stack_trace_histo, int first, struct post_info_s *post_info) --{ -- FILE *fp = __get_flame_graph_fp(svg_mng); -- if (!fp) { -- ERROR("[FLAMEGRAPH]: Invalid fp.\n"); -- return -1; -- } - -- __histo_tmp_str[0] = 0; -- -- if (first) { -- (void)snprintf(__histo_tmp_str, HISTO_TMP_LEN, "%s %llu", -- stack_trace_histo->stack_symbs_str, stack_trace_histo->count); -- } else { -- (void)snprintf(__histo_tmp_str, HISTO_TMP_LEN, "\n%s %llu", -- stack_trace_histo->stack_symbs_str, stack_trace_histo->count); -- } -- -- if (post_info->post_flag) { -- int written = post_info->buf - post_info->buf_start; -- int ret = __snprintf(&post_info->buf, post_info->remain_size, &post_info->remain_size, "%s", __histo_tmp_str); -- if (ret < 0) { -- int new_post_max = g_post_max + POST_MAX_STEP_SIZE; -- char *temp = (char *)realloc(post_info->buf_start, new_post_max); -- if(temp == NULL) { -- ERROR("[FLAMEGRAPH]: Not enough post memory (realloc failed), current capacity is %d.\n", -- g_post_max); -- } else { -- post_info->buf_start = temp; -- post_info->buf = post_info->buf_start + written; -- post_info->remain_size += POST_MAX_STEP_SIZE; -- g_post_max = new_post_max; -- INFO("[FLAMEGRAPH]: post memory realloc to %d\n", g_post_max); -- (void)__snprintf(&post_info->buf, post_info->remain_size, &post_info->remain_size, "%s", __histo_tmp_str); -- } -- } -- } -- -- (void)fputs(__histo_tmp_str, fp); -- return 0; --} - - static size_t __write_memory_cb(void *contents, size_t size, size_t nmemb, void *userp) - { -@@ -362,8 +301,7 @@ static void __init_curl_handle(struct post_server_s *post_server, struct post_in - } - } - --static void __do_wr_flamegraph(struct stack_svg_mng_s *svg_mng, struct stack_trace_histo_s *head, -- struct post_server_s *post_server, int en_type) -+static void __do_wr_flamegraph(struct stack_svg_mng_s *svg_mng, struct post_server_s *post_server, int en_type) - { - int first_flag = 0; - struct post_info_s post_info = {.remain_size = g_post_max, .post_flag = 0}; -@@ -374,11 +312,8 @@ static void __do_wr_flamegraph(struct stack_svg_mng_s *svg_mng, struct stack_tra - - __init_curl_handle(post_server, &post_info); - -- struct stack_trace_histo_s *item, *tmp; -- H_ITER(head, item, tmp) { -- (void)__do_wr_stack_histo(svg_mng, item, first_flag, &post_info); -- first_flag = 0; -- } -+ iter_histo_tbl(svg_mng, en_type, &first_flag, &post_info); -+ - if (post_info.post_flag) { - __curl_post(post_server, &post_info, en_type); - } -@@ -389,10 +324,10 @@ static void __do_wr_flamegraph(struct stack_svg_mng_s *svg_mng, struct stack_tra - - #endif - --void wr_flamegraph(struct stack_svg_mng_s *svg_mng, struct stack_trace_histo_s *head, int en_type, -+void wr_flamegraph(struct stack_svg_mng_s *svg_mng, int en_type, - struct post_server_s *post_server) - { -- __do_wr_flamegraph(svg_mng, head, post_server, en_type); -+ __do_wr_flamegraph(svg_mng, post_server, en_type); - - if (is_svg_tmout(svg_mng)) { - (void)create_svg_file(svg_mng, -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.h b/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.h -index ea29107..d596328 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.h -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/flame_graph.h -@@ -20,8 +20,9 @@ - #include "svg.h" - #include "stackprobe.h" - --void wr_flamegraph(struct stack_svg_mng_s *svg_mng, struct stack_trace_histo_s *head, int en_type, -- struct post_server_s *post_server); -+int do_wr_stack_histo(struct stack_svg_mng_s *svg_mng, -+ struct stack_trace_histo_s *stack_trace_histo, int first, struct post_info_s *post_info); -+void wr_flamegraph(struct stack_svg_mng_s *svg_mng, int en_type, struct post_server_s *post_server); - int set_flame_graph_path(struct stack_svg_mng_s *svg_mng, const char* path, const char *flame_name); - int set_post_server(struct post_server_s *post_server, const char *pyroscopeServer); - void clean_post_server(); -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c b/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c -index 48b4386..e7088fb 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/java_support.c -@@ -63,7 +63,7 @@ static struct jvm_agent_hash_t *jvm_agent_head = NULL; - #define FIND_JAVA_PROC_COMM "ps -e -o pid,comm | grep java | awk '{print $1}'" - #define PROC_COMM "/usr/bin/cat /proc/%u/comm 2> /dev/null" - #define ATTACH_BIN_PATH "/opt/gala-gopher/extend_probes/jvm_attach" --#define ATTACH_CMD "%s %u %u load %s true %s" // jvm_attach load /tmp/jvm_agent.so true /tmp/java-symbolization-123 -+#define ATTACH_CMD "%s %u %u load %s true %s" // jvm_attach load /tmp/jvm_agent.so true /tmp/java-sym-123 - #define HOST_SO_DIR "/opt/gala-gopher/extend_probes" - #define AGENT_SO_FILE "jvm_agent.so" - #define HOST_JAVA_SYM_PATH "/proc/%u/root/tmp/java-sym-%u/%s" // /proc//root/tmp/java-sym-/java-symbols.bin -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/jvmti/jvm_agent.c b/src/probes/extends/ebpf.probe/src/stackprobe/jvmti/jvm_agent.c -index 21b1780..f8450ac 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/jvmti/jvm_agent.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/jvmti/jvm_agent.c -@@ -103,7 +103,7 @@ void get_class_name_from_csig(char *dest, size_t dest_size, const char *sig) { - for(i = 0; i < (dest_size - 1) && src[i]; i++) { - char c = src[i]; - if (c == '/') c = '.'; -- if (c == ';') break; -+ if (c == ';' || c == '$') break; - dest[i] = c; - } - dest[i] = 0; -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stack.h b/src/probes/extends/ebpf.probe/src/stackprobe/stack.h -index 82fda3f..5b6f7e3 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/stack.h -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stack.h -@@ -20,12 +20,11 @@ - #include "common.h" - - #define AGGRE_PERIOD (1 * 30 * 1000) // 30s --#define SAMPLE_PERIOD (10) // 10ms - #define TMOUT_PERIOD (AGGRE_PERIOD / 1000) // Second as unit - #define PROC_CACHE_MAX_COUNT 100 // Cache 100 proc symbols - #define DIV_ROUND_UP(NUM, DEN) ((NUM + DEN - 1) / DEN) - --#define PERCPU_SAMPLE_COUNT (2 * DIV_ROUND_UP(AGGRE_PERIOD, SAMPLE_PERIOD)) -+#define MAX_PERCPU_SAMPLE_COUNT (2 * DIV_ROUND_UP(AGGRE_PERIOD, 10)) // samplePeriod as 10ms - - struct convert_data_t { - u32 whitelist_enable; -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/stackprobe_bpf.h b/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/stackprobe_bpf.h -index 5626bd5..1ab3b13 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/stackprobe_bpf.h -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stack_bpf/stackprobe_bpf.h -@@ -54,7 +54,7 @@ struct { - __uint(type, BPF_MAP_TYPE_STACK_TRACE); - __uint(key_size, sizeof(u32)); - __uint(value_size, PERF_MAX_STACK_DEPTH * sizeof(u64)); -- __uint(max_entries, PERCPU_SAMPLE_COUNT); -+ __uint(max_entries, MAX_PERCPU_SAMPLE_COUNT); - } stackmap_a SEC(".maps"); - - -@@ -63,7 +63,7 @@ struct { - __uint(type, BPF_MAP_TYPE_STACK_TRACE); - __uint(key_size, sizeof(u32)); - __uint(value_size, PERF_MAX_STACK_DEPTH * sizeof(u64)); -- __uint(max_entries, PERCPU_SAMPLE_COUNT); -+ __uint(max_entries, MAX_PERCPU_SAMPLE_COUNT); - } stackmap_b SEC(".maps"); - - -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c -index eafe5ad..dcc26c7 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.c -@@ -64,6 +64,8 @@ - #define IS_IEG_ADDR(addr) ((addr) != 0xcccccccccccccccc && (addr) != 0xffffffffffffffff) - - #define MEMLEAK_SEC_NUM 4 -+#define HISTO_TMP_LEN (2 * STACK_SYMBS_LEN) -+#define POST_MAX_STEP_SIZE 1048576 // 1M - - #define BPF_GET_MAP_FD(obj, map_name) \ - ({ \ -@@ -85,7 +87,7 @@ - __ret; \ - }) - --typedef int (*AttachFunc)(struct svg_stack_trace_s *svg_st); -+typedef int (*AttachFunc)(struct svg_stack_trace_s *svg_st, StackprobeConfig *conf); - typedef int (*PerfProcessFunc)(void *ctx, int cpu, void *data, u32 size); - - enum pid_state_t { -@@ -116,6 +118,9 @@ struct bpf_link_hash_t { - struct bpf_link_hash_value v; // value - }; - -+ -+static char __histo_tmp_str[HISTO_TMP_LEN]; -+int g_post_max = POST_MAX_STEP_SIZE; - static struct probe_params params = {.period = DEFAULT_PERIOD}; - static volatile sig_atomic_t g_stop; - static struct stack_trace_s *g_st = NULL; -@@ -198,12 +203,10 @@ static void destroy_proc_cache_tbl(struct stack_trace_s *st) - return; - } - -- struct proc_cache_s *proc_hash_tbl = st->proc_cache; - struct proc_cache_s *item, *tmp; -- -- H_ITER(proc_hash_tbl, item, tmp) { -+ H_ITER(st->proc_cache, item, tmp) { - __destroy_proc_cache(item); -- H_DEL(proc_hash_tbl, item); -+ H_DEL(st->proc_cache, item); - (void)free(item); - } - st->proc_cache = NULL; -@@ -322,7 +325,7 @@ static struct raw_stack_trace_s *create_raw_stack_trace(struct stack_trace_s *st - { - struct raw_stack_trace_s *raw_stack_trace; - -- size_t stack_size = st->cpus_num * PERCPU_SAMPLE_COUNT; -+ size_t stack_size = st->cpus_num * MAX_PERCPU_SAMPLE_COUNT; - size_t mem_size = sizeof(struct raw_stack_trace_s); - mem_size += (stack_size * sizeof(struct raw_trace_s)); - -@@ -353,9 +356,19 @@ static int add_raw_stack_id(struct raw_stack_trace_s *raw_st, struct raw_trace_s - - #endif - -+#define STACK_LAYER_ELSE 0 -+#define STACK_LAYER_1ST 1 -+#define STACK_LAYER_2ND 2 // only for Java -+#define STACK_LAYER_3RD 3 // only for Java -+ -+// For deep call stacks (especially prone to Java programs), it is easy to sample incomplete call stacks. -+// If the function name at the first layer of the call stack contains ".", -+// it means that this is must be an incomplete call stack. -+// We query whether the first two layers of this call stack are contained in other call stacks (eg. A), -+// and then count this call on the A call stack. - #if 1 - static int __stack_addrsymbs2string(struct proc_symbs_s *proc_symbs, struct addr_symb_s *addr_symb, -- int first, char *p, int size) -+ int *layer, char *p, int size) - { - int ret; - char *symb; -@@ -366,21 +379,33 @@ static int __stack_addrsymbs2string(struct proc_symbs_s *proc_symbs, struct addr - char *cur_p = p; - int len = size; - --#if 1 -- symb = addr_symb->sym ?: addr_symb->mod; -- if (first) { -- if (proc_symbs->pod[0] != 0) { -- ret = __snprintf(&cur_p, len, &len, "[Pod]%s; ", proc_symbs->pod); -- } -- if (proc_symbs->container_name[0] != 0) { -- ret = __snprintf(&cur_p, len, &len, "[Con]%s; ", proc_symbs->container_name); -+ if (addr_symb->sym == NULL) { -+ return 0; -+ } -+ symb = addr_symb->sym; -+ -+ if (*layer == STACK_LAYER_1ST) { -+ if (strstr(symb, ".") != NULL) { -+ ret = __snprintf(&cur_p, len, &len, "; %s", symb); -+ *layer = STACK_LAYER_2ND; -+ } else { -+ if (proc_symbs->pod[0] != 0) { -+ ret = __snprintf(&cur_p, len, &len, "[Pod]%s; ", proc_symbs->pod); -+ } -+ if (proc_symbs->container_name[0] != 0) { -+ ret = __snprintf(&cur_p, len, &len, "[Con]%s; ", proc_symbs->container_name); -+ } -+ ret = __snprintf(&cur_p, len, &len, "[%d]%s; %s", proc_symbs->proc_id, proc_symbs->comm, symb); -+ *layer = STACK_LAYER_ELSE; - } -- ret = __snprintf(&cur_p, len, &len, "[%d]%s; %s", proc_symbs->proc_id, proc_symbs->comm, symb); -+ } else if (*layer == STACK_LAYER_2ND) { -+ ret = __snprintf(&cur_p, len, &len, "; %s", symb); -+ *layer = STACK_LAYER_3RD; - } else { - ret = __snprintf(&cur_p, len, &len, "; %s", symb); -+ *layer = STACK_LAYER_ELSE; - } - --#endif - if (ret < 0) { - return -1; - } -@@ -391,7 +416,7 @@ static int __stack_symbs2string(struct stack_symbs_s *stack_symbs, struct proc_s - char symbos_str[], size_t size) - { - int len; -- int first_flag = 1; -+ int layer = STACK_LAYER_1ST; - int remain_len = size; - char *pos = symbos_str; - struct addr_symb_s *addr_symb; -@@ -399,28 +424,19 @@ static int __stack_symbs2string(struct stack_symbs_s *stack_symbs, struct proc_s - for (int i = 0; i < PERF_MAX_STACK_DEPTH; i++) { - addr_symb = &(stack_symbs->user_stack_symbs[i]); - if (addr_symb->orign_addr != 0) { -- len = __stack_addrsymbs2string(proc_symbs, addr_symb, first_flag, pos, remain_len); -- if (len < 0) { -+ len = __stack_addrsymbs2string(proc_symbs, addr_symb, &layer, pos, remain_len); -+ if (layer == STACK_LAYER_3RD) { - return -1; - } -- remain_len -= len; -- pos += len; -- first_flag = 0; -- } -- } -- -- for (int i = 0; i < PERF_MAX_STACK_DEPTH; i++) { -- addr_symb = &(stack_symbs->kern_stack_symbs[i]); -- if (addr_symb->orign_addr != 0) { -- len = __stack_addrsymbs2string(proc_symbs, addr_symb, first_flag, pos, remain_len); - if (len < 0) { - return -1; - } - remain_len -= len; - pos += len; -- first_flag = 0; - } - } -+ -+ symbos_str[size - 1] = 0; - return 0; - } - -@@ -428,7 +444,8 @@ static int add_stack_histo(struct stack_trace_s *st, struct stack_symbs_s *stack - struct proc_symbs_s *proc_symbs, enum stack_svg_type_e en_type, s64 count) - { - char str[STACK_SYMBS_LEN]; -- struct stack_trace_histo_s *item = NULL, *new_item; -+ struct stack_trace_histo_s *item = NULL, *new_item = NULL; -+ struct stack_trace_histo_s *tmp; - - str[0] = 0; - if (__stack_symbs2string(stack_symbs, proc_symbs, str, STACK_SYMBS_LEN)) { -@@ -448,6 +465,20 @@ static int add_stack_histo(struct stack_trace_s *st, struct stack_symbs_s *stack - return 0; - } - -+ // Java incomplete call stack merge -+ if (str[0] == ';') { -+ char tmp_str[__FUNC_NAME_LEN] = {0}; -+ (void)snprintf(tmp_str, __FUNC_NAME_LEN, "[%d]", proc_symbs->proc_id); -+ H_ITER(st->svg_stack_traces[en_type]->histo_tbl, item, tmp) { -+ if (strstr(item->stack_symbs_str, tmp_str) && strstr(item->stack_symbs_str, str)) { -+ st->stats.count[STACK_STATS_HISTO_FOLDED]++; -+ item->count = item->count + count; -+ return 0; -+ } -+ } -+ return -1; -+ } -+ - H_FIND_S(st->svg_stack_traces[en_type]->histo_tbl, str, item); - if (item) { - st->stats.count[STACK_STATS_HISTO_FOLDED]++; -@@ -461,6 +492,7 @@ static int add_stack_histo(struct stack_trace_s *st, struct stack_symbs_s *stack - } - new_item->stack_symbs_str[0] = 0; - (void)strncpy(new_item->stack_symbs_str, str, STACK_SYMBS_LEN - 1); -+ new_item->stack_symbs_str[STACK_SYMBS_LEN - 1] = 0; - new_item->count = count < 0 ? 0 : count; - H_ADD_S(st->svg_stack_traces[en_type]->histo_tbl, stack_symbs_str, new_item); - -@@ -473,11 +505,9 @@ static void clear_stack_histo(struct svg_stack_trace_s *svg_st) - return; - } - -- struct stack_trace_histo_s *stack_trace_histo_tbl = svg_st->histo_tbl; - struct stack_trace_histo_s *item, *tmp; -- -- H_ITER(stack_trace_histo_tbl, item, tmp) { -- H_DEL(stack_trace_histo_tbl, item); -+ H_ITER(svg_st->histo_tbl, item, tmp) { -+ H_DEL(svg_st->histo_tbl, item); - (void)free(item); - } - svg_st->histo_tbl = NULL; -@@ -1035,12 +1065,13 @@ err: - return -1; - } - --static int attach_oncpu_bpf_prog(struct svg_stack_trace_s *svg_st) -+static int attach_oncpu_bpf_prog(struct svg_stack_trace_s *svg_st, StackprobeConfig *conf) - { - int ret; -+ int samplePeriod = conf->generalConfig->samplePeriod; - - struct perf_event_attr attr_type_sw = { -- .sample_freq = SAMPLE_PERIOD, -+ .sample_freq = samplePeriod, // default 10ms - .freq = 1, - .type = PERF_TYPE_SOFTWARE, - .config = PERF_COUNT_SW_CPU_CLOCK, -@@ -1270,7 +1301,7 @@ static void *__uprobe_attach_check(void *arg) - - } - --static int attach_memleak_bpf_prog(struct svg_stack_trace_s *svg_st) -+static int attach_memleak_bpf_prog(struct svg_stack_trace_s *svg_st, StackprobeConfig *conf) - { - int err; - #if 0 -@@ -1393,6 +1424,66 @@ static void *__running(void *arg) - return NULL; - } - -+static FILE *__get_flame_graph_fp(struct stack_svg_mng_s *svg_mng) -+{ -+ struct stack_flamegraph_s *sfg; -+ -+ sfg = &(svg_mng->flame_graph); -+ return sfg->fp; -+} -+ -+int __do_wr_stack_histo(struct stack_svg_mng_s *svg_mng, -+ struct stack_trace_histo_s *stack_trace_histo, int first, struct post_info_s *post_info) -+{ -+ FILE *fp = __get_flame_graph_fp(svg_mng); -+ if (!fp) { -+ ERROR("[STACKPROBE]: Invalid fp.\n"); -+ return -1; -+ } -+ -+ __histo_tmp_str[0] = 0; -+ -+ if (first) { -+ (void)snprintf(__histo_tmp_str, HISTO_TMP_LEN, "%s %llu", -+ stack_trace_histo->stack_symbs_str, stack_trace_histo->count); -+ } else { -+ (void)snprintf(__histo_tmp_str, HISTO_TMP_LEN, "\n%s %llu", -+ stack_trace_histo->stack_symbs_str, stack_trace_histo->count); -+ } -+ if (post_info->post_flag) { -+ int written = post_info->buf - post_info->buf_start; -+ int ret = __snprintf(&post_info->buf, post_info->remain_size, &post_info->remain_size, "%s", __histo_tmp_str); -+ if (ret < 0) { -+ int new_post_max = g_post_max + POST_MAX_STEP_SIZE; -+ char *temp = (char *)realloc(post_info->buf_start, new_post_max); -+ if(temp == NULL) { -+ ERROR("[STACKPROBE]: Not enough post memory (realloc failed), current capacity is %d.\n", -+ g_post_max); -+ } else { -+ post_info->buf_start = temp; -+ post_info->buf = post_info->buf_start + written; -+ post_info->remain_size += POST_MAX_STEP_SIZE; -+ g_post_max = new_post_max; -+ INFO("[STACKPROBE]: post memory realloc to %d\n", g_post_max); -+ (void)__snprintf(&post_info->buf, post_info->remain_size, &post_info->remain_size, "%s", __histo_tmp_str); -+ } -+ } -+ } -+ -+ (void)fputs(__histo_tmp_str, fp); -+ return 0; -+} -+ -+void iter_histo_tbl(struct stack_svg_mng_s *svg_mng, int en_type, int *first_flag, struct post_info_s *post_info) -+{ -+ struct stack_trace_histo_s *item, *tmp; -+ H_ITER(g_st->svg_stack_traces[en_type]->histo_tbl, item, tmp) { -+ (void)__do_wr_stack_histo(svg_mng, item, *first_flag, post_info); -+ *first_flag = 0; -+ } -+ return; -+} -+ - static void switch_stackmap() - { - struct stack_trace_s *st = g_st; -@@ -1410,8 +1501,10 @@ static void switch_stackmap() - if (st->svg_stack_traces[i] == NULL) { - continue; - } -- (void)stack_id2histogram(st, i, st->is_stackmap_a); -- wr_flamegraph(st->svg_stack_traces[i]->svg_mng, st->svg_stack_traces[i]->histo_tbl, i, &st->post_server); -+ if (stack_id2histogram(st, i, st->is_stackmap_a) != 0) { -+ continue; -+ } -+ wr_flamegraph(st->svg_stack_traces[i]->svg_mng , i, &st->post_server); - clear_raw_stack_trace(st->svg_stack_traces[i], st->is_stackmap_a); - } - record_running_ctx(st); -@@ -1468,7 +1561,7 @@ static int init_enabled_svg_stack_traces(StackprobeConfig *conf) - } - - if (flameProcs[i].func) { -- if (flameProcs[i].func(svg_st)) { -+ if (flameProcs[i].func(svg_st, conf)) { - goto err; - } - } -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.h b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.h -index 2e3cfcc..b09cdba 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.h -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/stackprobe.h -@@ -141,4 +141,6 @@ struct stack_trace_s { - int pmu_fd[]; // It must be put to the last. - }; - -+void iter_histo_tbl(struct stack_svg_mng_s *svg_mng, int en_type, int *first_flag, struct post_info_s *post_info); -+ - #endif -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/svg.h b/src/probes/extends/ebpf.probe/src/stackprobe/svg.h -index d763e7b..a707342 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/svg.h -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/svg.h -@@ -19,6 +19,15 @@ - - #include - #include "stack.h" -+#include -+ -+struct post_info_s { -+ int post_flag; -+ int remain_size; -+ char *buf_start; -+ char *buf; -+ CURL *curl; -+}; - - #define DAYS_TIME (24 * 60 *60) // 1 DAY - #define WEEKS_TIME (DAYS_TIME * 7) // 1 WEEK -diff --git a/src/probes/extends/ebpf.probe/src/stackprobe/symbol.c b/src/probes/extends/ebpf.probe/src/stackprobe/symbol.c -index 2f7e06b..0c4ffaf 100644 ---- a/src/probes/extends/ebpf.probe/src/stackprobe/symbol.c -+++ b/src/probes/extends/ebpf.probe/src/stackprobe/symbol.c -@@ -1049,7 +1049,6 @@ int proc_search_addr_symb(struct proc_symbs_s *proc_symbs, - } - continue; - } -- - // search debug symbs - ret = search_elf_symb(proc_symbs->mods[i]->debug_symbs, - addr, addr, comm, addr_symb); --- -2.33.0 -