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 __doc__="""CricketView 15 16 $Id: CricketView.py,v 1.13 2004/04/06 21:05:03 edahl Exp $""" 17 18 __version__ = "$Revision: 1.13 $"[11:-2] 19 20 import types 21 22 from Acquisition import aq_base 23 2426 """ 27 Mixin to provide hooks to performance management functions 28 which allow targetmap management and graphing 29 configuration generation is in PerformanceDevice and PerformanceServer 30 """ 3119034 """resolve targettype and view names to objects 35 and pass to performanceconf""" 36 from Products.ZenRRD.utils import getRRDView 37 if not drange: drange = self.defaultDateRange 38 if target: targettype = self.getPerformanceTypeForTarget(target) 39 if not target: target = self.id 40 if not targettype: targettype = self.getPerformanceTargetType() 41 targetpath = self.performanceTargetPath() + '/' + target.lower() 42 if targetpath[-4:] != '.rrd': targetpath+='.rrd' 43 objpaq = self.primaryAq() 44 targettype = self.getPerformanceTarget(targettype) 45 if not view: 46 view = targettype.getDefaultView(objpaq) 47 else: 48 view = getRRDView(objpaq, view) 49 performanceserver = objpaq.getPerformanceServer() 50 if performanceserver: 51 return performanceserver.performanceGraphUrl(objpaq, targetpath, 52 targettype, view, drange)53 5456 """resolve targetsmap and view and send to perfconf""" 57 from Products.ZenRRD.utils import getRRDView 58 if not drange: drange = self.defaultDateRange 59 objpaq = self.primaryAq() 60 view = getRRDView(objpaq, view) 61 performanceserver = objpaq.getPerformanceServer() 62 ntm = [] 63 for target, targettype in targetsmap: 64 targettype = self.getPerformanceTarget(targettype) 65 ntm.append((target, targettype)) 66 if performanceserver: 67 return performanceserver.performanceMGraphUrl(objpaq, ntm, view, drange)68 6971 """build the performance target map for an object 72 used when we want to draw graphs for the object""" 73 tm = {} 74 if type(targets) != types.ListType and type(targets) != types.TupleType: 75 targets = (targets,) 76 for targetdata in targets: 77 name = targetdata['target'] 78 if name == '--default--': continue 79 ttype = targetdata['target-type'] 80 tm[name] = ttype 81 if tm != self._performanceTargetMap: 82 self._performanceTargetMap = tm 83 self._p_changed = 1 84 if self._performanceTargetPath != targetpath: 85 self._performanceTargetPath = targetpath86 8789 """Return the performance target path set for this object. 90 """ 91 return self._performanceTargetPath92 93 96 97 101 102 106 107109 """check to see if there is performance data for this object""" 110 return self.getPerformanceTargetMap() or self.getPerformanceMGraphs()111 112114 """get the default graph list for this object""" 115 targets = self.getPerformanceTargets() 116 graphs = [] 117 if len(targets) == 1: 118 targettype = self.getPerformanceTargetType() 119 views = self.getPerformanceViewsForTarget(targettype) 120 for view in views: 121 graph = {} 122 graph['title'] = view 123 graph['url'] = self.performanceGraphUrl(view=view,drange=drange) 124 if graph['url']: 125 graphs.append(graph) 126 else: 127 for target in targets: 128 graph = {} 129 graph['title'] = target 130 graph['url'] = self.performanceGraphUrl(target=target,drange=drange) 131 if graph['url']: 132 graphs.append(graph) 133 for mgraph in self.getPerformanceMGraphs(): 134 for view in mgraph.getViews(): 135 graph = {} 136 graph['title'] = view 137 graph['url'] = self.performanceMGraphUrl(mgraph.getMTargets(), 138 view, drange=drange) 139 graphs.append(graph) 140 return graphs141 142144 """return list of target names for a performance object""" 145 return self._performanceTargetMap.keys()146 147149 """return the entire targetmap""" 150 if not hasattr(self, '_performanceTargetMap'): 151 self._performanceTargetMap = {} 152 return self._performanceTargetMap153 154156 """return the target type of this instnace 157 if there is more than one will return but which is arbitrary""" 158 if len(self._performanceTargetMap) > 0: 159 return self._performanceTargetMap.values()[0]160 161163 """lookup the type of a target for this object we try 164 both the full target passed as well as the last section 165 when split by a '/'""" 166 return self._performanceTargetMap.get(target, None)167 168170 """lookup a targettype from its name""" 171 from Products.ZenRRD.utils import getRRDTargetType 172 return getRRDTargetType(self.primaryAq(), targettypename)173 174176 """get the views for a particular targetname""" 177 target = self.getPerformanceTarget(targettypename) 178 return target.getViewNames()179 180182 """lookup performance""" 183 if hasattr(self, 'interfaces'): 184 intrel = self.interfaces 185 for att in intrel.objectIds(): 186 if att.lower() == id: 187 obj = intrel._getOb(att) 188 #return obj.viewPerformanceDetail(self.REQUEST) 189 return obj.viewPerformanceDetail()
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:44 2007 | http://epydoc.sourceforge.net |