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 from GraphPoint import GraphPoint
20 from Globals import InitializeClass
21
22
31
32
34
35 meta_type = 'DefGraphPoint'
36
37 rrdFile = ''
38 dsName = 'ds0'
39 step = ''
40 start = ''
41 end = ''
42 cFunc = 'AVERAGE'
43 rFunc = ''
44
45 _properties = GraphPoint._properties + (
46 {'id':'rrdFile', 'type':'string', 'mode':'w'},
47 {'id':'dsName', 'type':'string', 'mode':'w'},
48 {'id':'step', 'type':'string', 'mode':'w'},
49 {'id':'start', 'type':'string', 'mode':'w'},
50 {'id':'end', 'type':'string', 'mode':'w'},
51 {'id':'cFunc', 'type':'string', 'mode':'w'},
52 {'id':'rFunc', 'type':'string', 'mode':'w'},
53 )
54
55
58
59
62
63
64 - def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx,
65 multiid=-1, prefix=''):
66 ''' Build the graphing commands for this graphpoint
67 '''
68 if not (self.rrdFile and self.dsName and self.cFunc):
69 return cmds
70
71 rrdFile = self.talesEval(self.rrdFile, context, rrdDir=rrdDir)
72
73 dest = self.getDsName(self.id, multiid, prefix)
74 gopt = 'DEF:%s=%s:%s:%s' % (
75 dest,
76 rrdFile,
77 self.dsName,
78 self.cFunc)
79 if self.step:
80 gopt += ':step=%s' % self.step
81 if self.start:
82 start = self.talesEval(self.start, context)
83 gopt += ':start=%s' % start.replace(':', '\:')
84 if self.end:
85 end = self.talesEval(self.end, context)
86 gopt += ':end=%s' % end.replace(':', '\:')
87 if self.rFunc:
88 gopt += ':reduce=%s' % self.rFunc
89 return cmds + [gopt]
90
91
92 InitializeClass(DefGraphPoint)
93