]> arthur.barton.de Git - netdata.git/blobdiff - src/plugin_proc_diskspace.c
Merge pull request #1870 from ktsaou/master
[netdata.git] / src / plugin_proc_diskspace.c
index db7aa08f99a9b2a8055ba23fa0a76d1aa7d7914e..6657ffe783e1d1ade18139b375b3fbc6ce5b2eb8 100644 (file)
@@ -27,6 +27,7 @@ static inline void mountinfo_reload(int force) {
 struct mount_point_metadata {
     int do_space;
     int do_inodes;
+    int shown_error;
 
     size_t collected; // the number of times this has been collected
 
@@ -53,9 +54,8 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
     if(unlikely(!mount_points)) {
         SIMPLE_PREFIX_MODE mode = SIMPLE_PATTERN_EXACT;
 
-        if(config_exists("plugin:proc:/proc/diskstats", "exclude space metrics on paths") && !config_exists(CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths")) {
-            // the config exists in the old section
-            config_move("plugin:proc:/proc/diskstats", "exclude space metrics on paths", CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths");
+        if(config_move("plugin:proc:/proc/diskstats", "exclude space metrics on paths", CONFIG_SECTION_DISKSPACE, "exclude space metrics on paths") != -1) {
+            // old configuration, enable backwards compatibility
             mode = SIMPLE_PATTERN_PREFIX;
         }
 
@@ -96,6 +96,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
         struct mount_point_metadata mp = {
                 .do_space = do_space,
                 .do_inodes = do_inodes,
+                .shown_error = 0,
 
                 .collected = 0,
 
@@ -112,12 +113,8 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
 
         m = dictionary_set(mount_points, mi->mount_point, &mp, sizeof(struct mount_point_metadata));
     }
-    else {
-        do_space = m->do_space;
-        do_inodes = m->do_inodes;
-    }
 
-    if(unlikely(do_space == CONFIG_BOOLEAN_NO && do_inodes == CONFIG_BOOLEAN_NO))
+    if(unlikely(m->do_space == CONFIG_BOOLEAN_NO && m->do_inodes == CONFIG_BOOLEAN_NO))
         return;
 
     if(unlikely(mi->flags & MOUNTINFO_READONLY && !m->collected))
@@ -125,9 +122,18 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
 
     struct statvfs buff_statvfs;
     if (statvfs(mi->mount_point, &buff_statvfs) < 0) {
-        error("Failed statvfs() for '%s' (disk '%s')", mi->mount_point, disk);
+        if(!m->shown_error) {
+            error("Failed statvfs() for '%s' (disk '%s', filesystem '%s', root '%s')"
+                  , mi->mount_point
+                  , disk
+                  , mi->filesystem?mi->filesystem:""
+                  , mi->root?mi->root:""
+            );
+            m->shown_error = 1;
+        }
         return;
     }
+    m->shown_error = 0;
 
     // logic found at get_fs_usage() in coreutils
     unsigned long bsize = (buff_statvfs.f_frsize) ? buff_statvfs.f_frsize : buff_statvfs.f_bsize;
@@ -164,7 +170,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
 
     int rendered = 0;
 
-    if(do_space == CONFIG_BOOLEAN_YES || (do_space == CONFIG_BOOLEAN_AUTO && (bavail || breserved_root || bused))) {
+    if(m->do_space == CONFIG_BOOLEAN_YES || (m->do_space == CONFIG_BOOLEAN_AUTO && (bavail || breserved_root || bused))) {
         if(unlikely(!m->st_space)) {
             m->do_space = CONFIG_BOOLEAN_YES;
             m->st_space = rrdset_find_bytype_localhost("disk_space", disk);
@@ -202,7 +208,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
 
     // --------------------------------------------------------------------------
 
-    if(do_inodes == CONFIG_BOOLEAN_YES || (do_inodes == CONFIG_BOOLEAN_AUTO && (favail || freserved_root || fused))) {
+    if(m->do_inodes == CONFIG_BOOLEAN_YES || (m->do_inodes == CONFIG_BOOLEAN_AUTO && (favail || freserved_root || fused))) {
         if(unlikely(!m->st_inodes)) {
             m->do_inodes = CONFIG_BOOLEAN_YES;
             m->st_inodes = rrdset_find_bytype_localhost("disk_inodes", disk);