1
2
3
4
5
6
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
28
29
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
55
56
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