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 2123 """ 24 Mixin to provide hooks to performance management functions 25 which allow targetmap management and graphing 26 configuration generation is in PerformanceDevice and PerformanceServer 27 """ 2818731 """resolve targettype and view names to objects 32 and pass to performanceconf""" 33 from Products.ZenRRD.utils import getRRDView 34 if not drange: drange = self.defaultDateRange 35 if target: targettype = self.getPerformanceTypeForTarget(target) 36 if not target: target = self.id 37 if not targettype: targettype = self.getPerformanceTargetType() 38 targetpath = self.performanceTargetPath() + '/' + target.lower() 39 if targetpath[-4:] != '.rrd': targetpath+='.rrd' 40 objpaq = self.primaryAq() 41 targettype = self.getPerformanceTarget(targettype) 42 if not view: 43 view = targettype.getDefaultView(objpaq) 44 else: 45 view = getRRDView(objpaq, view) 46 performanceserver = objpaq.getPerformanceServer() 47 if performanceserver: 48 return performanceserver.performanceGraphUrl(objpaq, targetpath, 49 targettype, view, drange)50 5153 """resolve targetsmap and view and send to perfconf""" 54 from Products.ZenRRD.utils import getRRDView 55 if not drange: drange = self.defaultDateRange 56 objpaq = self.primaryAq() 57 view = getRRDView(objpaq, view) 58 performanceserver = objpaq.getPerformanceServer() 59 ntm = [] 60 for target, targettype in targetsmap: 61 targettype = self.getPerformanceTarget(targettype) 62 ntm.append((target, targettype)) 63 if performanceserver: 64 return performanceserver.performanceMGraphUrl(objpaq, ntm, view, drange)65 6668 """build the performance target map for an object 69 used when we want to draw graphs for the object""" 70 tm = {} 71 if type(targets) != types.ListType and type(targets) != types.TupleType: 72 targets = (targets,) 73 for targetdata in targets: 74 name = targetdata['target'] 75 if name == '--default--': continue 76 ttype = targetdata['target-type'] 77 tm[name] = ttype 78 if tm != self._performanceTargetMap: 79 self._performanceTargetMap = tm 80 self._p_changed = 1 81 if self._performanceTargetPath != targetpath: 82 self._performanceTargetPath = targetpath83 8486 """Return the performance target path set for this object. 87 """ 88 return self._performanceTargetPath89 90 93 94 98 99 103 104106 """check to see if there is performance data for this object""" 107 return self.getPerformanceTargetMap() or self.getPerformanceMGraphs()108 109111 """get the default graph list for this object""" 112 targets = self.getPerformanceTargets() 113 graphs = [] 114 if len(targets) == 1: 115 targettype = self.getPerformanceTargetType() 116 views = self.getPerformanceViewsForTarget(targettype) 117 for view in views: 118 graph = {} 119 graph['title'] = view 120 graph['url'] = self.performanceGraphUrl(view=view,drange=drange) 121 if graph['url']: 122 graphs.append(graph) 123 else: 124 for target in targets: 125 graph = {} 126 graph['title'] = target 127 graph['url'] = self.performanceGraphUrl(target=target,drange=drange) 128 if graph['url']: 129 graphs.append(graph) 130 for mgraph in self.getPerformanceMGraphs(): 131 for view in mgraph.getViews(): 132 graph = {} 133 graph['title'] = view 134 graph['url'] = self.performanceMGraphUrl(mgraph.getMTargets(), 135 view, drange=drange) 136 graphs.append(graph) 137 return graphs138 139141 """return list of target names for a performance object""" 142 return self._performanceTargetMap.keys()143 144146 """return the entire targetmap""" 147 if not hasattr(self, '_performanceTargetMap'): 148 self._performanceTargetMap = {} 149 return self._performanceTargetMap150 151153 """return the target type of this instnace 154 if there is more than one will return but which is arbitrary""" 155 if len(self._performanceTargetMap) > 0: 156 return self._performanceTargetMap.values()[0]157 158160 """lookup the type of a target for this object we try 161 both the full target passed as well as the last section 162 when split by a '/'""" 163 return self._performanceTargetMap.get(target, None)164 165167 """lookup a targettype from its name""" 168 from Products.ZenRRD.utils import getRRDTargetType 169 return getRRDTargetType(self.primaryAq(), targettypename)170 171173 """get the views for a particular targetname""" 174 target = self.getPerformanceTarget(targettypename) 175 return target.getViewNames()176 177179 """lookup performance""" 180 if hasattr(self, 'interfaces'): 181 intrel = self.interfaces 182 for att in intrel.objectIds(): 183 if att.lower() == id: 184 obj = intrel._getOb(att) 185 #return obj.viewPerformanceDetail(self.REQUEST) 186 return obj.viewPerformanceDetail()
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:30 2009 | http://epydoc.sourceforge.net |