Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __doc__ = """df
- Determine the filesystems to monitor
- """
- import re
- from Products.DataCollector.plugins.CollectorPlugin import CommandPlugin
- #from Products.DataCollector.plugins.CollectorPlugin import LinuxCommandPlugin
- class df(CommandPlugin):
- """
- Run df -k to model filesystem information. Should work on most *nix.
- """
- maptype = "FilesystemMap"
- command = '/bin/df -PTk'
- compname = "os"
- relname = "filesystems"
- modname = "Products.ZenModel.FileSystem"
- deviceProperties = CommandPlugin.deviceProperties + (
- 'zFileSystemMapIgnoreNames', 'zFileSystemMapIgnoreTypes')
- oses = ['Linux']
- def condition(self, device, log):
- return device.os.uname == '' or device.os.uname in self.oses
- def process(self, device, results, log):
- log.info('Collecting filesystems for device %s' % device.id)
- #log.info('Device: ', device)
- from pprint import pprint
- log.info(dir(device))
- skipfsnames = getattr(df.deviceProperties, 'zFileSystemMapIgnoreNames', None)
- skipfstypes = getattr(df.deviceProperties, 'zFileSystemMapIgnoreTypes', None)
- log.info(skipfsnames)
- rm = self.relMap()
- rlines = results.split("\n")
- bline = ""
- log.info('Starting fs modeling')
- log.info(device.zFileSystemMapIgnoreNames)
- for line in rlines:
- if line.startswith("Filesystem"): continue
- om = self.objectMap()
- spline = line.split()
- if len(spline) == 1:
- bline = spline[0]
- continue
- if bline:
- spline.insert(0,bline)
- bline = None
- if len(spline) != 7: continue
- (om.storageDevice, om.type, tblocks, u, a, p, om.mount) = spline
- if skipfsnames and re.search(skipfsnames,om.mount): continue
- if skipfstypes and om.type in skipfstypes:
- log.info("Skipping %s (%s) as it matches zFileSystemMapIgnoreTypes.",om.mount, om.type)
- continue
- if tblocks == "-": om.totalBlocks = 0
- else: om.totalBlocks = long(tblocks)
- om.blockSize = 1024
- om.id = self.prepId(om.mount)
- rm.append(om)
- return rm
Advertisement
Add Comment
Please, Sign In to add comment