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 as published by 
 8  # 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 40 log.info('Collecting process information for device %s' % device.id) 41 relMap = self.relMap() 42 43 for line in self._filterLines(results.splitlines()): 44 45 words = line.split() 46 47 relMap.append(self.objectMap({ 48 "procName": words[0], 49 "parameters": " ".join(words[1:])})) 50 51 log.debug("First three modeled processes:\n%s" % 52 pformat(relMap.maps[:3])) 53 54 return relMap
55