Package Products :: Package ZenModel :: Module LineGraphPoint |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenModel.LineGraphPoint

     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__="""Line
    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_addLineGraphPoint(context, id, REQUEST = None):
    24      ''' This is here so than zope will let us copy/paste/rename
    25      graphpoints.
    26      '''
    27      gp = LineGraphPoint(id)
    28      context._setObject(gp.id, gp)
    29      if REQUEST:
    30          return context.callZenScreen(REQUEST)
    31
    32
    33 -class LineGraphPoint(GraphPoint):
    34
    35      meta_type = 'LineGraphPoint'
    36
    37      lineWidth = 1
    38      value = ''
    39      color = ''
    40      legend = GraphPoint.DEFAULT_LEGEND
    41      stacked = False
    42
    43      _properties = GraphPoint._properties + (
    44          {'id':'lineWidth', 'type':'long', 'mode':'w'},
    45          {'id':'value', 'type':'string', 'mode':'w'},
    46          {'id':'color', 'type':'string', 'mode':'w'},
    47          {'id':'legend', 'type':'string', 'mode':'w'},
    48          {'id':'stacked', 'type':'boolean', 'mode':'w'},
    49          )
    50
    51 -    def getDescription(self):
    52          return '%s %s' % (self.value, self.legend)
    53
    54
    55 -    def getType(self):
    56          return 'LINE'
    57
    58
    59 -    def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx,
    60                          multiid=-1, prefix=''):
    61          ''' Build the graphing commands for this graphpoint
    62          '''
    63          from Products.ZenUtils.Utils import unused
    64          unused(multiid, rrdDir)
    65          value = self.addPrefix(prefix, self.value)
    66          gopts = 'LINE%s:%s' % ((self.lineWidth or ''), value)
    67          if self.color:
    68              gopts += self.getColor(idx)
    69          if self.legend or self.stacked:
    70              legend = self.talesEval(self.legend, context)
    71              legend = self.escapeForRRD(legend)
    72              gopts += ':%s' % legend
    73          if self.stacked:
    74              gopts += ':STACK'
    75          return cmds + [gopts]
    76
    77
    78  InitializeClass(LineGraphPoint)
    79