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-
2523 def _base_device_name (device ):
2624 return device .strip ('\\ ' ).lower ()
2725
2826
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_misc' ,
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-
5427else :
5528 IGNORE_CASE = 0
5629
57- KNOWN_SPECIAL_FILE_SYSTEMS = set ()
58-
5930 def _base_device_name (device ):
6031 return os .path .basename (device )
6132
@@ -77,7 +48,7 @@ def __init__(self, name, init_config, instances):
7748 self ._file_system_whitelist = instance .get ('file_system_whitelist' , [])
7849 self ._file_system_blacklist = instance .get ('file_system_blacklist' , [])
7950 # FIXME (8.X): Exclude special file systems by default
80- self ._exclude_special_file_systems = instance .get ('exclude_special_file_systems ' , False )
51+ self ._include_all_devices = is_affirmative ( instance .get ('include_all_devices ' , True ) )
8152 self ._device_whitelist = instance .get ('device_whitelist' , [])
8253 self ._device_blacklist = instance .get ('device_blacklist' , [])
8354 self ._mount_point_whitelist = instance .get ('mount_point_whitelist' , [])
@@ -102,7 +73,7 @@ def check(self, instance):
10273 self .devices_label = self ._get_devices_label ()
10374
10475 self ._valid_disks = {}
105- for part in psutil .disk_partitions (all = True ):
76+ for part in psutil .disk_partitions (all = self . _include_all_devices ):
10677 # we check all exclude conditions
10778 if self .exclude_disk (part ):
10879 continue
@@ -119,21 +90,12 @@ def check(self, instance):
11990 )
12091 continue
12192 except Exception as 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- )
93+ self .log .warning (
94+ u'Unable to get disk metrics for %s: %s. '
95+ u'You can exclude this mountpoint in the settings if it is invalid.' ,
96+ part .mountpoint ,
97+ e ,
98+ )
13799 continue
138100
139101 # Exclude disks with size less than min_disk_size
@@ -234,9 +196,7 @@ def _file_system_blacklisted(self, file_system):
234196 if self ._file_system_blacklist is None :
235197 return False
236198
237- return (self ._exclude_special_file_systems and file_system in KNOWN_SPECIAL_FILE_SYSTEMS ) or bool (
238- self ._file_system_blacklist .match (file_system )
239- )
199+ return not not self ._file_system_blacklist .match (file_system )
240200
241201 def _device_whitelisted (self , device ):
242202 if not device or self ._device_whitelist is None :
0 commit comments