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 or (at your 8 # option) any later version as published by 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] 1921 """ 22 Mixin to provide hooks to performance management functions 23 which allow targetmap management and graphing 24 configuration generation is in PerformanceDevice and PerformanceServer 25 """ 2618529 """resolve targettype and view names to objects 30 and pass to performanceconf""" 31 from Products.ZenRRD.utils import getRRDView 32 if not drange: drange = self.defaultDateRange 33 if target: targettype = self.getPerformanceTypeForTarget(target) 34 if not target: target = self.id 35 if not targettype: targettype = self.getPerformanceTargetType() 36 targetpath = self.performanceTargetPath() + '/' + target.lower() 37 if targetpath[-4:] != '.rrd': targetpath+='.rrd' 38 objpaq = self.primaryAq() 39 targettype = self.getPerformanceTarget(targettype) 40 if not view: 41 view = targettype.getDefaultView(objpaq) 42 else: 43 view = getRRDView(objpaq, view) 44 performanceserver = objpaq.getPerformanceServer() 45 if performanceserver: 46 return performanceserver.performanceGraphUrl(objpaq, targetpath, 47 targettype, view, drange)48 4951 """resolve targetsmap and view and send to perfconf""" 52 from Products.ZenRRD.utils import getRRDView 53 if not drange: drange = self.defaultDateRange 54 objpaq = self.primaryAq() 55 view = getRRDView(objpaq, view) 56 performanceserver = objpaq.getPerformanceServer() 57 ntm = [] 58 for target, targettype in targetsmap: 59 targettype = self.getPerformanceTarget(targettype) 60 ntm.append((target, targettype)) 61 if performanceserver: 62 return performanceserver.performanceMGraphUrl(objpaq, ntm, view, drange)63 6466 """build the performance target map for an object 67 used when we want to draw graphs for the object""" 68 tm = {} 69 if not isinstance(targets, (list, tuple)): 70 targets = (targets,) 71 for targetdata in targets: 72 name = targetdata['target'] 73 if name == '--default--': continue 74 ttype = targetdata['target-type'] 75 tm[name] = ttype 76 if tm != self._performanceTargetMap: 77 self._performanceTargetMap = tm 78 self._p_changed = 1 79 if self._performanceTargetPath != targetpath: 80 self._performanceTargetPath = targetpath81 8284 """Return the performance target path set for this object. 85 """ 86 return self._performanceTargetPath87 88 91 92 96 97 101 102104 """check to see if there is performance data for this object""" 105 return self.getPerformanceTargetMap() or self.getPerformanceMGraphs()106 107109 """get the default graph list for this object""" 110 targets = self.getPerformanceTargets() 111 graphs = [] 112 if len(targets) == 1: 113 targettype = self.getPerformanceTargetType() 114 views = self.getPerformanceViewsForTarget(targettype) 115 for view in views: 116 graph = {} 117 graph['title'] = view 118 graph['url'] = self.performanceGraphUrl(view=view,drange=drange) 119 if graph['url']: 120 graphs.append(graph) 121 else: 122 for target in targets: 123 graph = {} 124 graph['title'] = target 125 graph['url'] = self.performanceGraphUrl(target=target,drange=drange) 126 if graph['url']: 127 graphs.append(graph) 128 for mgraph in self.getPerformanceMGraphs(): 129 for view in mgraph.getViews(): 130 graph = {} 131 graph['title'] = view 132 graph['url'] = self.performanceMGraphUrl(mgraph.getMTargets(), 133 view, drange=drange) 134 graphs.append(graph) 135 return graphs136 137139 """return list of target names for a performance object""" 140 return self._performanceTargetMap.keys()141 142144 """return the entire targetmap""" 145 if not hasattr(self, '_performanceTargetMap'): 146 self._performanceTargetMap = {} 147 return self._performanceTargetMap148 149151 """return the target type of this instnace 152 if there is more than one will return but which is arbitrary""" 153 if len(self._performanceTargetMap) > 0: 154 return self._performanceTargetMap.values()[0]155 156158 """lookup the type of a target for this object we try 159 both the full target passed as well as the last section 160 when split by a '/'""" 161 return self._performanceTargetMap.get(target, None)162 163165 """lookup a targettype from its name""" 166 from Products.ZenRRD.utils import getRRDTargetType 167 return getRRDTargetType(self.primaryAq(), targettypename)168 169171 """get the views for a particular targetname""" 172 target = self.getPerformanceTarget(targettypename) 173 return target.getViewNames()174 175177 """lookup performance""" 178 if hasattr(self, 'interfaces'): 179 intrel = self.interfaces 180 for att in intrel.objectIds(): 181 if att.lower() == id: 182 obj = intrel._getOb(att) 183 #return obj.viewPerformanceDetail(self.REQUEST) 184 return obj.viewPerformanceDetail()
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Tue Oct 11 12:51:53 2011 | http://epydoc.sourceforge.net |