1
2
3
4
5
6
7
8
9
10
11 from AccessControl import ClassSecurityInfo
12
13 import Globals
14 from Products.ZenModel.ZenModelRM import ZenModelRM
15 from Products.ZenModel.ZenPackable import ZenPackable
16 from Products.ZenRelations.RelSchema import *
17
19
21 """A ThresholdClass is a threshold description stored in a
22 Template. The ThresholdClass will create ThresholdInstance
23 objects when provided with a context, such as a device. Lists of
24 ThresholdInstances will be sent to collectors for evaluation.
25 """
26
27 meta_type = 'ThresholdClass'
28 security = ClassSecurityInfo()
29 dsnames = []
30 enabled = True
31
32 - def __init__(self, id, buildRelations=True):
36
37 _properties = (
38 {'id':'eventClass', 'type':'string', 'mode':'w'},
39 {'id':'severity', 'type':'int', 'mode':'w'},
40 {'id':'dsnames', 'type':'lines', 'mode':'w', 'label': 'DataPoints'},
41 {'id':'enabled', 'type':'boolean', 'mode':'w', 'label': 'Enabled'},
42 )
43
44 _relations = ZenPackable._relations + (
45 ("rrdTemplate", ToOne(ToManyCont,"Products.ZenModel.RRDTemplate", "thresholds")),
46 )
47
50
51
59
60
62 """Return a sub-class of ThresholdInstance. May raise a
63 BadInstance exception if the type of the context does not
64 match this type of threshold.
65 """
66
67
69 """Returns true if instances of this ThresholdClass can be
70 placed on a users' graph"""
71 return True
72
73
74 - def sync(self, eventManager, instances):
75 "update instances with state from the event manager"
76
77
80
81
83 """
84 Return a string that lists the datapoints used in this threshold.
85 Indicate missing datapoints with (missing) after the name.
86 """
87 names = []
88 availableDPNames = self.rrdTemplate.getRRDDataPointNames()
89 for dsName in self.dsnames:
90 if dsName in availableDPNames:
91 names.append(dsName)
92 else:
93 names.append('%s(<span style="color: red">missing</span>)' % dsName)
94 return ','.join(names)
95