2020 # See: https://github.com/DataDog/integrations-core/pull/1109#discussion_r167133580
2121 IGNORE_CASE = re .I
2222
23+ KNOWN_SPECIAL_FILE_SYSTEMS = set ()
24+
2325 def _base_device_name (device ):
2426 return device .strip ('\\ ' ).lower ()
2527
2628
29+ elif platform .system () == "Linux" :
30+ IGNORE_CASE = 0
31+
32+ # Remember to update the configuration specification
33+ # if modifying the list of special file systems.
34+ KNOWN_SPECIAL_FILE_SYSTEMS = set (
35+ [
36+ 'binfmt_msc' ,
37+ 'configfs' ,
38+ 'debugfs' ,
39+ 'devtmpfs' ,
40+ 'overlay' ,
41+ 'proc' ,
42+ 'rootfs' ,
43+ 'securityfs' ,
44+ 'sysfs' ,
45+ 'tmpfs' ,
46+ 'tracefs' ,
47+ ]
48+ )
49+
50+ def _base_device_name (device ):
51+ return os .path .basename (device )
52+
53+
2754else :
2855 IGNORE_CASE = 0
2956
57+ KNOWN_SPECIAL_FILE_SYSTEMS = set ()
58+
3059 def _base_device_name (device ):
3160 return os .path .basename (device )
3261
@@ -47,6 +76,8 @@ def __init__(self, name, init_config, instances):
4776 self ._all_partitions = is_affirmative (instance .get ('all_partitions' , False ))
4877 self ._file_system_whitelist = instance .get ('file_system_whitelist' , [])
4978 self ._file_system_blacklist = instance .get ('file_system_blacklist' , [])
79+ # FIXME (8.X): Exclude special file systems by default
80+ self ._exclude_special_file_systems = instance .get ('exclude_special_file_systems' , False )
5081 self ._device_whitelist = instance .get ('device_whitelist' , [])
5182 self ._device_blacklist = instance .get ('device_blacklist' , [])
5283 self ._mount_point_whitelist = instance .get ('mount_point_whitelist' , [])
@@ -88,7 +119,21 @@ def check(self, instance):
88119 )
89120 continue
90121 except Exception as e :
91- self .log .warning ('Unable to get disk metrics for %s: %s' , part .mountpoint , e )
122+ if not self ._exclude_special_file_systems and part .fstype in KNOWN_SPECIAL_FILE_SYSTEMS :
123+ self .log .warning (
124+ u'Unable to get disk metrics for %s with special file system %s: %s. '
125+ u'Enable `exclude_special_file_systems` to ignore common special file systems.' ,
126+ part .mountpoint ,
127+ part .fstype ,
128+ e ,
129+ )
130+ else :
131+ self .log .warning (
132+ u'Unable to get disk metrics for %s: %s. '
133+ u'You can exclude this mountpoint in the settings if it is invalid.' ,
134+ part .mountpoint ,
135+ e ,
136+ )
92137 continue
93138
94139 # Exclude disks with size less than min_disk_size
@@ -147,7 +192,6 @@ def _exclude_disk(self, device, file_system, mount_point):
147192 """
148193 Return True for disks we don't want or that match regex in the config file
149194 """
150- self .log .debug ('_exclude_disk: %s, %s, %s' , device , file_system , mount_point )
151195
152196 if not device or device == 'none' :
153197 device = None
@@ -190,6 +234,14 @@ def _file_system_blacklisted(self, file_system):
190234 if self ._file_system_blacklist is None :
191235 return False
192236
237+ # Check if it is a known special file system
238+ if (
239+ self ._exclude_special_file_systems
240+ and file_system in KNOWN_SPECIAL_FILE_SYSTEMS
241+ and not self ._file_system_whitelisted (file_system )
242+ ):
243+ return True
244+
193245 return not not self ._file_system_blacklist .match (file_system )
194246
195247 def _device_whitelisted (self , device ):
@@ -245,7 +297,12 @@ def _collect_inodes_metrics(self, mountpoint):
245297 )
246298 return metrics
247299 except Exception as e :
248- self .log .warning ('Unable to get disk metrics for %s: %s' , mountpoint , e )
300+ self .log .warning (
301+ u'Unable to get disk metrics for %s: %s. '
302+ u'You can exclude this mountpoint in the settings if it is invalid.' ,
303+ mountpoint ,
304+ e ,
305+ )
249306 return metrics
250307
251308 if inodes .f_files != 0 :
0 commit comments