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

Source Code for Module ZenModel.HruleGraphPoint

 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__="""  
15   
16  Handles GraphPoints that define an rrd Line 
17  """ 
18   
19  from GraphPoint import GraphPoint 
20  from Globals import InitializeClass 
21   
22   
23 -def manage_addHruleGraphPoint(context, id, REQUEST = None):
24 ''' This is here so than zope will let us copy/paste/rename 25 graphpoints. 26 ''' 27 gp = HruleGraphPoint(id) 28 context._setObject(gp.id, gp) 29 if REQUEST: 30 return context.callZenScreen(REQUEST)
31 32
33 -class HruleGraphPoint(GraphPoint):
34 35 meta_type = 'HruleGraphPoint' 36 37 value = '' 38 color = '' 39 legend = GraphPoint.DEFAULT_LEGEND 40 41 _properties = GraphPoint._properties + ( 42 {'id':'value', 'type':'string', 'mode':'w'}, 43 {'id':'color', 'type':'string', 'mode':'w'}, 44 {'id':'legend', 'type':'string', 'mode':'w'}, 45 ) 46 47
48 - def getDescription(self):
49 return '%s %s' % (self.value, self.color)
50 51
52 - def getType(self):
53 return 'HRULE'
54 55
56 - def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx, 57 multiid=-1, prefix=''):
58 ''' Build the graphing commands for this graphpoint 59 ''' 60 from Products.ZenUtils.Utils import unused 61 unused(multiid, prefix, rrdDir) 62 legend = self.talesEval(self.legend, context) 63 legend = self.escapeForRRD(legend) 64 return cmds + ['HRULE:%s%s%s' % ( 65 self.value or 0, 66 self.getColor(idx), 67 legend and ':%s' % legend or '')]
68 69 70 InitializeClass(HruleGraphPoint) 71