1
2
3
4
5
6
7
8
9
10
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
32
33
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
59
60
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