Trees | Indices | Help |
|
---|
|
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 from Globals import DTMLFile 15 from Globals import InitializeClass 16 from AccessControl import ClassSecurityInfo, Permissions 17 18 from ZenModelRM import ZenModelRM 19 from ZenPackable import ZenPackable 20 21 from Products.ZenRelations.RelSchema import * 22 from Products.ZenUtils.ZenTales import talesEval 23 from Products.ZenEvents.ZenEventClasses import Perf_Snmp 24 from Products.ZenModel.MinMaxThreshold import rpneval 25 2628 """make a RRDThreshold""" 29 tt = RRDThreshold(id) 30 context._setObject(tt.id, tt) 31 if REQUEST is not None: 32 REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')33 34 addRRDThreshold = DTMLFile('dtml/addRRDThreshold',globals()) 3537 38 meta_type = 'RRDThreshold' 39 40 security = ClassSecurityInfo() 41 42 dsnames = [] 43 minval = "" 44 maxval = "" 45 eventClass = Perf_Snmp 46 severity = 3 47 escalateCount = 0 48 enabled = True 49 50 _properties = ( 51 {'id':'dsnames', 'type':'lines', 'mode':'w'}, 52 {'id':'minval', 'type':'string', 'mode':'w'}, 53 {'id':'maxval', 'type':'string', 'mode':'w'}, 54 {'id':'eventClass', 'type':'string', 'mode':'w'}, 55 {'id':'severity', 'type':'int', 'mode':'w'}, 56 {'id':'escalateCount', 'type':'int', 'mode':'w'}, 57 {'id':'enabled', 'type':'boolean', 'mode':'w'}, 58 ) 59 60 # _relations = ZenPackable._relations + ( 61 # ("rrdTemplate", ToOne(ToManyCont,"Products.ZenModel.RRDTemplate", "thresholds")), 62 # ) 63 64 65 factory_type_information = ( 66 { 67 'immediate_view' : 'editRRDThreshold', 68 'actions' : 69 ( 70 { 'id' : 'edit' 71 , 'name' : 'RRD Threshold' 72 , 'action' : 'editRRDThreshold' 73 , 'permissions' : ( Permissions.view, ) 74 }, 75 ) 76 }, 77 ) 78156 157 158 InitializeClass(RRDThreshold) 15980 """Return the breadcrumb links for this object add ActionRules list. 81 [('url','id'), ...] 82 """ 83 from RRDTemplate import crumbspath 84 crumbs = super(RRDThreshold, self).breadCrumbs(terminator) 85 return crumbspath(self.rrdTemplate(), crumbs, -2)86 8789 """Return the config used by the collector to process simple min/max 90 thresholds. (id, minval, maxval, severity, escalateCount) 91 """ 92 return (self.id,self.getMinval(context),self.getMaxval(context), 93 self.eventClass, self.severity,self.escalateCount)94 9597 """Build the min value for this threshold. 98 """ 99 minval = None 100 if self.minval: 101 minval = talesEval("python:"+self.minval, context) 102 return minval103 104106 """Build the max value for this threshold. 107 """ 108 maxval = None 109 if self.maxval: 110 maxval = talesEval("python:"+self.maxval, context) 111 return maxval112 113 116 117 120 121123 """when graphing use this so that rpn conversions are accounted for""" 124 val = getfunc(context) 125 if val is None or len(self.dsnames) == 0: return 126 dp = self.getRRDDataPoint(self.dsnames[0]) 127 if dp and dp.rpn: 128 #When VDEF does full rpn 129 #val = "%s,%s" % (val, dp.rpn) 130 val = rpneval(val, dp.rpn) 131 return val132 133135 """build a label for a min threshold""" 136 return "%s < %s" % (self.id,self.setPower(self.getGraphMinval(context)))137 138140 """build a label for a max threshold""" 141 return "%s > %s" % (self.id,self.setPower(self.getGraphMaxval(context)))142 143145 powers = ("k", "M", "G") 146 if number < 1000: return number 147 for power in powers: 148 number = number / 1000 149 if number < 1000: 150 return "%0.2f%s" % (number, power) 151 return "%.2f%s" % (number, powers[-1])152 153
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:18 2009 | http://epydoc.sourceforge.net |