1
2
3
4
5
6
7
8
9
10
11 __doc__="""ThreshGraphPoint
12
13 Handles GraphPoints that refer to RRDDataPoints
14 """
15
16 from GraphPoint import GraphPoint
17 from Globals import InitializeClass
18 from Products.ZenUtils.deprecated import deprecated
30
33
34 meta_type = 'ThresholdGraphPoint'
35
36 isThreshold = True
37
38 threshId = ''
39 color = ''
40 legend = GraphPoint.DEFAULT_LEGEND
41
42 _properties = GraphPoint._properties + (
43 {'id':'threshId', 'type':'string', 'mode':'w'},
44 {'id':'color', 'type':'string', 'mode':'w'},
45 {'id':'legend', 'type':'string', 'mode':'w'},
46 )
47
49 ''' Get the related threshold class or None if it doesn't exist
50 '''
51 threshClass = None
52 if self.graphDef.rrdTemplate():
53 threshClass = self.graphDef.rrdTemplate.thresholds._getOb(
54 self.threshId, None)
55 return threshClass
56
57
60
61
64
65
83
84
85 - def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx,
86 multiid=-1, prefix=''):
87 ''' Build the graphing commands for this graphpoint
88 '''
89 from Products.ZenUtils.Utils import unused
90 unused(multiid, rrdDir)
91 if getattr(context, 'isFake', False):
92 return cmds
93 relatedGps = self.getRelatedGraphPoints(context)
94 gopts = []
95 threshClass = self.getThreshClass(context)
96 if threshClass:
97 threshInst = threshClass.createThresholdInstance(context)
98 namespace = self.addPrefix(prefix, self.id)
99 color = self.getThresholdColor(idx)
100 legend = self.talesEval(self.legend, context)
101 template = self.graphDef.rrdTemplate() or None
102
103
104
105 gopts = threshInst.getGraphElements(
106 template, context, gopts, namespace,
107 color, legend, relatedGps)
108 return cmds + gopts
109
110
111 InitializeClass(ThresholdGraphPoint)
112