From 7bb0ff121d90309fbd503980a9656079ca40e16c Mon Sep 17 00:00:00 2001 From: YanZhicong Date: Thu, 10 Jul 2025 18:04:01 +0800 Subject: [PATCH 1/2] Judgment when adding metric data type as Kafka --- src/ingress/ingress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ingress/ingress.c b/src/ingress/ingress.c index 5f0fa93a..18c8af7b 100644 --- a/src/ingress/ingress.c +++ b/src/ingress/ingress.c @@ -284,7 +284,7 @@ static int ProcessMetricData(IngressMgr *mgr, const char *content, const char *t } } - if (mgr->imdbMgr->writeLogsType == METRIC_LOG_PROM || mgr->imdbMgr->writeLogsType == METRIC_LOG_JSON) { + if (mgr->imdbMgr->writeLogsType == METRIC_LOG_PROM || mgr->imdbMgr->writeLogsType == METRIC_LOG_JSON || mgr->imdbMgr->writeLogsType == METRIC_LOG_NULL) { // save metric to imdb rec = IMDB_DataBaseMgrCreateRec(mgr->imdbMgr, table, content); if (rec == NULL) { -- Gitee From f5c865436c9cf63ea7173339f9548ef0694778c2 Mon Sep 17 00:00:00 2001 From: YanZhicong Date: Mon, 14 Jul 2025 15:47:20 +0800 Subject: [PATCH 2/2] Fix: Failed to read when the value of IUse is '-' --- src/probes/system_infos.probe/system_disk.c | 27 +++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/probes/system_infos.probe/system_disk.c b/src/probes/system_infos.probe/system_disk.c index 867bcfd9..36a50645 100644 --- a/src/probes/system_infos.probe/system_disk.c +++ b/src/probes/system_infos.probe/system_disk.c @@ -33,16 +33,39 @@ static df_stats *g_df_tbl = NULL; +#define MAX_LINE_LEN 1024 +void replace_dash_with_zero(char *line) { + char *token = strtok(line, " "); + char temp[MAX_LINE_LEN] = {0}; + + while (token != NULL) { + if (strcmp(token, "-") == 0) { + strcat(temp, "0 "); + } else { + strcat(temp, token); + strcat(temp, " "); + } + token = strtok(NULL, " "); + } + + temp[strlen(temp)-1] = '\0'; + strcpy(line, temp); +} + #define DF_INODE_FIELD_NUM 7 static int get_df_inode_fields(char *line, df_stats *stats) { int ret; char format[SSCANF_FORMAT_LEN]; + char line_copy[MAX_LINE_LEN]; - (void)snprintf(format, sizeof(format), "%%%lus %%%lus %%ld %%ld %%ld %%ld%%*s %%%lus", + strncpy(line_copy, line, MAX_LINE_LEN); + replace_dash_with_zero(line_copy); + + (void)snprintf(format, sizeof(format), "%%%lus %%%lus %%ld %%ld %%ld %%ld %%%lus", sizeof(stats->fsname) - 1, sizeof(stats->fstype) - 1, sizeof(stats->mount_on) - 1); - ret = sscanf(line, format, + ret = sscanf(line_copy, format, &stats->fsname, &stats->fstype, &stats->inode_sum, &stats->inode_used, &stats->inode_free, &stats->inode_used_per, &stats->mount_on); if (ret < DF_INODE_FIELD_NUM) { -- Gitee