Package ZenRRD :: Module RRDRelativeThresh
[hide private]
[frames] | no frames]

Source Code for Module ZenRRD.RRDRelativeThresh

 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  __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   
35 -def manage_addRRDRelativeThresh(context, id, REQUEST = None):
36 """make a RRDRelativeThresh""" 37 tt = RRDRelativeThresh(id) 38 context._setObject(tt.id, tt) 39 if REQUEST is not None: 40 REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')
41 42 addRRDRelativeThresh = DTMLFile('dtml/addRRDRelativeThresh',globals()) 43 44
45 -class RRDRelativeThresh(RRDThreshold):
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
68 - def getCricketThresholds(self, context):
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