Trees | Indices | Help |
|
---|
|
1 ############################################################################## 2 # 3 # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 4 # 5 # This content is made available according to terms specified in 6 # License.zenoss under the directory where your Zenoss product is installed. 7 # 8 ############################################################################## 9 10 11 # Hide a SyntaxWarning that is raised in twisted.web.microdom under Python>=2.5 12 # TODO in 3.1: Remove when twisted is upgraded 13 import warnings 14 warnings.filterwarnings('ignore', 'assertion is always true', SyntaxWarning) 15 16 from twisted.web import xmlrpc 17 18 import types 19 20 import DateTime 21 22 from Products.ZenHub.services.RRDImpl import RRDImpl 23 from Products.DataCollector.ApplyDataMap import ApplyDataMap 24 from Products.Zuul import getFacade 25 from Products.ZenUtils.ZenTales import talesEval 2628 # serializable types 29 PRIMITIVES = [types.IntType, types.StringType, types.BooleanType, 30 types.DictType, types.FloatType, types.LongType, 31 types.NoneType] 32124 12534 xmlrpc.XMLRPC.__init__(self) 35 self.dmd = dmd 36 self.zem = dmd.ZenEventManager 37 self.impl = RRDImpl(dmd)38 3941 'XMLRPC requests are processed asynchronously in a thread' 42 result = self.zem.sendEvent(data) 43 if result is None: 44 result = "none" 45 return result46 49 53 56 5962 """Apply a datamap passed as a list of dicts through XML-RPC. 63 """ 64 dev = self.dmd.findDevice(devName) 65 adm = ApplyDataMap() 66 adm.applyDataMap(dev, datamap, relname=relname, 67 compname=compname, modname=modname)68 6971 '''Return the performance configurations for the monitor name and data 72 source provided. ''' 73 74 def toDict(device, ds, dps=[]): 75 '''marshall the fields from the datasource into a dictionary and 76 ignore everything that is not a primitive''' 77 78 vals = {} 79 vals['dps'] = [] 80 vals['dptypes'] = [] 81 for key, val in ds.__dict__.items(): 82 if isinstance(val, XmlRpcService.PRIMITIVES): 83 if isinstance(val, basestring) and '$' in val: 84 val = talesEval('string:%s' % (val, ), device) 85 vals[key] = val 86 87 for dp in dps: 88 vals['dps'].append(dp.id) 89 vals['dptypes'].append(dp.rrdtype) 90 91 # add zproperties 92 for propertyId in device.propertyIds(): 93 value = device.getProperty(propertyId) 94 95 # _millis can't be serialized because it is long, so 96 # we skip it to avoid an XML-RPC serialization error 97 if isinstance(value, DateTime.DateTime): 98 continue 99 100 vals[propertyId] = value 101 102 vals['device'] = device.id 103 vals['manageIp'] = device.manageIp 104 105 return vals106 107 108 result = [] 109 110 # get the performance conf (if it exists) 111 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 112 if conf is None: 113 return result 114 115 # loop over devices that use the performance monitor 116 for device in conf.devices(): 117 device = device.primaryAq() 118 for template in device.getRRDTemplates(): 119 for ds in template.getRRDDataSources(): 120 if ds.sourcetype == dstype: 121 result.append(toDict(device, ds, ds.datapoints())) 122 123 return result127 self.impl.writeRRD(devId, compType, compId, dpName, value) 128 129 # return something for compliance with the XML-RPC specification 130 return ""131 132134 ''' returns the performance configuration for the monitor provided, or 135 {} if no collector with the name provided is located.''' 136 137 result = {} 138 fields = ['configCycleInterval', 'statusCycleInterval', 139 'processCycleInterval', 'perfsnmpCycleInterval', 140 'eventlogCycleInterval', 'renderurl', 'renderpass', 141 'renderuser', 'winCycleInterval'] 142 143 # get the performance conf (if it exists) 144 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 145 if conf is None: 146 return result 147 148 for field in fields: 149 result[field] = getattr(conf, field, None) 150 151 return result152
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Mon Jul 30 17:11:27 2012 | http://epydoc.sourceforge.net |