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 from twisted.web import xmlrpc 14 15 import types 16 17 import DateTime 18 19 from Products.ZenHub.services.RRDImpl import RRDImpl 20 from Products.DataCollector.ApplyDataMap import ApplyDataMap 21 22 from Products.ZenUtils.ZenTales import talesEval 2325 # serializable types 26 PRIMITIVES = [types.IntType, types.StringType, types.BooleanType, 27 types.DictType, types.FloatType, types.LongType, 28 types.NoneType] 29123 12431 xmlrpc.XMLRPC.__init__(self) 32 self.dmd = dmd 33 self.zem = dmd.ZenEventManager 34 self.impl = RRDImpl(dmd)35 3638 'XMLRPC requests are processed asynchronously in a thread' 39 result = self.zem.sendEvent(data) 40 if result is None: 41 result = "none" 42 return result43 46 49 5254 return self.dmd.Devices.Server.Windows.getDeviceWinInfo(*args)5557 return self.dmd.Devices.Server.Windows.getWinServices(*args)5861 """Apply a datamap passed as a list of dicts through XML-RPC. 62 """ 63 dev = self.dmd.findDevice(devName) 64 adm = ApplyDataMap() 65 adm.applyDataMap(dev, datamap, relname=relname, 66 compname=compname, modname=modname)67 6870 '''Return the performance configurations for the monitor name and data 71 source provided. ''' 72 73 def toDict(device, ds, dps=[]): 74 '''marshall the fields from the datasource into a dictionary and 75 ignore everything that is not a primitive''' 76 77 vals = {} 78 vals['dps'] = [] 79 vals['dptypes'] = [] 80 for key, val in ds.__dict__.items(): 81 if type(val) in XmlRpcService.PRIMITIVES: 82 if (type(val) == types.StringType) and (val.find('$') >= 0): 83 val = talesEval('string:%s' % (val, ), device) 84 vals[key] = val 85 86 for dp in dps: 87 vals['dps'].append(dp.id) 88 vals['dptypes'].append(dp.rrdtype) 89 90 # add zproperties 91 for propertyId in device.propertyIds(): 92 value = device.getProperty(propertyId) 93 94 # _millis can't be serialized because it is long, so 95 # we skip it to avoid an XML-RPC serialization error 96 if isinstance(value, DateTime.DateTime): 97 continue 98 99 vals[propertyId] = value 100 101 vals['device'] = device.id 102 vals['manageIp'] = device.manageIp 103 104 return vals105 106 107 result = [] 108 109 # get the performance conf (if it exists) 110 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 111 if conf is None: 112 return result 113 114 # loop over devices that use the performance monitor 115 for device in conf.devices(): 116 device = device.primaryAq() 117 for template in device.getRRDTemplates(): 118 for ds in template.getRRDDataSources(): 119 if ds.sourcetype == dstype: 120 result.append(toDict(device, ds, ds.datapoints())) 121 122 return result126 self.impl.writeRRD(devId, compType, compId, dpName, value) 127 128 # return something for compliance with the XML-RPC specification 129 return ""130 131133 ''' returns the performance configuration for the monitor provided, or 134 {} if no collector with the name provided is located.''' 135 136 result = {} 137 fields = ['configCycleInterval', 'statusCycleInterval', 138 'processCycleInterval', 'perfsnmpCycleInterval', 139 'eventlogCycleInterval', 'renderurl', 'renderpass', 140 'renderuser', 'winCycleInterval', 'winmodelerCycleInterval'] 141 142 # get the performance conf (if it exists) 143 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 144 if conf is None: 145 return result 146 147 for field in fields: 148 result[field] = getattr(conf, field, None) 149 150 return result151
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:37 2009 | http://epydoc.sourceforge.net |