Package Products :: Package ZenRRD :: Module CommandParser
[hide private]
[frames] | no frames]

Source Code for Module Products.ZenRRD.CommandParser

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, 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  import logging 
15  log = logging.getLogger('zen.ZenRRD.CommandParser') 
16   
17  from pprint import pformat 
18 19 -class ParsedResults(object):
20
21 - def __init__(self):
22 self.events = [] # list of event dictionaries 23 self.values = [] # list of (DataPointConfig, value)
24
25 - def __repr__(self):
26 args = (pformat(self.events), pformat(self.values)) 27 return "ParsedResults\n events: %s\n values: %s}" % args
28
29 -class CommandParser(object):
30
31 - def dataForParser(self, context, datapoint):
32 return {}
33
34 - def preprocessResults(self, cmd, log):
35 """ 36 Preprocess the results of running a command. 37 38 @type cmd: Products.ZenRRD.zencommand.Cmd 39 @param cmd: the results of running a command, with the 40 configuration from ZenHub 41 @return: None. 42 """ 43 44 # If the command was echoed back, strip it off 45 if cmd.result.output.lstrip().startswith(cmd.command): 46 cmd.result.output = cmd.result.output.lstrip()[len(cmd.command):]
47
48 - def processResults(self, cmd, results):
49 """ 50 Process the results of a running a command. 51 52 @type cmd: Products.ZenRRD.zencommand.Cmd 53 54 @param cmd: the results of running a command, with the 55 configuration from ZenHub 56 @param results: the values and events from the command output 57 @return: None. 58 """ 59 raise NotImplementedError
60 61 @property
63 """ 64 Property which can control whether events will be created 65 based on the exit code of the command if no events are 66 generated in the processResults function. 67 """ 68 return True
69