1
2
3
4
5
6
7
8
9
10
11 from Globals import DTMLFile
12 from Globals import InitializeClass
13 from AccessControl import ClassSecurityInfo, Permissions
14
15 from ZenModelRM import ZenModelRM
16 from ZenPackable import ZenPackable
17
18 from Products.ZenRelations.RelSchema import *
19 from Products.ZenUtils.ZenTales import talesEval
20 from Products.ZenEvents.ZenEventClasses import Perf_Snmp
21 from Products.ZenModel.MinMaxThreshold import rpneval
22
23
30
31 addRRDThreshold = DTMLFile('dtml/addRRDThreshold',globals())
32
34
35 meta_type = 'RRDThreshold'
36
37 security = ClassSecurityInfo()
38
39 dsnames = []
40 minval = ""
41 maxval = ""
42 eventClass = Perf_Snmp
43 severity = 3
44 escalateCount = 0
45 enabled = True
46
47 _properties = (
48 {'id':'dsnames', 'type':'lines', 'mode':'w'},
49 {'id':'minval', 'type':'string', 'mode':'w'},
50 {'id':'maxval', 'type':'string', 'mode':'w'},
51 {'id':'eventClass', 'type':'string', 'mode':'w'},
52 {'id':'severity', 'type':'int', 'mode':'w'},
53 {'id':'escalateCount', 'type':'int', 'mode':'w'},
54 {'id':'enabled', 'type':'boolean', 'mode':'w'},
55 )
56
57
58
59
60
61
62 factory_type_information = (
63 {
64 'immediate_view' : 'editRRDThreshold',
65 'actions' :
66 (
67 { 'id' : 'edit'
68 , 'name' : 'RRD Threshold'
69 , 'action' : 'editRRDThreshold'
70 , 'permissions' : ( Permissions.view, )
71 },
72 )
73 },
74 )
75
83
84
91
92
100
101
109
110
113
114
117
118
120 """when graphing use this so that rpn conversions are accounted for"""
121 val = getfunc(context)
122 if val is None or len(self.dsnames) == 0: return
123 dp = self.getRRDDataPoint(self.dsnames[0])
124 if dp and dp.rpn:
125
126
127 val = rpneval(val, dp.rpn)
128 return val
129
130
134
135
139
140
142 powers = ("k", "M", "G")
143 if number < 1000: return number
144 for power in powers:
145 number = number / 1000
146 if number < 1000:
147 return "%0.2f%s" % (number, power)
148 return "%.2f%s" % (number, powers[-1])
149
150
153
154
155 InitializeClass(RRDThreshold)
156