Package Products :: Package DataCollector :: Module ProcessCommandPlugin |
[hide private]
[frames] | no frames]

# Source Code for Module Products.DataCollector.ProcessCommandPlugin

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2009, Zenoss Inc.
     5  #
     6  # This program is free software; you can redistribute it and/or modify it
     7  # under the terms of the GNU General Public License version 2 or (at your
     8  # option) any later version as published by the Free Software Foundation.
     9  #
    10  # For complete information please visit: http://www.zenoss.com/oss/
    11  #
    12  ###########################################################################
    13
    14
    15  from pprint import pformat
    16
    17  from Products.DataCollector.plugins.CollectorPlugin import CommandPlugin
    18
    19
    20 -class ProcessCommandPlugin(CommandPlugin):
    21      """
    22      Base class for Linux and AIX command plugins for parsing ps command output
    23      and modeling processes.
    24      """
    25
    26      compname = "os"
    27      relname = "processes"
    28      modname = "Products.ZenModel.OSProcess"
    29      classname = "createFromObjectMap"
    30
    31 -    def _filterLines(self, lines):
    32          """
    33          Filter out any unwanted lines.  The base implementation returns all
    34          the lines.
    35          """
    36          return lines
    37
    38 -    def process(self, device, results, log):
    39          log.info('Processing %s for device %s', self.name(), device.id)
    40          if not results:
    41              log.error("Unable to get data for %s -- skipping model",
    42                        device.id)
    43              return None
    44
    45          relMap = self.relMap()
    46          for line in self._filterLines(results.splitlines()):
    47              words = line.split()
    48
    49              relMap.append(self.objectMap({
    50                  "procName": words[0],
    51                  "parameters": " ".join(words[1:])}))
    52
    53          log.debug("First three modeled processes:\n%s" %
    54                  pformat(relMap.maps[:3]))
    55
    56          return relMap
    57