]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Hugepages plugin skips reading write-only file collectd-5.13
authorYadnesh Kulkarni <ykulkarn@redhat.com>
Wed, 22 Feb 2023 12:27:55 +0000 (17:57 +0530)
committerMatthias Runge <mrunge@matthias-runge.de>
Fri, 24 Mar 2023 10:27:41 +0000 (11:27 +0100)
Since 'demote' is a write-only file do not attempt to
to read it. This also prevents the plugin from generating
incessant logs about the failure to open it.

Fixes: #3993
https://docs.kernel.org/admin-guide/mm/hugetlbpage.html

src/hugepages.c

index e066300beb799460f0b12b0f991740ef62983452..bd381a926ae792e98706b5b239e8a1804f85b81c 100644 (file)
@@ -125,6 +125,14 @@ static int read_hugepage_entry(const char *path, const char *entry,
   struct entry_info *info = e_info;
   double value;
 
+  /**
+   * Since demote is a write-only file, do not attempt to open it.
+   * https://docs.kernel.org/admin-guide/mm/hugetlbpage.html
+   */
+  if (strcmp(entry, "demote") == 0) {
+    return -1;
+  }
+
   snprintf(path2, sizeof(path2), "%s/%s", path, entry);
 
   FILE *fh = fopen(path2, "rt");