1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""RRDRelativeThresh
15
16 RRDRelativeThresh is the zentinel version of a cricket relative threshold.
17 In cricket the threshold will look something like this:
18
19 ifInOctets:relation:<10 pct:::300:SNMP
20
21 for each data source defined
22
23 $Id: RRDRelativeThresh.py,v 1.2 2003/11/13 22:52:42 edahl Exp $"""
24
25 __version__ = "$Revision: 1.2 $"[11:-2]
26
27
28 from AccessControl import ClassSecurityInfo
29 from Globals import InitializeClass
30
31 from Globals import DTMLFile
32
33 from RRDThreshold import RRDThreshold
34
41
42 addRRDRelativeThresh = DTMLFile('dtml/addRRDRelativeThresh',globals())
43
44
46
47 meta_type = 'RRDRelativeThresh'
48
49 security = ClassSecurityInfo()
50
51 operators = (">", "<")
52
53 _properties = (
54 {'id':'dsnames', 'type':'lines', 'mode':'w'},
55 {'id':'delta', 'type':'int', 'mode':'w'},
56 {'id':'operator', 'type':'selection',
57 'select_variable': 'operators', 'mode':'w'},
58 {'id':'percent', 'type':'boolean', 'mode':'w'},
59 {'id':'timeoffset', 'type':'int', 'mode':'w'},
60 )
61
62 _dsnames = []
63 delta = 0
64 operator = ">"
65 percent = 1
66 timeoffset = 300
67
69 """return the cricket threshold string that this threshold defines"""
70 threshs = []
71 for ds in self._dsnames:
72 if self.delta:
73 value = "%s%s" % (self.operator, self.delta)
74 if self.percent: value += " pct"
75 thresh = "%s:relation:%s:::%s:SNMP" % (ds,value,self.timeoffset)
76 threshs.append(thresh)
77 return ','.join(threshs)
78
79 InitializeClass(RRDRelativeThresh)
80