1
2
3
4
5
6
7
8
9
10
11 from Products.ZenModel.ThresholdInstance import RRDThresholdInstance
12
13 __doc__= """Threshold to track when a value changes.
14 """
15
16 from Globals import InitializeClass
17 from ThresholdClass import ThresholdClass
18 from ThresholdInstance import ThresholdContext
19 from zenoss.protocols.protobufs.zep_pb2 import SEVERITY_INFO
20 from Products.ZenEvents.ZenEventClasses import Status_Perf
21
22 import logging
23 log = logging.getLogger('zen.MinMaxCheck')
24
25
26 NaN = float('nan')
27
45
46 InitializeClass(ValueChangeThreshold)
47 ValueChangeThresholdClass = ValueChangeThreshold
48
50 """
51 Threshold that emits an event when a value changes from its previous value. Does not send clear events.
52 """
53
54 - def __init__(self, id, context, dpNames, eventClass, severity):
57
59 dpKey = self._getDpKey(dataPoint)
60 lastValue = self._lastValues.get(dpKey, None)
61 if lastValue != value:
62 self._lastValues[dpKey] = value
63 event = dict(
64 device=self.context().deviceName,
65 summary="Value changed from %s to %s" % (lastValue, value),
66 eventKey=self.id,
67 eventClass=self.eventClass,
68 component=self.context().componentName,
69 current=value,
70 previous=lastValue,
71 severity=self.severity)
72 return (event,)
73 return tuple()
74
76 return ':'.join(self.context().key()) + ':' + dp
77
78
79 from twisted.spread import pb
80 pb.setUnjellyableForClass(ValueChangeThresholdInstance, ValueChangeThresholdInstance)
81