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

Source Code for Module ZenModel.DefGraphPoint

 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__="""DefGraphPoint 
15   
16  Handles GraphPoints that define an rrd DEF 
17  """ 
18   
19  import os 
20  from GraphPoint import GraphPoint 
21  from Globals import InitializeClass 
22   
23   
24 -def manage_addDefGraphPoint(context, id, REQUEST = None):
25 ''' This is here so than zope will let us copy/paste/rename 26 graphpoints. 27 ''' 28 gp = DefGraphPoint(id) 29 context._setObject(gp.id, gp) 30 if REQUEST: 31 return context.callZenScreen(REQUEST)
32 33
34 -class DefGraphPoint(GraphPoint):
35 36 meta_type = 'DefGraphPoint' 37 38 rrdFile = '' 39 dsName = 'ds0' 40 step = '' 41 start = '' 42 end = '' 43 cFunc = 'AVERAGE' 44 rFunc = '' 45 46 _properties = GraphPoint._properties + ( 47 {'id':'rrdFile', 'type':'string', 'mode':'w'}, 48 {'id':'dsName', 'type':'string', 'mode':'w'}, 49 {'id':'step', 'type':'string', 'mode':'w'}, 50 {'id':'start', 'type':'string', 'mode':'w'}, 51 {'id':'end', 'type':'string', 'mode':'w'}, 52 {'id':'cFunc', 'type':'string', 'mode':'w'}, 53 {'id':'rFunc', 'type':'string', 'mode':'w'}, 54 ) 55 56
57 - def getDescription(self):
58 return '%s %s' % (self.rrdFile, self.dsName)
59 60
61 - def getType(self):
62 return 'DEF'
63 64
65 - def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx, 66 multiid=-1, prefix=''):
67 ''' Build the graphing commands for this graphpoint 68 ''' 69 if not (self.rrdFile and self.dsName and self.cFunc): 70 return cmds 71 72 rrdFile = self.talesEval(self.rrdFile, context, rrdDir=rrdDir) 73 74 dest = self.getDsName(self.id, multiid, prefix) 75 gopt = 'DEF:%s=%s:%s:%s' % ( 76 dest, 77 rrdFile, 78 self.dsName, 79 self.cFunc) 80 if self.step: 81 gopt += ':step=%s' % self.step 82 if self.start: 83 start = self.talesEval(self.start, context) 84 gopt += ':start=%s' % start.replace(':', '\:') 85 if self.end: 86 end = self.talesEval(self.end, context) 87 gopt += ':end=%s' % end.replace(':', '\:') 88 if self.rFunc: 89 gopt += ':reduce=%s' % self.rFunc 90 return cmds + [gopt]
91 92 93 InitializeClass(DefGraphPoint) 94