Package Products :: Package ZenModel :: Module DefGraphPoint
[hide private]
[frames] | no frames]

Source Code for Module Products.ZenModel.DefGraphPoint

 1  ############################################################################## 
 2  #  
 3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 
 4  #  
 5  # This content is made available according to terms specified in 
 6  # License.zenoss under the directory where your Zenoss product is installed. 
 7  #  
 8  ############################################################################## 
 9   
10   
11  __doc__="""DefGraphPoint 
12   
13  Handles GraphPoints that define an rrd DEF 
14  """ 
15   
16  from GraphPoint import GraphPoint 
17  from Globals import InitializeClass 
18   
19   
20 -def manage_addDefGraphPoint(context, id, REQUEST = None):
21 ''' This is here so than zope will let us copy/paste/rename 22 graphpoints. 23 ''' 24 gp = DefGraphPoint(id) 25 context._setObject(gp.id, gp) 26 if REQUEST: 27 return context.callZenScreen(REQUEST)
28 29
30 -class DefGraphPoint(GraphPoint):
31 32 meta_type = 'DefGraphPoint' 33 34 rrdFile = '' 35 dsName = 'ds0' 36 step = '' 37 start = '' 38 end = '' 39 cFunc = 'AVERAGE' 40 rFunc = '' 41 42 _properties = GraphPoint._properties + ( 43 {'id':'rrdFile', 'type':'string', 'mode':'w'}, 44 {'id':'dsName', 'type':'string', 'mode':'w'}, 45 {'id':'step', 'type':'string', 'mode':'w'}, 46 {'id':'start', 'type':'string', 'mode':'w'}, 47 {'id':'end', 'type':'string', 'mode':'w'}, 48 {'id':'cFunc', 'type':'string', 'mode':'w'}, 49 {'id':'rFunc', 'type':'string', 'mode':'w'}, 50 ) 51 52
53 - def getDescription(self):
54 return '%s %s' % (self.rrdFile, self.dsName)
55 56
57 - def getType(self):
58 return 'DEF'
59 60
61 - def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx, 62 multiid=-1, prefix=''):
63 ''' Build the graphing commands for this graphpoint 64 ''' 65 if not (self.rrdFile and self.dsName and self.cFunc): 66 return cmds 67 68 rrdFile = self.talesEval(self.rrdFile, context, rrdDir=rrdDir) 69 70 dest = self.getDsName(self.id, multiid, prefix) 71 gopt = 'DEF:%s=%s:%s:%s' % ( 72 dest, 73 rrdFile, 74 self.dsName, 75 self.cFunc) 76 if self.step: 77 gopt += ':step=%s' % self.step 78 if self.start: 79 start = self.talesEval(self.start, context) 80 gopt += ':start=%s' % start.replace(':', '\:') 81 if self.end: 82 end = self.talesEval(self.end, context) 83 gopt += ':end=%s' % end.replace(':', '\:') 84 if self.rFunc: 85 gopt += ':reduce=%s' % self.rFunc 86 return cmds + [gopt]
87 88 89 InitializeClass(DefGraphPoint) 90