Skip to content

Commit

Permalink
Win disks| Skip according to device_blaklist_re
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudy committed Jul 9, 2014
1 parent 66640ef commit a73faa3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions checks/system/win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
# Device WMI drive types
class DriveType(object):
UNKNOWN, NOROOT, REMOVEABLE, LOCAL, NETWORK, CD, RAM = (0, 1, 2, 3, 4, 5, 6)
IGNORED = ('_total',)
B2MB = float(1048576)
KB2MB = B2KB = float(1024)

def should_ignore_disk(name, blacklist_re):
# blacklist_re is a compiled regex, compilation done at config loading time
if name =='_total':
return True
elif blacklist_re and blacklist_re.match(name):
return True
else:
return False

class Processes(Check):
def __init__(self, logger):
Check.__init__(self, logger)
Expand Down Expand Up @@ -176,9 +184,10 @@ def check(self, agentConfig):
' No disk metrics will be returned.')
return

blacklist_re = agentConfig.get('device_blacklist_re', None)
for device in disk:
name = self.normalize_device_name(device.name)
if device.DriveType in (DriveType.CD, DriveType.UNKNOWN) or name in IGNORED:
if device.DriveType in (DriveType.CD, DriveType.UNKNOWN) or should_ignore_disk(name, blacklist_re):
continue
if device.FreeSpace is not None and device.Size is not None:
free = float(device.FreeSpace) / B2KB
Expand Down Expand Up @@ -208,10 +217,10 @@ def check(self, agentConfig):
self.logger.info('Missing Win32_PerfFormattedData_PerfDisk_LogicalDiskUnable WMI class.' \
' No I/O metrics will be returned.')
return

blacklist_re = agentConfig.get('device_blacklist_re', None)
for device in disk:
name = self.normalize_device_name(device.name)
if name in IGNORED:
if should_ignore_disk(name, blacklist_re):
continue
if device.DiskWriteBytesPerSec is not None:
self.save_sample('system.io.wkb_s', int(device.DiskWriteBytesPerSec) / B2KB,
Expand Down

0 comments on commit a73faa3

Please sign in to comment.