diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-06-26 12:02:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-26 12:02:42 +0300 |
commit | c2d625779799ea5725a881cc318b39a43ad2274e (patch) | |
tree | 4a82a3cbf6491adda7f8999fc0ac2cfa6bba23fc /collectors | |
parent | a1019ccf1721933147ddf43ec9f7607c7f19b276 (diff) |
deduplicate mountinfo based on mount point (#13215)
Diffstat (limited to 'collectors')
-rw-r--r-- | collectors/proc.plugin/proc_self_mountinfo.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/collectors/proc.plugin/proc_self_mountinfo.c b/collectors/proc.plugin/proc_self_mountinfo.c index ca00f8a89f..90295f788d 100644 --- a/collectors/proc.plugin/proc_self_mountinfo.c +++ b/collectors/proc.plugin/proc_self_mountinfo.c @@ -199,11 +199,21 @@ struct mountinfo *mountinfo_read(int do_statvfs) { struct mountinfo *root = NULL, *last = NULL, *mi = NULL; + // create a dictionary to track uniqueness + DICTIONARY *dict = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED|DICTIONARY_FLAG_DONT_OVERWRITE_VALUE|DICTIONARY_FLAG_NAME_LINK_DONT_CLONE); + unsigned long l, lines = procfile_lines(ff); for(l = 0; l < lines ;l++) { if(unlikely(procfile_linewords(ff, l) < 5)) continue; + // make sure we don't add the same item twice + char *v = (char *)dictionary_set(dict, procfile_lineword(ff, l, 4), "N", 2); + if(v) { + if(*v == 'O') continue; + *v = 'O'; + } + mi = mallocz(sizeof(struct mountinfo)); unsigned long w = 0; @@ -411,6 +421,7 @@ struct mountinfo *mountinfo_read(int do_statvfs) { } */ + dictionary_destroy(dict); procfile_close(ff); return root; } |