1
2
3
4
5
6
7
8
9
10
11
12
13
14 import os
15
16 import Globals
17 from Products.ZenModel.PerformanceConf import performancePath
18
19
20 from twisted.spread import pb
21 -class ThresholdContext(pb.Copyable, pb.RemoteCopy):
22 """Remember all the little details about a specific data point
23 within a context. This is useful for error messages and path
24 information in the collectors. It's a copy of the key bits of
25 information from the Model."""
26
27 - def __init__(self, context):
28 self.deviceName = context.device().id
29 try:
30 self.componentName = context.name()
31 except AttributeError:
32 self.componentName = context.id
33 if self.componentName == self.deviceName:
34 self.componentName = ''
35 self.rrdPath = context.rrdPath()
36
37
39 "Unique data that refers this context"
40 return self.deviceName, self.componentName
41
42
43 - def fileKey(self, dataPoint):
44 "Unique base filename for this context and given dataPoint"
45 return os.path.join(self.rrdPath, dataPoint)
46
47
48 - def path(self, dataPoint):
49 "The full pathname to RRD file that uses a dataPoint"
50 return performancePath(os.path.join(self.rrdPath, dataPoint)) + '.rrd'
51
52 pb.setUnjellyableForClass(ThresholdContext, ThresholdContext)
53
55 """A ThresholdInstance is a threshold to be evaluated in a
56 collector within a given context."""
57
58
59 count = None
60
62 "return the name of this threshold (from the ThresholdClass)"
63
65 "Return the ThresholdContext for this ThresholdInstance"
66
68 "Unique data that refers to this object within a collector"
69 return self.name(), self.context().key()
70
72 "Returns the names of the datapoints used to compute the threshold"
73
74 - def check(self, dataPoints):
75 """The given datapoints have been updated, so re-evaluate.
76 returns events or an empty sequence"""
77
78 - def checkRaw(self, dataPoint, timeOf, value):
79 """A new datapoint has been collected, use the given _raw_
80 value to re-evalue the threshold.
81 returns a sequence of events.
82 """
83 return self.check([dataPoint])
84
86 """Produce a visual indication on the graph of where the
87 threshold applies."""
88 return []
89
90
91 pb.setUnjellyableForClass(ThresholdInstance, ThresholdInstance)
92