diff --git a/src/ingress/ingress.c b/src/ingress/ingress.c index 5f0fa93a938d0788579055ceb17e00bb35f6bd95..18c8af7bd677fb09cf6554f29ffa2c1b959459ab 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) { diff --git a/src/probes/system_infos.probe/system_disk.c b/src/probes/system_infos.probe/system_disk.c index 867bcfd9cc887364ae99b1c85b5aa5ecf5a23551..36a5064596c8db4887792c495249eba0c865147c 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) {