!97 backport from upstream to fix bugs
From: @hu_liping Reviewed-by: @Vchanger Signed-off-by: @Vchanger
This commit is contained in:
commit
317eef2ee5
291
avoid-use-ato.patch
Normal file
291
avoid-use-ato.patch
Normal file
@ -0,0 +1,291 @@
|
||||
From 5a3f1ba26d09349a610d84547a076d619b2539bd Mon Sep 17 00:00:00 2001
|
||||
From: hlp_00667687 <huliping10@huawei.com>
|
||||
Date: Thu, 25 Apr 2024 17:21:15 +0800
|
||||
Subject: [PATCH] avoid use ato*
|
||||
|
||||
---
|
||||
src/common/histogram.c | 2 +-
|
||||
src/lib/probe/extend_probe.c | 2 +-
|
||||
src/lib/probe/snooper.c | 4 ++--
|
||||
src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c | 2 +-
|
||||
src/probes/extends/ebpf.probe/src/lib/conntrack.c | 8 ++++----
|
||||
src/probes/extends/ebpf.probe/src/lib/java_support.c | 8 ++++----
|
||||
src/probes/extends/ebpf.probe/src/lib/tcp.c | 2 +-
|
||||
src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c | 2 +-
|
||||
src/probes/system_infos.probe/system_cpu.c | 4 ++--
|
||||
src/probes/system_infos.probe/system_disk.c | 2 +-
|
||||
src/probes/system_infos.probe/system_os.c | 4 ++--
|
||||
src/probes/system_infos.probe/system_procs.c | 6 +++---
|
||||
src/probes/virtualized_infos.probe/virt_proc.c | 4 ++--
|
||||
13 files changed, 25 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/src/common/histogram.c b/src/common/histogram.c
|
||||
index cf79899..40ef2ef 100644
|
||||
--- a/src/common/histogram.c
|
||||
+++ b/src/common/histogram.c
|
||||
@@ -209,7 +209,7 @@ static int resolve_bucket_size(char *buf, char **new_buf)
|
||||
}
|
||||
*pos = '\0';
|
||||
|
||||
- ret = atoi(buf);
|
||||
+ ret = strtol(buf, NULL, 10);
|
||||
if (ret <= 0) {
|
||||
return -1;
|
||||
}
|
||||
diff --git a/src/lib/probe/extend_probe.c b/src/lib/probe/extend_probe.c
|
||||
index 5580ddb..bb40867 100644
|
||||
--- a/src/lib/probe/extend_probe.c
|
||||
+++ b/src/lib/probe/extend_probe.c
|
||||
@@ -60,7 +60,7 @@ static int lkup_and_set_probe_pid(struct probe_s *probe)
|
||||
if (exec_cmd((const char *)cmd, pid_str, INT_LEN) < 0) {
|
||||
return -1;
|
||||
}
|
||||
- pid = atoi(pid_str);
|
||||
+ pid = strtol(pid_str, NULL, 10);
|
||||
(void)pthread_rwlock_wrlock(&probe->rwlock);
|
||||
probe->pid = pid;
|
||||
(void)pthread_rwlock_unlock(&probe->rwlock);
|
||||
diff --git a/src/lib/probe/snooper.c b/src/lib/probe/snooper.c
|
||||
index 053e80a..917d1f1 100644
|
||||
--- a/src/lib/probe/snooper.c
|
||||
+++ b/src/lib/probe/snooper.c
|
||||
@@ -1176,7 +1176,7 @@ static int gen_snooper_by_procname(struct probe_s *probe)
|
||||
}
|
||||
}
|
||||
// Well matched
|
||||
- (void)add_snooper_obj_procid(probe, (u32)atoi(entry->d_name));
|
||||
+ (void)add_snooper_obj_procid(probe, strtoul(entry->d_name, NULL, 10));
|
||||
break;
|
||||
}
|
||||
cmdline_obtained = 0;
|
||||
@@ -1233,7 +1233,7 @@ static int __gen_snooper_by_container(struct probe_s *probe, con_id_element *con
|
||||
LL_FOREACH_SAFE(con_id_list, con_info_elem, tmp) {
|
||||
if (strcmp((const char *)container_id, con_info_elem->con_id) == 0) {
|
||||
// Well matched
|
||||
- (void)add_snooper_obj_procid(probe, (u32)atoi(entry->d_name));
|
||||
+ (void)add_snooper_obj_procid(probe, strtoul(entry->d_name, NULL, 10));
|
||||
break;
|
||||
}
|
||||
}
|
||||
diff --git a/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c b/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c
|
||||
index cc75ef4..272a264 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c
|
||||
@@ -599,7 +599,7 @@ static char is_load_probe(char *probe_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- count = atoi((const char *)count_str);
|
||||
+ count = strtol(count_str, NULL, 10);
|
||||
|
||||
return (count > 0) ? 1 : 0;
|
||||
}
|
||||
diff --git a/src/probes/extends/ebpf.probe/src/lib/conntrack.c b/src/probes/extends/ebpf.probe/src/lib/conntrack.c
|
||||
index db56071..d1f7391 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/lib/conntrack.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/lib/conntrack.c
|
||||
@@ -134,7 +134,7 @@ static struct tcp_conntrack_s *parse_conntrack_tcp(const char *s)
|
||||
if (__get_sub_str((const char *)p, "sport=", " ", sub_str, INET6_ADDRSTRLEN)) {
|
||||
goto err;
|
||||
}
|
||||
- conn_tcp->sport = atoi(sub_str);
|
||||
+ conn_tcp->sport = strtol(sub_str, NULL, 10);
|
||||
|
||||
// parse conntrack tcp dst port
|
||||
p = strstr((const char *)p, "dport=");
|
||||
@@ -145,7 +145,7 @@ static struct tcp_conntrack_s *parse_conntrack_tcp(const char *s)
|
||||
if (__get_sub_str((const char *)p, "dport=", " ", sub_str, INET6_ADDRSTRLEN)) {
|
||||
goto err;
|
||||
}
|
||||
- conn_tcp->dport = atoi(sub_str);
|
||||
+ conn_tcp->dport = strtol(sub_str, NULL, 10);
|
||||
|
||||
// parse conntrack tcp reply src ip address
|
||||
p = strstr((const char *)p, "src=");
|
||||
@@ -178,7 +178,7 @@ static struct tcp_conntrack_s *parse_conntrack_tcp(const char *s)
|
||||
if (__get_sub_str((const char *)p, "sport=", " ", sub_str, INET6_ADDRSTRLEN)) {
|
||||
goto err;
|
||||
}
|
||||
- conn_tcp->reply_sport = atoi(sub_str);
|
||||
+ conn_tcp->reply_sport = strtol(sub_str, NULL, 10);
|
||||
|
||||
// parse conntrack tcp reply dst port
|
||||
p = strstr((const char *)p, "dport=");
|
||||
@@ -189,7 +189,7 @@ static struct tcp_conntrack_s *parse_conntrack_tcp(const char *s)
|
||||
if (__get_sub_str((const char *)p, "dport=", " ", sub_str, INET6_ADDRSTRLEN)) {
|
||||
goto err;
|
||||
}
|
||||
- conn_tcp->reply_dport = atoi(sub_str);
|
||||
+ conn_tcp->reply_dport = strtol(sub_str, NULL, 10);
|
||||
|
||||
return conn_tcp;
|
||||
|
||||
diff --git a/src/probes/extends/ebpf.probe/src/lib/java_support.c b/src/probes/extends/ebpf.probe/src/lib/java_support.c
|
||||
index 0456db2..f8cc134 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/lib/java_support.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/lib/java_support.c
|
||||
@@ -76,13 +76,13 @@ static int _set_effective_id(int pid, struct jvm_process_info *v)
|
||||
size_t size;
|
||||
while (getline(&line, &size, status_file) != -1) {
|
||||
if (strncmp(line, "Uid:", 4) == 0 && strtok(line + 4, "\t ") != NULL) {
|
||||
- eUid = (uid_t)atoi(strtok(NULL, "\t "));
|
||||
+ eUid = strtoul(strtok(NULL, "\t "), NULL, 10);
|
||||
} else if (strncmp(line, "Gid:", 4) == 0 && strtok(line + 4, "\t ") != NULL) {
|
||||
- eGid = (gid_t)atoi(strtok(NULL, "\t "));
|
||||
+ eGid = strtoul(strtok(NULL, "\t "), NULL, 10);
|
||||
} else if (strncmp(line, "NStgid:", 7) == 0) {
|
||||
char* s;
|
||||
for (s = strtok(line + 7, "\t "); s != NULL; s = strtok(NULL, "\t ")) {
|
||||
- nspid = atoi(s);
|
||||
+ nspid = strtol(s, NULL, 10);
|
||||
}
|
||||
nspid_found = 1;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ static int _exe_attach_cmd(char *cmd)
|
||||
while(fgets(result_buf, sizeof(result_buf), f) != NULL) {
|
||||
DEBUG("%s\n", result_buf);
|
||||
/* 判断load指令执行返回结果,非0表示失败 */
|
||||
- if (isdigit(result_buf[0]) && atoi(result_buf) != 0) {
|
||||
+ if (isdigit(result_buf[0]) && strtol(result_buf, NULL, 10) != 0) {
|
||||
ERROR("[JAVA_SUPPORT]: attach failed, cmd: %s, ret code: %s\n", cmd, result_buf);
|
||||
(void)pclose(f);
|
||||
return -1;
|
||||
diff --git a/src/probes/extends/ebpf.probe/src/lib/tcp.c b/src/probes/extends/ebpf.probe/src/lib/tcp.c
|
||||
index 572c3e5..664b9f7 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/lib/tcp.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/lib/tcp.c
|
||||
@@ -652,7 +652,7 @@ int get_listen_sock_inode(struct tcp_listen_port *tlp, unsigned long *ino)
|
||||
return -1;
|
||||
}
|
||||
SPLIT_NEWLINE_SYMBOL(line);
|
||||
- *ino = atoi(line);
|
||||
+ *ino = strtol(line, NULL, 10);
|
||||
|
||||
(void)pclose(f);
|
||||
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 c7a680e..a3faacf 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/pgsliprobe/pgsliprobe.c
|
||||
@@ -299,7 +299,7 @@ static int add_bpf_link_by_search_pids()
|
||||
if (fgets(line, LINE_BUF_LEN, f) == NULL) {
|
||||
continue;
|
||||
}
|
||||
- pid = (unsigned int)atoi(line);
|
||||
+ pid = strtoul(line, NULL, 10);
|
||||
if (pid <= 0) {
|
||||
continue;
|
||||
}
|
||||
diff --git a/src/probes/system_infos.probe/system_cpu.c b/src/probes/system_infos.probe/system_cpu.c
|
||||
index f90592f..7c1a25f 100644
|
||||
--- a/src/probes/system_infos.probe/system_cpu.c
|
||||
+++ b/src/probes/system_infos.probe/system_cpu.c
|
||||
@@ -66,7 +66,7 @@ static void get_cpu_time_in_jiff(char *cpu_total_line, u64 *time_total, u64 *tim
|
||||
|
||||
while (i++ < PROC_STAT_COL_NUM) {
|
||||
retrieved_time = __strtok_r(NULL, " ", &save);
|
||||
- time = atoll(retrieved_time);
|
||||
+ time = strtoll(retrieved_time, NULL, 10);
|
||||
|
||||
*time_total += time;
|
||||
|
||||
@@ -256,7 +256,7 @@ static int get_cpu_mhz_info(void)
|
||||
token = strtok(NULL, ":");
|
||||
}
|
||||
if (last_token != NULL && index < cpus_num) {
|
||||
- cur_cpus[index]->mhz = atof(last_token);
|
||||
+ cur_cpus[index]->mhz = strtod(last_token, NULL);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
diff --git a/src/probes/system_infos.probe/system_disk.c b/src/probes/system_infos.probe/system_disk.c
|
||||
index f3fc32e..6465697 100644
|
||||
--- a/src/probes/system_infos.probe/system_disk.c
|
||||
+++ b/src/probes/system_infos.probe/system_disk.c
|
||||
@@ -468,7 +468,7 @@ static int get_diskdev_num(int *num)
|
||||
return -1;
|
||||
}
|
||||
SPLIT_NEWLINE_SYMBOL(line);
|
||||
- *num = atoi(line);
|
||||
+ *num = strtol(line, NULL, 10);
|
||||
(void)pclose(f);
|
||||
return 0;
|
||||
}
|
||||
diff --git a/src/probes/system_infos.probe/system_os.c b/src/probes/system_infos.probe/system_os.c
|
||||
index ceb8398..6a7088a 100644
|
||||
--- a/src/probes/system_infos.probe/system_os.c
|
||||
+++ b/src/probes/system_infos.probe/system_os.c
|
||||
@@ -139,7 +139,7 @@ static int parse_netmask(char *ip_addr)
|
||||
if (colon == NULL) {
|
||||
return 32;
|
||||
}
|
||||
- return (atoi(colon + 1) > 32) ? 0 : atoi(colon + 1);
|
||||
+ return (strtol(colon + 1, NULL, 10) > 32) ? 0 : strtol(colon + 1, NULL, 10);
|
||||
}
|
||||
|
||||
/* 检查IP是否在某网段内 */
|
||||
@@ -281,7 +281,7 @@ static int get_resource_info(struct node_infos *infos)
|
||||
infos->clock_ticks = (u64)sysconf(_SC_CLK_TCK);
|
||||
sys_btime[0] = 0;
|
||||
(void)get_system_btime(sys_btime);
|
||||
- infos->os_btime = (u64)atoll(sys_btime);
|
||||
+ infos->os_btime = strtoull(sys_btime, NULL, 10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/src/probes/system_infos.probe/system_procs.c b/src/probes/system_infos.probe/system_procs.c
|
||||
index 5a10fc3..f8dd1a3 100644
|
||||
--- a/src/probes/system_infos.probe/system_procs.c
|
||||
+++ b/src/probes/system_infos.probe/system_procs.c
|
||||
@@ -50,7 +50,7 @@ static proc_hash_t *hash_find_proc(u32 pid, const char *stime)
|
||||
proc_hash_t temp = {0};
|
||||
|
||||
temp.key.pid = pid;
|
||||
- temp.key.start_time = (u64)atoll(stime);
|
||||
+ temp.key.start_time = strtoull(stime, NULL, 10);
|
||||
HASH_FIND(hh, g_procmap, &temp.key, sizeof(proc_key_t), p);
|
||||
|
||||
return p;
|
||||
@@ -236,7 +236,7 @@ static int get_proc_fdcnt(u32 pid, proc_info_t *proc_info)
|
||||
|
||||
static void do_set_proc_stat(proc_info_t *proc_info, char *buf, int index)
|
||||
{
|
||||
- u64 value = (u64)atoll(buf);
|
||||
+ u64 value = strtoull(buf, NULL, 10);
|
||||
switch (index)
|
||||
{
|
||||
case PROC_STAT_MIN_FLT:
|
||||
@@ -557,7 +557,7 @@ static proc_hash_t* init_one_proc(u32 pid, char *stime, char *comm)
|
||||
(void)memset(item, 0, sizeof(proc_hash_t));
|
||||
|
||||
item->key.pid = pid;
|
||||
- item->key.start_time = (u64)atoll(stime);
|
||||
+ item->key.start_time = strtoull(stime, NULL, 10);
|
||||
|
||||
(void)snprintf(item->info.comm, sizeof(item->info.comm), "%s", comm);
|
||||
item->flag = PROC_IN_PROBE_RANGE;
|
||||
diff --git a/src/probes/virtualized_infos.probe/virt_proc.c b/src/probes/virtualized_infos.probe/virt_proc.c
|
||||
index cbdb6e0..7a6848b 100644
|
||||
--- a/src/probes/virtualized_infos.probe/virt_proc.c
|
||||
+++ b/src/probes/virtualized_infos.probe/virt_proc.c
|
||||
@@ -110,7 +110,7 @@ static int get_qemu_proc_tgid(struct proc_infos *one_proc)
|
||||
ERROR("[VIRT_PROC] get uuid(%s)'s tgid failed.\n", one_proc->uuid);
|
||||
return -1;
|
||||
}
|
||||
- one_proc->tgid = atoi(line);
|
||||
+ one_proc->tgid = strtol(line, NULL, 10);
|
||||
|
||||
output_proc_infos(one_proc);
|
||||
|
||||
@@ -147,7 +147,7 @@ static int get_vhost_proc_tgid(struct proc_infos *one_proc)
|
||||
return -1;
|
||||
}
|
||||
SPLIT_NEWLINE_SYMBOL(line);
|
||||
- tmp.tgid = atoi(line);
|
||||
+ tmp.tgid = strtol(line, NULL, 10);
|
||||
output_proc_infos(&tmp);
|
||||
}
|
||||
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
237
bugfix-probe_define-access-out-of-bounds.patch
Normal file
237
bugfix-probe_define-access-out-of-bounds.patch
Normal file
@ -0,0 +1,237 @@
|
||||
From dda00ceb8e98171a05cb5903cf26378a3d1c18d2 Mon Sep 17 00:00:00 2001
|
||||
From: wo_cow <niuqianqian@huawei.com>
|
||||
Date: Fri, 26 Apr 2024 11:19:00 +0800
|
||||
Subject: [PATCH] bugfix: probe_define access out of bounds
|
||||
|
||||
---
|
||||
gala-gopher.spec | 10 +++--
|
||||
src/common/ipc.h | 58 ++++++++++++++++++++++++++++
|
||||
src/lib/probe/probe_mng.c | 80 ++++++++++++---------------------------
|
||||
src/lib/probe/probe_mng.h | 1 +
|
||||
4 files changed, 90 insertions(+), 59 deletions(-)
|
||||
|
||||
diff --git a/gala-gopher.spec b/gala-gopher.spec
|
||||
index 24f6bae..85fa3fa 100644
|
||||
--- a/gala-gopher.spec
|
||||
+++ b/gala-gopher.spec
|
||||
@@ -109,7 +109,7 @@ BUILD_OPTS=(
|
||||
-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_SOCKET=%[0%{?without_socket}?0:1]
|
||||
-DENABLE_IO=%[0%{?without_io}?0:1]
|
||||
-DENABLE_PROC=%[0%{?without_proc}?0:1]
|
||||
-DENABLE_JVM=%[0%{?without_jvm}?0:1]
|
||||
@@ -155,8 +155,12 @@ 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
|
||||
+ if [ -d /var/log/gala-gopher ]; then
|
||||
+ chmod 750 /var/log/gala-gopher/debug
|
||||
+ fi
|
||||
+ if [ -e /var/log/gala-gopher/debug/gopher.log ]; then
|
||||
+ chmod 640 /var/log/gala-gopher/debug/gopher.log
|
||||
+ fi
|
||||
fi
|
||||
fi
|
||||
|
||||
diff --git a/src/common/ipc.h b/src/common/ipc.h
|
||||
index 0bc043a..c14bbf1 100644
|
||||
--- a/src/common/ipc.h
|
||||
+++ b/src/common/ipc.h
|
||||
@@ -21,6 +21,64 @@
|
||||
#include "args.h"
|
||||
#include "object.h"
|
||||
|
||||
+#ifndef ENABLE_BASEINFO
|
||||
+#define ENABLE_BASEINFO 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_VIRT
|
||||
+#define ENABLE_VIRT 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_FLAMEGRAPH
|
||||
+#define ENABLE_FLAMEGRAPH 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_L7
|
||||
+#define ENABLE_L7 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_TCP
|
||||
+#define ENABLE_TCP 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_SOCKET
|
||||
+#define ENABLE_SOCKET 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_IO
|
||||
+#define ENABLE_IO 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_PROC
|
||||
+#define ENABLE_PROC 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_JVM
|
||||
+#define ENABLE_JVM 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_POSTGRE_SLI
|
||||
+#define ENABLE_POSTGRE_SLI 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_OPENGAUSS_SLI
|
||||
+#define ENABLE_OPENGAUSS_SLI 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_NGINX
|
||||
+#define ENABLE_NGINX 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_KAFKA
|
||||
+#define ENABLE_KAFKA 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_TPROFILING
|
||||
+#define ENABLE_TPROFILING 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_HW
|
||||
+#define ENABLE_HW 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_NGINX
|
||||
+#define ENABLE_NGINX 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_KSLI
|
||||
+#define ENABLE_KSLI 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_CONTAINER
|
||||
+#define ENABLE_CONTAINER 0
|
||||
+#endif
|
||||
+#ifndef ENABLE_SERMANT
|
||||
+#define ENABLE_SERMANT 0
|
||||
+#endif
|
||||
+
|
||||
#define SNOOPER_MAX 100
|
||||
|
||||
/* FlameGraph subprobe define */
|
||||
diff --git a/src/lib/probe/probe_mng.c b/src/lib/probe/probe_mng.c
|
||||
index 83629cc..769a08b 100644
|
||||
--- a/src/lib/probe/probe_mng.c
|
||||
+++ b/src/lib/probe/probe_mng.c
|
||||
@@ -39,60 +39,24 @@ static int set_probe_bin(struct probe_s *probe, const char *bin);
|
||||
static void init_probe_bin(struct probe_s *probe, enum probe_type_e probe_type);
|
||||
|
||||
struct probe_define_s probe_define[] = {
|
||||
-#ifdef ENABLE_BASEINFO
|
||||
- {"baseinfo", "system_infos", PROBE_BASEINFO},
|
||||
-#endif
|
||||
-#ifdef ENABLE_VIRT
|
||||
- {"virt", "virtualized_infos", PROBE_VIRT},
|
||||
-#endif
|
||||
-#ifdef ENABLE_FLAMEGRAPH
|
||||
- {"flamegraph", "/opt/gala-gopher/extend_probes/stackprobe", PROBE_FG},
|
||||
-#endif
|
||||
-#ifdef ENABLE_L7
|
||||
- {"l7", "/opt/gala-gopher/extend_probes/l7probe", PROBE_L7},
|
||||
-#endif
|
||||
-#ifdef ENABLE_TCP
|
||||
- {"tcp", "/opt/gala-gopher/extend_probes/tcpprobe", PROBE_TCP},
|
||||
-#endif
|
||||
-#ifdef ENABLE_SOCKET
|
||||
- {"socket", "/opt/gala-gopher/extend_probes/endpoint", PROBE_SOCKET},
|
||||
-#endif
|
||||
-#ifdef ENABLE_IO
|
||||
- {"io", "/opt/gala-gopher/extend_probes/ioprobe", PROBE_IO},
|
||||
-#endif
|
||||
-#ifdef ENABLE_PROC
|
||||
- {"proc", "/opt/gala-gopher/extend_probes/taskprobe", PROBE_PROC},
|
||||
-#endif
|
||||
-#ifdef ENABLE_JVM
|
||||
- {"jvm", "/opt/gala-gopher/extend_probes/jvmprobe", PROBE_JVM},
|
||||
-#endif
|
||||
-#ifdef ENABLE_POSTGRE_SLI
|
||||
- {"postgre_sli", "/opt/gala-gopher/extend_probes/pgsliprobe", PROBE_POSTGRE_SLI},
|
||||
-#endif
|
||||
-#ifdef ENABLE_OPENGAUSS_SLI
|
||||
- {"opengauss_sli", "/opt/gala-gopher/extend_probes/pg_stat_probe.py", PROBE_GAUSS_SLI},
|
||||
-#endif
|
||||
-#ifdef ENABLE_NGINX
|
||||
- {"nginx", "/opt/gala-gopher/extend_probes/nginx_probe", PROBE_NGINX},
|
||||
-#endif
|
||||
-#ifdef ENABLE_KAFKA
|
||||
- {"kafka", "/opt/gala-gopher/extend_probes/kafkaprobe", PROBE_KAFKA},
|
||||
-#endif
|
||||
-#ifdef ENABLE_TPROFILING
|
||||
- {"tprofiling", "/opt/gala-gopher/extend_probes/tprofiling", PROBE_TP},
|
||||
-#endif
|
||||
-#ifdef ENABLE_HW
|
||||
- {"hw", "/opt/gala-gopher/extend_probes/hwprobe", PROBE_HW},
|
||||
-#endif
|
||||
-#ifdef ENABLE_KSLI
|
||||
- {"ksli", "/opt/gala-gopher/extend_probes/ksliprobe", PROBE_KSLI},
|
||||
-#endif
|
||||
-#ifdef ENABLE_CONTAINER
|
||||
- {"container", "/opt/gala-gopher/extend_probes/cadvisor_probe.py", PROBE_CONTAINER},
|
||||
-#endif
|
||||
-#ifdef ENABLE_SERMANT
|
||||
- {"sermant", "/opt/gala-gopher/extend_probes/sermant_probe.py", PROBE_SERMANT}
|
||||
-#endif
|
||||
+ {"baseinfo", "system_infos", PROBE_BASEINFO, ENABLE_BASEINFO},
|
||||
+ {"virt", "virtualized_infos", PROBE_VIRT, ENABLE_VIRT},
|
||||
+ {"flamegraph", "/opt/gala-gopher/extend_probes/stackprobe", PROBE_FG, ENABLE_FLAMEGRAPH},
|
||||
+ {"l7", "/opt/gala-gopher/extend_probes/l7probe", PROBE_L7, ENABLE_L7},
|
||||
+ {"tcp", "/opt/gala-gopher/extend_probes/tcpprobe", PROBE_TCP, ENABLE_TCP},
|
||||
+ {"socket", "/opt/gala-gopher/extend_probes/endpoint", PROBE_SOCKET, ENABLE_SOCKET},
|
||||
+ {"io", "/opt/gala-gopher/extend_probes/ioprobe", PROBE_IO, ENABLE_IO},
|
||||
+ {"proc", "/opt/gala-gopher/extend_probes/taskprobe", PROBE_PROC, ENABLE_PROC},
|
||||
+ {"jvm", "/opt/gala-gopher/extend_probes/jvmprobe", PROBE_JVM, ENABLE_JVM},
|
||||
+ {"postgre_sli", "/opt/gala-gopher/extend_probes/pgsliprobe", PROBE_POSTGRE_SLI, ENABLE_POSTGRE_SLI},
|
||||
+ {"opengauss_sli", "/opt/gala-gopher/extend_probes/pg_stat_probe.py", PROBE_GAUSS_SLI, ENABLE_OPENGAUSS_SLI},
|
||||
+ {"nginx", "/opt/gala-gopher/extend_probes/nginx_probe", PROBE_NGINX, ENABLE_NGINX},
|
||||
+ {"kafka", "/opt/gala-gopher/extend_probes/kafkaprobe", PROBE_KAFKA, ENABLE_KAFKA},
|
||||
+ {"tprofiling", "/opt/gala-gopher/extend_probes/tprofiling", PROBE_TP, ENABLE_TPROFILING},
|
||||
+ {"hw", "/opt/gala-gopher/extend_probes/hwprobe", PROBE_HW, ENABLE_HW},
|
||||
+ {"ksli", "/opt/gala-gopher/extend_probes/ksliprobe", PROBE_KSLI, ENABLE_KSLI},
|
||||
+ {"container", "/opt/gala-gopher/extend_probes/cadvisor_probe.py", PROBE_CONTAINER, ENABLE_CONTAINER},
|
||||
+ {"sermant", "/opt/gala-gopher/extend_probes/sermant_probe.py", PROBE_SERMANT, ENABLE_SERMANT},
|
||||
|
||||
// If you want to add a probe, add the probe define.
|
||||
};
|
||||
@@ -595,15 +559,20 @@ static enum probe_type_e get_probe_type_by_name(const char *probe_name)
|
||||
size_t size = sizeof(probe_define) / sizeof(struct probe_define_s);
|
||||
|
||||
if (probe_name == NULL) {
|
||||
+ PARSE_ERR("invalid probe name");
|
||||
return PROBE_TYPE_MAX;
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!strcasecmp(probe_define[i].desc, probe_name)) {
|
||||
+ if (probe_define[i].enable == 0) {
|
||||
+ PARSE_ERR("not supported in the current version");
|
||||
+ return PROBE_TYPE_MAX;
|
||||
+ }
|
||||
return probe_define[i].type;
|
||||
}
|
||||
}
|
||||
-
|
||||
+ PARSE_ERR("invalid probe name");
|
||||
return PROBE_TYPE_MAX;
|
||||
}
|
||||
|
||||
@@ -611,7 +580,6 @@ static struct probe_s *get_probe_by_name(const char *probe_name)
|
||||
{
|
||||
enum probe_type_e probe_type = get_probe_type_by_name(probe_name);
|
||||
if (probe_type >= PROBE_TYPE_MAX) {
|
||||
- PARSE_ERR("invalid probe name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
diff --git a/src/lib/probe/probe_mng.h b/src/lib/probe/probe_mng.h
|
||||
index f09190f..7853f17 100644
|
||||
--- a/src/lib/probe/probe_mng.h
|
||||
+++ b/src/lib/probe/probe_mng.h
|
||||
@@ -41,6 +41,7 @@ struct probe_define_s {
|
||||
char *desc;
|
||||
char *bin;
|
||||
enum probe_type_e type;
|
||||
+ char enable;
|
||||
};
|
||||
|
||||
typedef int (*ParseParam)(const char*, struct probe_params *);
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
25
cadvisor_probe-fix-int-to-str-warnings.patch
Normal file
25
cadvisor_probe-fix-int-to-str-warnings.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From e6e97f66c1127834a0026a6f5d2ee83bc040d9bb Mon Sep 17 00:00:00 2001
|
||||
From: xietangxin <xietangxin@huawei.com>
|
||||
Date: Tue, 30 Apr 2024 14:46:43 +0800
|
||||
Subject: [PATCH] cadvisor_probe: fix int to str warnings
|
||||
|
||||
---
|
||||
.../extends/python.probe/cadvisor.probe/cadvisor_probe.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
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 c4dcb45..d31f7a6 100755
|
||||
--- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
|
||||
+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
|
||||
@@ -118,7 +118,7 @@ class CadvisorProbe():
|
||||
else:
|
||||
raise Exception('[cadvisor_probe]cAdvisor running but get info failed')
|
||||
whitelist_label = "-whitelisted_container_labels=" + get_meta_label_list()
|
||||
- interval = "--housekeeping_interval="+ period + "s"
|
||||
+ interval = "--housekeeping_interval="+ str(period) + "s"
|
||||
ps = subprocess.Popen(["/usr/bin/cadvisor", "-port", str(self.port),\
|
||||
"--store_container_labels=false", interval, whitelist_label,\
|
||||
DISABLE_METRICS_OPTION],\
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
155
fix-buffer-overflow-caused-by-strcpy.patch
Normal file
155
fix-buffer-overflow-caused-by-strcpy.patch
Normal file
@ -0,0 +1,155 @@
|
||||
From 75b51832bbcea4b176fec299105c66140aafaaea Mon Sep 17 00:00:00 2001
|
||||
From: xietangxin <xietangxin@huawei.com>
|
||||
Date: Mon, 6 May 2024 11:22:24 +0800
|
||||
Subject: [PATCH] fix buffer overflow caused by strcpy()
|
||||
|
||||
---
|
||||
build/install.sh | 6 ++----
|
||||
src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c | 2 +-
|
||||
src/probes/extends/ebpf.probe/src/lib/tcp.c | 2 +-
|
||||
src/probes/system_infos.probe/system_cpu.c | 2 +-
|
||||
src/probes/system_infos.probe/system_disk.c | 8 ++++----
|
||||
src/probes/system_infos.probe/system_disk.h | 5 +++--
|
||||
src/probes/system_infos.probe/system_meminfo.c | 8 ++++----
|
||||
7 files changed, 16 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/build/install.sh b/build/install.sh
|
||||
index acde443..152b4fa 100755
|
||||
--- a/build/install.sh
|
||||
+++ b/build/install.sh
|
||||
@@ -172,10 +172,8 @@ function install_shared_lib()
|
||||
cp ${SHARED_LIB} ${GOPHER_SHARED_LIB_DIR}
|
||||
done
|
||||
|
||||
- if ! [[ $EXTEND_PROBES =~ "l7probe" ]] || ! [[ $EXTEND_PROBES =~ "stackprobe" ]] || ! [[ $EXTEND_PROBES =~ "jvm.probe" ]] ; then
|
||||
- echo "install lib:" ${JVM_ATTACH_BIN}
|
||||
- cp ${JVM_ATTACH_BIN} ${GOPHER_SHARED_LIB_DIR}
|
||||
- fi
|
||||
+ echo "install lib:" ${JVM_ATTACH_BIN}
|
||||
+ cp ${JVM_ATTACH_BIN} ${GOPHER_SHARED_LIB_DIR}
|
||||
}
|
||||
|
||||
function install_extend_probes()
|
||||
diff --git a/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c b/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c
|
||||
index 272a264..93d02d6 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/ioprobe/ioprobe.c
|
||||
@@ -237,7 +237,7 @@ static void get_diskname(const char* dev_name, char *disk_name, size_t size)
|
||||
char *p;
|
||||
char last_disk_name[DISK_NAME_LEN];
|
||||
|
||||
- strcpy(cmd, LSBLK_TREE_CMD);
|
||||
+ snprintf(cmd, sizeof(cmd), "%s", LSBLK_TREE_CMD);
|
||||
f = popen_chroot(cmd, "r");
|
||||
if (f == NULL) {
|
||||
return;
|
||||
diff --git a/src/probes/extends/ebpf.probe/src/lib/tcp.c b/src/probes/extends/ebpf.probe/src/lib/tcp.c
|
||||
index 664b9f7..e928e8a 100644
|
||||
--- a/src/probes/extends/ebpf.probe/src/lib/tcp.c
|
||||
+++ b/src/probes/extends/ebpf.probe/src/lib/tcp.c
|
||||
@@ -210,7 +210,7 @@ static struct tcp_estab_comm* __get_estab_comm(const char *start, unsigned int l
|
||||
return NULL;
|
||||
}
|
||||
te_comm->comm[0] = 0;
|
||||
- (void)strcpy(te_comm->comm, comm);
|
||||
+ (void)snprintf(te_comm->comm, sizeof(te_comm->comm), "%s", comm);
|
||||
|
||||
te_comm->pid = strtoul(pid_s, NULL, 10);
|
||||
te_comm->fd = strtoul(fd_s, NULL, 10);
|
||||
diff --git a/src/probes/system_infos.probe/system_cpu.c b/src/probes/system_infos.probe/system_cpu.c
|
||||
index 7c1a25f..ac7ccb5 100644
|
||||
--- a/src/probes/system_infos.probe/system_cpu.c
|
||||
+++ b/src/probes/system_infos.probe/system_cpu.c
|
||||
@@ -85,7 +85,7 @@ static void report_cpu_status(struct ipc_body_s *ipc_body)
|
||||
}
|
||||
|
||||
entityId[0] = 0;
|
||||
- (void)strcpy(entityId, "cpu");
|
||||
+ (void)snprintf(entityId, sizeof(entityId), "%s", "cpu");
|
||||
|
||||
evt.entityName = ENTITY_NAME;
|
||||
evt.entityId = entityId;
|
||||
diff --git a/src/probes/system_infos.probe/system_disk.c b/src/probes/system_infos.probe/system_disk.c
|
||||
index 6465697..bd16523 100644
|
||||
--- a/src/probes/system_infos.probe/system_disk.c
|
||||
+++ b/src/probes/system_infos.probe/system_disk.c
|
||||
@@ -162,12 +162,12 @@ static int init_fs_inode_info(void)
|
||||
(void)pclose(f);
|
||||
return -1;
|
||||
}
|
||||
- strcpy(fsItem->mount_on, stats.mount_on);
|
||||
+ snprintf(fsItem->mount_on, sizeof(fsItem->mount_on), "%s", stats.mount_on);
|
||||
HASH_ADD_STR(g_df_tbl, mount_on, fsItem);
|
||||
}
|
||||
fsItem->valid = 1;
|
||||
- strcpy(fsItem->fsname, stats.fsname);
|
||||
- strcpy(fsItem->fstype, stats.fstype);
|
||||
+ snprintf(fsItem->fsname, sizeof(fsItem->fsname), "%s", stats.fsname);
|
||||
+ snprintf(fsItem->fstype, sizeof(fsItem->fstype), "%s", stats.fstype);
|
||||
fsItem->inode_sum = stats.inode_sum;
|
||||
fsItem->inode_used = stats.inode_used;
|
||||
fsItem->inode_free = stats.inode_free;
|
||||
@@ -258,7 +258,7 @@ static int init_fs_status(void)
|
||||
if (!fsItem || !fsItem->valid) {
|
||||
continue;
|
||||
}
|
||||
- (void)strcpy(fsItem->mount_status, mountStatus);
|
||||
+ (void)snprintf(fsItem->mount_status, sizeof(fsItem->mount_status), "%s", mountStatus);
|
||||
}
|
||||
|
||||
(void)pclose(f);
|
||||
diff --git a/src/probes/system_infos.probe/system_disk.h b/src/probes/system_infos.probe/system_disk.h
|
||||
index 999b06e..7747d1e 100644
|
||||
--- a/src/probes/system_infos.probe/system_disk.h
|
||||
+++ b/src/probes/system_infos.probe/system_disk.h
|
||||
@@ -24,11 +24,12 @@
|
||||
/* the interval of time (@p) is given in second */
|
||||
#define S_VALUE(m,n,p) (((double) ((n) - (m))) / (p))
|
||||
|
||||
-#define FSTYPE_LEN 64
|
||||
+#define FSNAME_LEN 128
|
||||
+#define FSTYPE_LEN 32
|
||||
#define MOUNTON_LEN 128
|
||||
#define MOUNTSTATUS_LEN 8
|
||||
typedef struct {
|
||||
- char fsname[FSTYPE_LEN];
|
||||
+ char fsname[FSNAME_LEN];
|
||||
char fstype[FSTYPE_LEN];
|
||||
char mount_on[MOUNTON_LEN];
|
||||
char mount_status[MOUNTSTATUS_LEN];
|
||||
diff --git a/src/probes/system_infos.probe/system_meminfo.c b/src/probes/system_infos.probe/system_meminfo.c
|
||||
index 6c1dc91..023ae59 100644
|
||||
--- a/src/probes/system_infos.probe/system_meminfo.c
|
||||
+++ b/src/probes/system_infos.probe/system_meminfo.c
|
||||
@@ -44,7 +44,7 @@ int system_meminfo_init(void)
|
||||
"SwapTotal", "SwapFree", "Shmem", "Slab", "SReclaimable", "SUnreclaim", "KernelStack", "PageTables",
|
||||
"VmallocUsed", "HugePages_Total", "Hugepagesize"};
|
||||
for (int i = MEM_TOTAL; i < TOTAL_DATA_INDEX; i++) {
|
||||
- strcpy(meminfo_fields[i].key, key_[i]);
|
||||
+ snprintf(meminfo_fields[i].key, sizeof(meminfo_fields[i].key), "%s", key_[i]);
|
||||
meminfo_fields[i].value = 0;
|
||||
}
|
||||
return 0;
|
||||
@@ -109,8 +109,8 @@ static void report_meminfo_status(struct ipc_body_s *ipc_body, double mem_util,
|
||||
|
||||
entityId[0] = 0;
|
||||
entityName[0] = 0;
|
||||
- (void)strcpy(entityId, "/proc/meminfo");
|
||||
- (void)strcpy(entityName, "mem");
|
||||
+ (void)snprintf(entityId, sizeof(entityId), "%s", "/proc/meminfo");
|
||||
+ (void)snprintf(entityName, sizeof(entityName), "%s", "mem");
|
||||
|
||||
evt.entityName = entityName;
|
||||
evt.entityId = entityId;
|
||||
@@ -192,7 +192,7 @@ static int get_meminfo(struct ipc_body_s *ipc_body)
|
||||
}
|
||||
int cur_index = 0;
|
||||
while (!feof(f)) {
|
||||
- line[0] = 0;
|
||||
+ line[0] = 0;
|
||||
if (fgets(line, LINE_BUF_LEN, f) == NULL) {
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
110
fix-compile-warnings-when-disable-KAFKA_CHANNEL.patch
Normal file
110
fix-compile-warnings-when-disable-KAFKA_CHANNEL.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From f35fe992298b244064c841e8407ac7d96dce1be5 Mon Sep 17 00:00:00 2001
|
||||
From: xietangxin <xietangxin@huawei.com>
|
||||
Date: Tue, 30 Apr 2024 12:11:59 +0800
|
||||
Subject: [PATCH] fix compile warnings when disable KAFKA_CHANNEL
|
||||
|
||||
---
|
||||
build/install.sh | 11 ++++++++---
|
||||
src/common/event.c | 19 +++++++++++--------
|
||||
src/egress/egress.c | 1 +
|
||||
3 files changed, 20 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/build/install.sh b/build/install.sh
|
||||
index 55d911d..acde443 100755
|
||||
--- a/build/install.sh
|
||||
+++ b/build/install.sh
|
||||
@@ -22,7 +22,10 @@ function __create_btf_cache()
|
||||
for file in $(find ${BTF_DIR} -name "*"${ARCH}"*.btf.tar.xz") ; do
|
||||
tar -xf $file
|
||||
done
|
||||
- find ./ -name "*.btf" | xargs mv -t ${BTF_CACHE}
|
||||
+
|
||||
+ for file in $(find ./ -name "*.btf") ; do
|
||||
+ mv $file -t ${BTF_CACHE}
|
||||
+ done
|
||||
}
|
||||
|
||||
function __delete_btf_cache()
|
||||
@@ -169,8 +172,10 @@ function install_shared_lib()
|
||||
cp ${SHARED_LIB} ${GOPHER_SHARED_LIB_DIR}
|
||||
done
|
||||
|
||||
- echo "install lib:" ${JVM_ATTACH_BIN}
|
||||
- cp ${JVM_ATTACH_BIN} ${GOPHER_SHARED_LIB_DIR}
|
||||
+ if ! [[ $EXTEND_PROBES =~ "l7probe" ]] || ! [[ $EXTEND_PROBES =~ "stackprobe" ]] || ! [[ $EXTEND_PROBES =~ "jvm.probe" ]] ; then
|
||||
+ echo "install lib:" ${JVM_ATTACH_BIN}
|
||||
+ cp ${JVM_ATTACH_BIN} ${GOPHER_SHARED_LIB_DIR}
|
||||
+ fi
|
||||
}
|
||||
|
||||
function install_extend_probes()
|
||||
diff --git a/src/common/event.c b/src/common/event.c
|
||||
index a53dc2f..2694c2d 100644
|
||||
--- a/src/common/event.c
|
||||
+++ b/src/common/event.c
|
||||
@@ -26,11 +26,15 @@
|
||||
#include "nprobe_fprintf.h"
|
||||
#endif
|
||||
|
||||
-static struct evt_ts_hash_t *g_evt_head = NULL;
|
||||
+
|
||||
static unsigned int g_evt_period = 600;
|
||||
// static EventsConfig *g_evt_conf;
|
||||
// static char g_lang_type[MAX_EVT_GRP_NAME_LEN] = "zh_CN";
|
||||
|
||||
+
|
||||
+#ifdef ENABLE_REPORT_EVENT
|
||||
+static struct evt_ts_hash_t *g_evt_head = NULL;
|
||||
+
|
||||
static void hash_clear_older_evt(time_t cur_time);
|
||||
static unsigned int hash_count_evt(void);
|
||||
static int is_evt_need_report(const char *entityId, time_t cur_time);
|
||||
@@ -61,7 +65,6 @@ static struct evt_sec_s secs[EVT_SEC_MAX] = {
|
||||
{21, "FATAL"}
|
||||
};
|
||||
|
||||
-#ifdef ENABLE_REPORT_EVENT
|
||||
#define __EVT_BODY_LEN 512 // same as MAX_IMDB_METRIC_VAL_LEN
|
||||
void report_logs(const struct event_info_s* evt, enum evt_sec_e sec, const char * fmt, ...)
|
||||
{
|
||||
@@ -143,12 +146,6 @@ void report_logs(const struct event_info_s* evt, enum evt_sec_e sec, const char
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
-#else
|
||||
-void report_logs(const struct event_info_s* evt, enum evt_sec_e sec, const char * fmt, ...)
|
||||
-{
|
||||
- return;
|
||||
-}
|
||||
-#endif
|
||||
|
||||
void emit_otel_log(struct otel_log *ol)
|
||||
{
|
||||
@@ -243,6 +240,12 @@ static int is_evt_need_report(const char *entityId, time_t cur_time)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+#else
|
||||
+void report_logs(const struct event_info_s* evt, enum evt_sec_e sec, const char * fmt, ...)
|
||||
+{
|
||||
+ return;
|
||||
+}
|
||||
+#endif
|
||||
|
||||
void init_event_mgr(unsigned int time_out)
|
||||
{
|
||||
diff --git a/src/egress/egress.c b/src/egress/egress.c
|
||||
index 3af7396..6081b34 100644
|
||||
--- a/src/egress/egress.c
|
||||
+++ b/src/egress/egress.c
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include "base.h"
|
||||
+#include "common.h"
|
||||
#include "egress.h"
|
||||
|
||||
EgressMgr *EgressMgrCreate(void)
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
78
fix-delete-unnecessary-judgments.patch
Normal file
78
fix-delete-unnecessary-judgments.patch
Normal file
@ -0,0 +1,78 @@
|
||||
From f5078ecd0e1bd4d4e3862746c483b988a4f99b00 Mon Sep 17 00:00:00 2001
|
||||
From: wangqing <wangqing@uniontech.com>
|
||||
Date: Tue, 7 May 2024 18:09:13 +0800
|
||||
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E6=B2=A1=E5=BF=85?=
|
||||
=?UTF-8?q?=E8=A6=81=E7=9A=84=E5=88=A4=E6=96=AD?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: wangqing <wangqing@uniontech.com>
|
||||
---
|
||||
.../cadvisor.probe/cadvisor_probe.py | 49 +++++++++----------
|
||||
1 file changed, 24 insertions(+), 25 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 d31f7a6..81e06c9 100755
|
||||
--- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
|
||||
+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
|
||||
@@ -231,32 +231,31 @@ def print_metrics():
|
||||
continue
|
||||
for key, record in records.items():
|
||||
s = "|" + table + "|"
|
||||
- if table in g_meta:
|
||||
- for field_name, field_type in g_meta[table].items():
|
||||
- value = 0
|
||||
- if field_type == LABEL:
|
||||
- continue
|
||||
-
|
||||
- if field_type == KEY:
|
||||
- value = key
|
||||
- s += value + "|"
|
||||
- continue
|
||||
-
|
||||
- if field_name not in record:
|
||||
- value = ""
|
||||
- else:
|
||||
- for item in record[field_name].values():
|
||||
- if field_type == COUNTER:
|
||||
- if item[1] > item[0]:
|
||||
- value += item[1] - item[0]
|
||||
- else:
|
||||
- value += 0
|
||||
- item[0] = item[1]
|
||||
+ for field_name, field_type in g_meta[table].items():
|
||||
+ value = 0
|
||||
+ if field_type == LABEL:
|
||||
+ continue
|
||||
+
|
||||
+ if field_type == KEY:
|
||||
+ value = key
|
||||
+ s += value + "|"
|
||||
+ continue
|
||||
+
|
||||
+ if field_name not in record:
|
||||
+ value = ""
|
||||
+ else:
|
||||
+ for item in record[field_name].values():
|
||||
+ if field_type == COUNTER:
|
||||
+ if item[1] > item[0]:
|
||||
+ value += item[1] - item[0]
|
||||
else:
|
||||
- value += item
|
||||
- s = s + str(value) + "|"
|
||||
- print(s)
|
||||
- sys.stdout.flush()
|
||||
+ value += 0
|
||||
+ item[0] = item[1]
|
||||
+ else:
|
||||
+ value += item
|
||||
+ s = s + str(value) + "|"
|
||||
+ print(s)
|
||||
+ sys.stdout.flush()
|
||||
|
||||
|
||||
def clean_metrics():
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
39
fix-segmentation-fault-when-setting-out_channel-of-m.patch
Normal file
39
fix-segmentation-fault-when-setting-out_channel-of-m.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From a0909c7b51feedabda52faedfd0ec6d5f70b2c89 Mon Sep 17 00:00:00 2001
|
||||
From: xietangxin <xietangxin@huawei.com>
|
||||
Date: Mon, 29 Apr 2024 19:45:29 +0800
|
||||
Subject: [PATCH] fix segmentation fault when setting out_channel of metrics to
|
||||
logs
|
||||
|
||||
---
|
||||
src/daemon/daemon.c | 14 +++++++++-----
|
||||
1 file changed, 9 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
|
||||
index 84d9a09..4891ef2 100644
|
||||
--- a/src/daemon/daemon.c
|
||||
+++ b/src/daemon/daemon.c
|
||||
@@ -127,12 +127,16 @@ int DaemonRun(ResourceMgr *mgr)
|
||||
INFO("[DAEMON] create egress thread success.\n");
|
||||
|
||||
// 3. start web_server thread
|
||||
- ret = pthread_create(&mgr->web_server_mgr->tid, NULL, DaemonRunWebServer, mgr->web_server_mgr);
|
||||
- if (ret != 0) {
|
||||
- ERROR("[DAEMON] create web_server thread failed.(errno:%d, %s)\n", errno, strerror(errno));
|
||||
- return -1;
|
||||
+ if (mgr->web_server_mgr == NULL) {
|
||||
+ INFO("[DAEMON] skip create web_server thread.\n");
|
||||
+ } else {
|
||||
+ ret = pthread_create(&mgr->web_server_mgr->tid, NULL, DaemonRunWebServer, mgr->web_server_mgr);
|
||||
+ if (ret != 0) {
|
||||
+ ERROR("[DAEMON] create web_server thread failed.(errno:%d, %s)\n", errno, strerror(errno));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ INFO("[DAEMON] create web_server thread success.\n");
|
||||
}
|
||||
- INFO("[DAEMON] create web_server thread success.\n");
|
||||
|
||||
// 4. start metadata_report thread
|
||||
ret = pthread_create(&mgr->mmMgr->tid, NULL, DaemonRunMetadataReport, mgr->mmMgr);
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
84
fix-writing-metadata-to-log-file-properly.patch
Normal file
84
fix-writing-metadata-to-log-file-properly.patch
Normal file
@ -0,0 +1,84 @@
|
||||
From a04d1a44441a6d19f105177c0a6c9b73d36291ec Mon Sep 17 00:00:00 2001
|
||||
From: xietangxin <xietangxin@huawei.com>
|
||||
Date: Mon, 29 Apr 2024 19:25:01 +0800
|
||||
Subject: [PATCH] fix writing metadata to log file properly
|
||||
|
||||
---
|
||||
doc/constraints_introduction.md | 4 ++--
|
||||
src/common/logs.c | 7 +++----
|
||||
src/lib/meta/meta.c | 8 ++++++--
|
||||
3 files changed, 11 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/doc/constraints_introduction.md b/doc/constraints_introduction.md
|
||||
index 4e25a1f..8a30224 100644
|
||||
--- a/doc/constraints_introduction.md
|
||||
+++ b/doc/constraints_introduction.md
|
||||
@@ -38,5 +38,5 @@ logs =
|
||||
...
|
||||
};
|
||||
```
|
||||
-#### 1.2.3 meta 与 raw 日志
|
||||
-- meta, raw 日志打印配置与 debug 基本相同, 备份与最大校验尺寸配置方法一致。
|
||||
+#### 1.2.3 meta 日志
|
||||
+- meta 日志当前允许最大存储量为 100MB, 单位 MB, 当前meta日志不允许备份,当超过最大允许存储后会清除后重头部开始写
|
||||
diff --git a/src/common/logs.c b/src/common/logs.c
|
||||
index 7a2ba16..b68e1c8 100644
|
||||
--- a/src/common/logs.c
|
||||
+++ b/src/common/logs.c
|
||||
@@ -363,7 +363,7 @@ static void init_all_logger(void)
|
||||
init_logger(&g_metrics_logger, "metrics", 0, METRICS_LOGS_FILESIZE);
|
||||
init_logger(&g_event_logger, "event", 1, EVENT_LOGS_FILESIZE);
|
||||
init_logger(&g_debug_logger, "debug", 1, DEBUG_LOGS_FILESIZE);
|
||||
- init_logger(&g_meta_logger, "meta", 1, META_LOGS_FILESIZE);
|
||||
+ init_logger(&g_meta_logger, "meta", 0, META_LOGS_FILESIZE);
|
||||
}
|
||||
|
||||
#define FULL_PATH_LEN (PATH_LEN * 2)
|
||||
@@ -777,9 +777,8 @@ void wr_meta_logs(const char* logs)
|
||||
if (access(g_meta_abs_path, F_OK) == -1) {
|
||||
(void)append_meta_logger(local);
|
||||
}
|
||||
- if (g_meta_logger.level <= LOGGER_DEBUG) { // using debug level
|
||||
- log_without_date(&g_meta_logger, logs);
|
||||
- }
|
||||
+
|
||||
+ log_without_date(&g_meta_logger, logs);
|
||||
}
|
||||
|
||||
static void reappend_debug_logger(struct log_mgr_s *mgr)
|
||||
diff --git a/src/lib/meta/meta.c b/src/lib/meta/meta.c
|
||||
index 156b1cd..9302363 100644
|
||||
--- a/src/lib/meta/meta.c
|
||||
+++ b/src/lib/meta/meta.c
|
||||
@@ -591,6 +591,10 @@ static int report_one_metadata(const MeasurementMgr *mgr, const Measurement *mm)
|
||||
int ret;
|
||||
char *json_str = NULL;
|
||||
|
||||
+ if (mgr->meta_out_channel != OUT_CHNL_KAFKA && mgr->meta_out_channel != OUT_CHNL_LOGS) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
json_str = (char *)malloc(MAX_DATA_STR_LEN);
|
||||
if (json_str == NULL) {
|
||||
return -1;
|
||||
@@ -628,7 +632,7 @@ static int report_one_metadata(const MeasurementMgr *mgr, const Measurement *mm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int ReportMeteData(const MeasurementMgr *mgr)
|
||||
+static int ReportMetaData(const MeasurementMgr *mgr)
|
||||
{
|
||||
Measurement *mm = NULL;
|
||||
int i, meta_num;
|
||||
@@ -670,7 +674,7 @@ int ReportMetaDataMain(const MeasurementMgr *mgr)
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
- ret = ReportMeteData(mgr);
|
||||
+ ret = ReportMetaData(mgr);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
Summary: Intelligent ops toolkit for openEuler
|
||||
Name: gala-gopher
|
||||
Version: 2.0.1
|
||||
Release: 1
|
||||
Release: 2
|
||||
License: Mulan PSL v2
|
||||
URL: https://gitee.com/openeuler/gala-gopher
|
||||
Source: %{name}-%{version}.tar.gz
|
||||
@ -82,7 +82,7 @@ Requires: libcurl
|
||||
Requires: python3-psycopg2 python3-yaml net-tools
|
||||
%endif
|
||||
%if !0%{?without_container}
|
||||
Requires: cadvisor python3-libconf python3-requests net-tools util-linux
|
||||
Requires: cadvisor python3-requests net-tools util-linux
|
||||
%endif
|
||||
%if !0%{?without_postgre_sli}
|
||||
Requires: iproute
|
||||
@ -94,6 +94,15 @@ Requires: jsoncpp conntrack-tools
|
||||
Requires: lsof
|
||||
%endif
|
||||
|
||||
Patch1: avoid-use-ato.patch
|
||||
Patch2: refactor-cadvisor-remove-the-dependency-on-the-pytho.patch
|
||||
Patch3: fix-writing-metadata-to-log-file-properly.patch
|
||||
Patch4: fix-segmentation-fault-when-setting-out_channel-of-m.patch
|
||||
Patch5: fix-compile-warnings-when-disable-KAFKA_CHANNEL.patch
|
||||
Patch6: fix-buffer-overflow-caused-by-strcpy.patch
|
||||
Patch7: fix-delete-unnecessary-judgments.patch
|
||||
Patch8: cadvisor_probe-fix-int-to-str-warnings.patch
|
||||
Patch9: bugfix-probe_define-access-out-of-bounds.patch
|
||||
|
||||
%description
|
||||
gala-gopher is a low-overhead eBPF-based probes framework
|
||||
@ -188,7 +197,18 @@ fi
|
||||
%attr(0550,root,root) /usr/libexec/gala-gopher/init_probes.sh
|
||||
|
||||
%changelog
|
||||
* Wed Apr 24 2024 Tangxin Xie <xietangxin@huawei.com> - 2.0.0-1
|
||||
* Wed May 8 2024 Liping Hu <huliping10@huawei.com> - 2.0.1-2
|
||||
- fix delete unnecessary judgments
|
||||
fix buffer overflow caused by strcpy()
|
||||
cadvisor_probe: fix int to str warnings
|
||||
fix compile warnings when disable KAFKA_CHANNEL
|
||||
fix segmentation fault when setting out_channel of metrics to logs
|
||||
fix writing metadata to log file properly
|
||||
bugfix: probe_define access out of bounds
|
||||
refactor(cadvisor): remove the dependency on the python-libconf
|
||||
avoid use ato*
|
||||
|
||||
* Wed Apr 24 2024 Tangxin Xie <xietangxin@huawei.com> - 2.0.1-1
|
||||
- Update to 2.0.1
|
||||
|
||||
* Mon Apr 15 2024 Liping Hu <huliping10@huawei.com> - 2.0.0-6
|
||||
|
||||
543
refactor-cadvisor-remove-the-dependency-on-the-pytho.patch
Normal file
543
refactor-cadvisor-remove-the-dependency-on-the-pytho.patch
Normal file
@ -0,0 +1,543 @@
|
||||
From 388da3f3fc05357f1fbfc8a12ce40ad198397332 Mon Sep 17 00:00:00 2001
|
||||
From: h00465007 <hexiujun1@huawei.com>
|
||||
Date: Wed, 24 Apr 2024 10:45:15 +0800
|
||||
Subject: [PATCH] refactor(cadvisor): remove the dependency on the
|
||||
python-libconf
|
||||
|
||||
---
|
||||
gala-gopher.spec | 2 +-
|
||||
.../cadvisor.probe/cadvisor_probe.conf | 449 +++++++++---------
|
||||
.../cadvisor.probe/cadvisor_probe.py | 26 +-
|
||||
3 files changed, 240 insertions(+), 237 deletions(-)
|
||||
|
||||
diff --git a/gala-gopher.spec b/gala-gopher.spec
|
||||
index 2c11562..24f6bae 100644
|
||||
--- a/gala-gopher.spec
|
||||
+++ b/gala-gopher.spec
|
||||
@@ -81,7 +81,7 @@ Requires: libcurl
|
||||
Requires: python3-psycopg2 python3-yaml net-tools
|
||||
%endif
|
||||
%if !0%{?without_container}
|
||||
-Requires: cadvisor python3-libconf python3-requests net-tools util-linux
|
||||
+Requires: cadvisor python3-requests net-tools util-linux
|
||||
%endif
|
||||
%if !0%{?without_postgre_sli}
|
||||
Requires: iproute
|
||||
diff --git a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.conf b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.conf
|
||||
index 1ff2283..79686ee 100644
|
||||
--- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.conf
|
||||
+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.conf
|
||||
@@ -1,224 +1,225 @@
|
||||
-version = "1.0.0"
|
||||
-measurements:
|
||||
-(
|
||||
- {
|
||||
- table_name: "container_cpu",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "cpu",
|
||||
- type: "label",
|
||||
- name: "cpu",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative system cpu time consumed in seconds",
|
||||
- type: "counter",
|
||||
- name: "cpu_system_seconds_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative cpu time consumed in seconds",
|
||||
- type: "counter",
|
||||
- name: "cpu_usage_seconds_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative user cpu time consumed in seconds",
|
||||
- type: "counter",
|
||||
- name: "cpu_user_seconds_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Total time duration the container has been throttled",
|
||||
- type: "counter",
|
||||
- name: "cpu_cfs_throttled_seconds_total"
|
||||
- }
|
||||
- )
|
||||
- },
|
||||
- {
|
||||
- table_name: "container_fs",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "device",
|
||||
- type: "label",
|
||||
- name: "device",
|
||||
- },
|
||||
- {
|
||||
- description: "Number of available Inodes",
|
||||
- type: "gauge",
|
||||
- name: "fs_inodes_free",
|
||||
- },
|
||||
- {
|
||||
- description: "Number of Inodes",
|
||||
- type: "gauge",
|
||||
- name: "fs_inodes_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of seconds spent reading",
|
||||
- type: "counter",
|
||||
- name: "fs_read_seconds_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of seconds spent writing",
|
||||
- type: "counter",
|
||||
- name: "fs_write_seconds_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of bytes read",
|
||||
- type: "counter",
|
||||
- name: "fs_reads_bytes_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of bytes written",
|
||||
- type: "counter",
|
||||
- name: "fs_writes_bytes_total",
|
||||
- }
|
||||
- )
|
||||
- },
|
||||
- {
|
||||
- table_name: "container_memory",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "Number of bytes of page cache memory",
|
||||
- type: "gauge",
|
||||
- name: "memory_cache",
|
||||
- },
|
||||
- {
|
||||
- description: "Size of memory mapped files in bytes",
|
||||
- type: "gauge",
|
||||
- name: "memory_mapped_file",
|
||||
- },
|
||||
- {
|
||||
- description: "Size of RSS in byte",
|
||||
- type: "gauge",
|
||||
- name: "memory_rss",
|
||||
- },
|
||||
- {
|
||||
- description: "Current memory usage in bytes, including all memory regardless of when it was accessed",
|
||||
- type: "gauge",
|
||||
- name: "memory_usage_bytes",
|
||||
- },
|
||||
- {
|
||||
- description: "Current working set in bytes",
|
||||
- type: "gauge",
|
||||
- name: "memory_working_set_bytes",
|
||||
- }
|
||||
- )
|
||||
- },
|
||||
- {
|
||||
- table_name: "container_network",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "interface",
|
||||
- type: "label",
|
||||
- name: "interface",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of bytes received",
|
||||
- type: "counter",
|
||||
- name: "network_receive_bytes_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of errors encountered while receiving",
|
||||
- type: "counter",
|
||||
- name: "network_receive_errors_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of packets dropped while receiving",
|
||||
- type: "counter",
|
||||
- name: "network_receive_packets_dropped_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of bytes transmitted",
|
||||
- type: "counter",
|
||||
- name: "network_transmit_bytes_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of errors encountered while transmitting",
|
||||
- type: "counter",
|
||||
- name: "network_transmit_errors_total",
|
||||
- },
|
||||
- {
|
||||
- description: "Cumulative count of packets dropped while transmitting",
|
||||
- type: "counter",
|
||||
- name: "network_transmit_packets_dropped_total",
|
||||
- }
|
||||
- )
|
||||
- },
|
||||
- {
|
||||
- table_name: "container_oom",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "Count of out of memory events observed for the container",
|
||||
- type: "counter",
|
||||
- name: "oom_events_total",
|
||||
- }
|
||||
- )
|
||||
- },
|
||||
- {
|
||||
- table_name: "container_start",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "Start time of the container since unix epoch in seconds",
|
||||
- type: "gauge",
|
||||
- name: "start_time_seconds",
|
||||
- }
|
||||
- )
|
||||
- },
|
||||
- {
|
||||
- table_name: "container_file",
|
||||
- entity_name: "container",
|
||||
- fields:
|
||||
- (
|
||||
- {
|
||||
- description: "container id",
|
||||
- type: "key",
|
||||
- name: "container_id",
|
||||
- },
|
||||
- {
|
||||
- description: "Number of open file descriptors for the container",
|
||||
- type: "gauge",
|
||||
- name: "file_descriptors",
|
||||
- }
|
||||
- )
|
||||
- }
|
||||
-)
|
||||
-
|
||||
+{
|
||||
+ "version": "1.0.0",
|
||||
+ "measurements":
|
||||
+ [
|
||||
+ {
|
||||
+ "table_name": "container_cpu",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "cpu",
|
||||
+ "type": "label",
|
||||
+ "name": "cpu"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative system cpu time consumed in seconds",
|
||||
+ "type": "counter",
|
||||
+ "name": "cpu_system_seconds_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative cpu time consumed in seconds",
|
||||
+ "type": "counter",
|
||||
+ "name": "cpu_usage_seconds_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative user cpu time consumed in seconds",
|
||||
+ "type": "counter",
|
||||
+ "name": "cpu_user_seconds_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Total time duration the container has been throttled",
|
||||
+ "type": "counter",
|
||||
+ "name": "cpu_cfs_throttled_seconds_total"
|
||||
+ }
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "table_name": "container_fs",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "device",
|
||||
+ "type": "label",
|
||||
+ "name": "device"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Number of available Inodes",
|
||||
+ "type": "gauge",
|
||||
+ "name": "fs_inodes_free"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Number of Inodes",
|
||||
+ "type": "gauge",
|
||||
+ "name": "fs_inodes_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of seconds spent reading",
|
||||
+ "type": "counter",
|
||||
+ "name": "fs_read_seconds_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of seconds spent writing",
|
||||
+ "type": "counter",
|
||||
+ "name": "fs_write_seconds_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of bytes read",
|
||||
+ "type": "counter",
|
||||
+ "name": "fs_reads_bytes_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of bytes written",
|
||||
+ "type": "counter",
|
||||
+ "name": "fs_writes_bytes_total"
|
||||
+ }
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "table_name": "container_memory",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Number of bytes of page cache memory",
|
||||
+ "type": "gauge",
|
||||
+ "name": "memory_cache"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Size of memory mapped files in bytes",
|
||||
+ "type": "gauge",
|
||||
+ "name": "memory_mapped_file"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Size of RSS in byte",
|
||||
+ "type": "gauge",
|
||||
+ "name": "memory_rss"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Current memory usage in bytes, including all memory regardless of when it was accessed",
|
||||
+ "type": "gauge",
|
||||
+ "name": "memory_usage_bytes"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Current working set in bytes",
|
||||
+ "type": "gauge",
|
||||
+ "name": "memory_working_set_bytes"
|
||||
+ }
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "table_name": "container_network",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "interface",
|
||||
+ "type": "label",
|
||||
+ "name": "interface"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of bytes received",
|
||||
+ "type": "counter",
|
||||
+ "name": "network_receive_bytes_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of errors encountered while receiving",
|
||||
+ "type": "counter",
|
||||
+ "name": "network_receive_errors_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of packets dropped while receiving",
|
||||
+ "type": "counter",
|
||||
+ "name": "network_receive_packets_dropped_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of bytes transmitted",
|
||||
+ "type": "counter",
|
||||
+ "name": "network_transmit_bytes_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of errors encountered while transmitting",
|
||||
+ "type": "counter",
|
||||
+ "name": "network_transmit_errors_total"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Cumulative count of packets dropped while transmitting",
|
||||
+ "type": "counter",
|
||||
+ "name": "network_transmit_packets_dropped_total"
|
||||
+ }
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "table_name": "container_oom",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Count of out of memory events observed for the container",
|
||||
+ "type": "counter",
|
||||
+ "name": "oom_events_total"
|
||||
+ }
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "table_name": "container_start",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Start time of the container since unix epoch in seconds",
|
||||
+ "type": "gauge",
|
||||
+ "name": "start_time_seconds"
|
||||
+ }
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "table_name": "container_file",
|
||||
+ "entity_name": "container",
|
||||
+ "fields":
|
||||
+ [
|
||||
+ {
|
||||
+ "description": "container id",
|
||||
+ "type": "key",
|
||||
+ "name": "container_id"
|
||||
+ },
|
||||
+ {
|
||||
+ "description": "Number of open file descriptors for the container",
|
||||
+ "type": "gauge",
|
||||
+ "name": "file_descriptors"
|
||||
+ }
|
||||
+ ]
|
||||
+ }
|
||||
+ ]
|
||||
+}
|
||||
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 5adbaf2..c4dcb45 100755
|
||||
--- a/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
|
||||
+++ b/src/probes/extends/python.probe/cadvisor.probe/cadvisor_probe.py
|
||||
@@ -7,7 +7,8 @@ import subprocess
|
||||
import os
|
||||
import io
|
||||
import requests
|
||||
-import libconf
|
||||
+import json
|
||||
+import re
|
||||
import ipc
|
||||
|
||||
CONTAINER_ID_LEN = 64
|
||||
@@ -49,13 +50,13 @@ def convert_meta():
|
||||
global g_meta
|
||||
meta_path = os.path.join("/etc/gala-gopher/extend_probes/cadvisor_probe.conf")
|
||||
with io.open(meta_path, encoding='utf-8') as f:
|
||||
- meta = libconf.load(f)
|
||||
+ meta = json.load(f)
|
||||
g_meta = dict()
|
||||
- for measure in meta.measurements:
|
||||
- g_meta[measure.table_name] = dict()
|
||||
- for field in measure.fields:
|
||||
+ for measure in meta.get("measurements"):
|
||||
+ g_meta[measure.get("table_name")] = dict()
|
||||
+ for field in measure.get("fields"):
|
||||
try:
|
||||
- g_meta[measure.table_name][field.name] = field.type
|
||||
+ g_meta[measure.get("table_name")][field.get("name")] = field.get("type")
|
||||
except KeyError:
|
||||
# main will catch the exception
|
||||
raise
|
||||
@@ -164,20 +165,21 @@ class CadvisorProbe():
|
||||
if table_name not in g_metric:
|
||||
g_metric[table_name] = dict()
|
||||
|
||||
- metric_str = libconf.loads(line[(line.index("{") + 1):line.index("} ")])
|
||||
+ metric_str = line[line.index("{"):line.index("} ")+1]
|
||||
+ metric_dict = json.loads(re.sub(r'(\w+)=', r'"\1":', metric_str))
|
||||
# cadvisor metric id is cgroup path of container
|
||||
- if metric_str.id not in self.cgroup_path_map.keys():
|
||||
- continue;
|
||||
+ if metric_dict.get("id") not in self.cgroup_path_map.keys():
|
||||
+ continue
|
||||
|
||||
label_key= ''
|
||||
for field_name, field_type in g_meta[table_name].items():
|
||||
- if field_type == LABEL and field_name in metric_str:
|
||||
- label_key += "_" + metric_str[field_name]
|
||||
+ if field_type == LABEL and field_name in metric_dict:
|
||||
+ label_key += "_" + metric_dict[field_name]
|
||||
|
||||
if label_key == '':
|
||||
label_key = LABEL
|
||||
|
||||
- container_id = self.cgroup_path_map[metric_str.id]
|
||||
+ container_id = self.cgroup_path_map[metric_dict.get("id")]
|
||||
if container_id not in g_metric[table_name]:
|
||||
g_metric[table_name][container_id] = dict()
|
||||
|
||||
--
|
||||
2.28.0.windows.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user