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

# Source Code for Module Products.ZenModel.DefGraphPoint

     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__="""DefGraphPoint
    15
    16  Handles GraphPoints that define an rrd DEF
    17  """
    18
    19  from GraphPoint import GraphPoint
    20  from Globals import InitializeClass
    21
    22
    23 -def manage_addDefGraphPoint(context, id, REQUEST = None):
    24      ''' This is here so than zope will let us copy/paste/rename
    25      graphpoints.
    26      '''
    27      gp = DefGraphPoint(id)
    28      context._setObject(gp.id, gp)
    29      if REQUEST:
    30          return context.callZenScreen(REQUEST)
    31
    32
    33 -class DefGraphPoint(GraphPoint):
    34
    35      meta_type = 'DefGraphPoint'
    36
    37      rrdFile = ''
    38      dsName = 'ds0'
    39      step = ''
    40      start = ''
    41      end = ''
    42      cFunc = 'AVERAGE'
    43      rFunc = ''
    44
    45      _properties = GraphPoint._properties + (
    46          {'id':'rrdFile', 'type':'string', 'mode':'w'},
    47          {'id':'dsName', 'type':'string', 'mode':'w'},
    48          {'id':'step', 'type':'string', 'mode':'w'},
    49          {'id':'start', 'type':'string', 'mode':'w'},
    50          {'id':'end', 'type':'string', 'mode':'w'},
    51          {'id':'cFunc', 'type':'string', 'mode':'w'},
    52          {'id':'rFunc', 'type':'string', 'mode':'w'},
    53          )
    54
    55
    56 -    def getDescription(self):
    57          return '%s %s' % (self.rrdFile, self.dsName)
    58
    59
    60 -    def getType(self):
    61          return 'DEF'
    62
    63
    64 -    def getGraphCmds(self, cmds, context, rrdDir, addSummary, idx,
    65                              multiid=-1, prefix=''):
    66          ''' Build the graphing commands for this graphpoint
    67          '''
    68          if not (self.rrdFile and self.dsName and self.cFunc):
    69              return cmds
    70
    71          rrdFile = self.talesEval(self.rrdFile, context, rrdDir=rrdDir)
    72
    73          dest = self.getDsName(self.id, multiid, prefix)
    74          gopt = 'DEF:%s=%s:%s:%s' % (
    75                      dest,
    76                      rrdFile,
    77                      self.dsName,
    78                      self.cFunc)
    79          if self.step:
    80              gopt += ':step=%s' % self.step
    81          if self.start:
    82              start = self.talesEval(self.start, context)
    83              gopt += ':start=%s' % start.replace(':', '\:')
    84          if self.end:
    85              end = self.talesEval(self.end, context)
    86              gopt += ':end=%s' % end.replace(':', '\:')
    87          if self.rFunc:
    88              gopt += ':reduce=%s' % self.rFunc
    89          return cmds + [gopt]
    90
    91
    92  InitializeClass(DefGraphPoint)
    93