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 # Hide a SyntaxWarning that is raised in twisted.web.microdom under Python>=2.5 15 # TODO in 3.1: Remove when twisted is upgraded 16 import warnings 17 warnings.filterwarnings('ignore', 'assertion is always true', SyntaxWarning) 18 19 from twisted.web import xmlrpc 20 21 import types 22 23 import DateTime 24 25 from Products.ZenHub.services.RRDImpl import RRDImpl 26 from Products.DataCollector.ApplyDataMap import ApplyDataMap 27 28 from Products.ZenUtils.ZenTales import talesEval 2931 # serializable types 32 PRIMITIVES = [types.IntType, types.StringType, types.BooleanType, 33 types.DictType, types.FloatType, types.LongType, 34 types.NoneType] 35126 12737 xmlrpc.XMLRPC.__init__(self) 38 self.dmd = dmd 39 self.zem = dmd.ZenEventManager 40 self.impl = RRDImpl(dmd)41 4244 'XMLRPC requests are processed asynchronously in a thread' 45 result = self.zem.sendEvent(data) 46 if result is None: 47 result = "none" 48 return result49 52 5557 return self.dmd.Devices.Server.Windows.getDeviceWinInfo(*args)5860 return self.dmd.Devices.Server.Windows.getWinServices(*args)6164 """Apply a datamap passed as a list of dicts through XML-RPC. 65 """ 66 dev = self.dmd.findDevice(devName) 67 adm = ApplyDataMap() 68 adm.applyDataMap(dev, datamap, relname=relname, 69 compname=compname, modname=modname)70 7173 '''Return the performance configurations for the monitor name and data 74 source provided. ''' 75 76 def toDict(device, ds, dps=[]): 77 '''marshall the fields from the datasource into a dictionary and 78 ignore everything that is not a primitive''' 79 80 vals = {} 81 vals['dps'] = [] 82 vals['dptypes'] = [] 83 for key, val in ds.__dict__.items(): 84 if type(val) in XmlRpcService.PRIMITIVES: 85 if (type(val) == types.StringType) and (val.find('$') >= 0): 86 val = talesEval('string:%s' % (val, ), device) 87 vals[key] = val 88 89 for dp in dps: 90 vals['dps'].append(dp.id) 91 vals['dptypes'].append(dp.rrdtype) 92 93 # add zproperties 94 for propertyId in device.propertyIds(): 95 value = device.getProperty(propertyId) 96 97 # _millis can't be serialized because it is long, so 98 # we skip it to avoid an XML-RPC serialization error 99 if isinstance(value, DateTime.DateTime): 100 continue 101 102 vals[propertyId] = value 103 104 vals['device'] = device.id 105 vals['manageIp'] = device.manageIp 106 107 return vals108 109 110 result = [] 111 112 # get the performance conf (if it exists) 113 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 114 if conf is None: 115 return result 116 117 # loop over devices that use the performance monitor 118 for device in conf.devices(): 119 device = device.primaryAq() 120 for template in device.getRRDTemplates(): 121 for ds in template.getRRDDataSources(): 122 if ds.sourcetype == dstype: 123 result.append(toDict(device, ds, ds.datapoints())) 124 125 return result129 self.impl.writeRRD(devId, compType, compId, dpName, value) 130 131 # return something for compliance with the XML-RPC specification 132 return ""133 134136 ''' returns the performance configuration for the monitor provided, or 137 {} if no collector with the name provided is located.''' 138 139 result = {} 140 fields = ['configCycleInterval', 'statusCycleInterval', 141 'processCycleInterval', 'perfsnmpCycleInterval', 142 'eventlogCycleInterval', 'renderurl', 'renderpass', 143 'renderuser', 'winCycleInterval'] 144 145 # get the performance conf (if it exists) 146 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 147 if conf is None: 148 return result 149 150 for field in fields: 151 result[field] = getattr(conf, field, None) 152 153 return result154
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jul 14 12:07:22 2010 | http://epydoc.sourceforge.net |