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 from Products.ZenHub.services.RRDImpl import RRDImpl 18 from Products.DataCollector.ApplyDataMap import ApplyDataMap 19 20 from Products.ZenUtils.ZenTales import talesEval 2123 # serializable types 24 PRIMITIVES = [types.IntType, types.StringType, types.BooleanType, 25 types.DictType, types.FloatType, types.LongType, 26 types.NoneType] 27108 10929 xmlrpc.XMLRPC.__init__(self) 30 self.dmd = dmd 31 self.zem = dmd.ZenEventManager 32 self.impl = RRDImpl(dmd)33 3436 'XMLRPC requests are processed asynchronously in a thread' 37 result = self.zem.sendEvent(data) 38 if result is None: 39 result = "none" 40 return result41 44 47 5052 return self.dmd.Devices.Server.Windows.getDeviceWinInfo(*args)5355 return self.dmd.Devices.Server.Windows.getWinServices(*args)5659 """Apply a datamap passed as a list of dicts through XML-RPC. 60 """ 61 dev = self.dmd.findDevice(devName) 62 adm = ApplyDataMap() 63 adm.applyDataMap(dev, datamap, relname=relname, 64 compname=compname, modname=modname)65 6668 '''Return the performance configurations for the monitor name and data 69 source provided. ''' 70 71 def toDict(device, ds, dps=[]): 72 '''marshall the fields from the datasource into a dictionary and 73 ignore everything that is not a primitive''' 74 75 vals = {} 76 vals['dps'] = [] 77 vals['dptypes'] = [] 78 for key, val in ds.__dict__.items(): 79 if type(val) in XmlRpcService.PRIMITIVES: 80 if (type(val) == types.StringType) and (val.find('$') >= 0): 81 val = talesEval('string:%s' % (val, ), device) 82 vals[key] = val 83 84 for dp in dps: 85 vals['dps'].append(dp.id) 86 vals['dptypes'].append(dp.rrdtype) 87 88 vals['device'] = device.id 89 return vals90 91 92 result = [] 93 94 # get the performance conf (if it exists) 95 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 96 if conf is None: 97 return result 98 99 # loop over devices that use the performance monitor 100 for device in conf.devices(): 101 device = device.primaryAq() 102 for template in device.getRRDTemplates(): 103 for ds in template.getRRDDataSources(): 104 if ds.sourcetype == dstype: 105 result.append(toDict(device, ds, ds.datapoints())) 106 107 return result111 self.impl.writeRRD(devId, compType, compId, dpName, value) 112 113 # return something for compliance with the XML-RPC specification 114 return ""115 116118 ''' returns the performance configuration for the monitor provided, or 119 {} if no collector with the name provided is located.''' 120 121 result = {} 122 fields = ['configCycleInterval', 'statusCycleInterval', 123 'processCycleInterval', 'perfsnmpCycleInterval', 124 'eventlogCycleInterval', 'renderurl', 'renderpass', 125 'renderuser', 'winCycleInterval', 'winmodelerCycleInterval'] 126 127 # get the performance conf (if it exists) 128 conf = getattr(self.dmd.Monitors.Performance, monitor, None) 129 if conf is None: 130 return result 131 132 for field in fields: 133 result[field] = getattr(conf, field, None) 134 135 return result136
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:24 2007 | http://epydoc.sourceforge.net |