| Trees | Indices | Help |
|
|---|
|
|
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 as published by
8 # 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
20
22 self.events = [] # list of event dictionaries
23 self.values = [] # list of (DataPointConfig, value)
24
28
30
33
35 """
36 Process the results of a running a command.
37
38 @type cmd: Products.ZenRRD.zencommand.Cmd
39
40 @param cmd: the results of running a command, with the
41 configuration from ZenHub
42 @param results: the values and events from the command output
43 @return: None.
44 """
45 raise NotImplementedError
46
47
48 ParserCache = {}
49
51 """
52 Import and create the parser for this command
53 """
54 try:
55 return ParserCache[name]
56 except KeyError:
57 from Products.ZenUtils.Utils import importClass
58 klass = importClass('Products.ZenRRD.parsers.' + name)
59 instance = klass()
60 ParserCache[name] = instance
61 return instance
62
64 """
65 Import and create the parser for this command
66 """
67 try:
68 return ParserCache[name]
69 except KeyError:
70 from Products.ZenUtils.Utils import importClass
71 klass = importClass(name)
72 instance = klass()
73 ParserCache[name] = instance
74 return instance
75
77 """
78 Import and create the parser for this command
79 """
80 err = ImportError("%s not found" % name)
81 try:
82 return _getParser(name)
83 except ImportError, err:
84 msg = "%s is not a core parser. Attempting to import it from " \
85 "installed zenpacks."
86 log.debug(msg, name)
87 return _getPackParser(name)
88
89
96
97 import os
98 from Products.ZenUtils.Utils import zenPath
99 result = []
100 for d, ds, fs in os.walk(zenPath('Products','ZenRRD', 'parsers')):
101 for f in fs:
102 plugin = looksLikeAPlugin(f)
103 if plugin:
104 plugin = os.path.join(d, plugin)
105 plugin = plugin.split(os.path.sep)
106 plugin = plugin[plugin.index('parsers') + 1:]
107 plugin = '.'.join(plugin)
108 result.append(plugin)
109
110 for pack in dmd.ZenPackManager.packs():
111 root = pack.path('parsers')
112 for d, ds, fs in os.walk(root):
113 for f in fs:
114 plugin = looksLikeAPlugin(f)
115 if plugin:
116 plugin = os.path.join(d, plugin)
117 plugin = plugin.split(os.path.sep)
118 plugin = plugin[plugin.index('ZenPacks'):]
119 plugin = '.'.join(plugin)
120 result.append(plugin)
121 return sorted(result)
122
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Thu May 7 11:46:48 2009 | http://epydoc.sourceforge.net |