Package ZenModel :: Module ThresholdInstance
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.ThresholdInstance

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
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
38 - def key(self):
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
54 -class ThresholdInstance(pb.Copyable, pb.RemoteCopy):
55 """A ThresholdInstance is a threshold to be evaluated in a 56 collector within a given context.""" 57 58 # count is unknown if None 59 count = None 60
61 - def name(self):
62 "return the name of this threshold (from the ThresholdClass)"
63
64 - def context(self):
65 "Return the ThresholdContext for this ThresholdInstance"
66
67 - def key(self):
68 "Unique data that refers to this object within a collector" 69 return self.name(), self.context().key()
70
71 - def dataPoints(self):
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
85 - def getGraphElements(self, template, gopts, namespace, color):
86 """Produce a visual indication on the graph of where the 87 threshold applies.""" 88 return []
89 90 91 pb.setUnjellyableForClass(ThresholdInstance, ThresholdInstance) 92