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

# Source Code for Module Products.ZenModel.Monitor

      1  ##############################################################################
      2  #
      3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
      4  #
      5  # This content is made available according to terms specified in
      6  # License.zenoss under the directory where your Zenoss product is installed.
      7  #
      8  ##############################################################################
      9
     10
     11  __doc__="""Monitor
     12
     13  Base class for all Monitor or Monitor Configuration Classes.  This is
     14  an abstract class that is used for the devices to monitors
     15  relationship which says which monitors monitor which devices.
     16
     17  $Id: Monitor.py,v 1.5 2004/04/14 22:11:48 edahl Exp $"""
     18
     19  __version__ = "$Revision: 1.5 $"[11:-2]
     20
     21  from Globals import InitializeClass
     22
     23  from ZenModelRM import ZenModelRM
     24  from DeviceManagerBase import DeviceManagerBase
     25  from RRDView import RRDView
     26  from Products.ZenWidgets import messaging
     27
     28 -class Monitor(ZenModelRM, DeviceManagerBase, RRDView):
     29      meta_type = 'Monitor'
     30
     31 -    def snmpIgnore(self):
     32          return True
     33
     34 -    def breadCrumbs(self, target='dmd'):
     35          from Products.ZenUtils.Utils import unused
     36          unused(target)
     37          bc = ZenModelRM.breadCrumbs(self)
     38          return [bc[0],bc[-1]]
     39
     40 -    def deviceMoveTargets(self):
     41          """see IManageDevice"""
     42          mroot = self.getDmdRoot("Monitors")._getOb(self.monitorRootName)
     43          return filter(lambda x: x != self.id, mroot.objectIds())
     44
     45
     46 -    def getDeviceMoveTarget(self, moveTargetName):
     47          """see IManageDevice"""
     48          mroot = self.getDmdRoot("Monitors")._getOb(self.monitorRootName)
     49          return mroot._getOb(moveTargetName)
     50
     51
     52 -    def getOrganizerName(self):
     53          """Return the DMD path of an Organizer without its dmdSubRel names."""
     54          return self.id
     55
     56 -    def setPerformanceMonitor(self, performanceMonitor=None, deviceNames=None,
     57                                REQUEST=None):
     58          """ Provide a method to set performance monitor from any organizer """
     59          if not performanceMonitor:
     60              if REQUEST:
     61                  messaging.IMessageSender(self).sendToBrowser(
     62                      'Error',
     63                      'No monitor was selected.',
     64                      priority=messaging.WARNING
     65                  )
     66              return self.callZenScreen(REQUEST)
     67          if deviceNames is None:
     68              if REQUEST:
     69                  messaging.IMessageSender(self).sendToBrowser(
     70                      'Error',
     71                      'No devices were selected.',
     72                      priority=messaging.WARNING
     73                  )
     74              return self.callZenScreen(REQUEST)
     75          for devname in deviceNames:
     76              dev = self.devices._getOb(devname)
     77              dev.setPerformanceMonitor(performanceMonitor)
     78          if REQUEST:
     79              messaging.IMessageSender(self).sendToBrowser(
     80                  'Monitor Set',
     81                  'Performance monitor was set to %s.' % performanceMonitor
     82              )
     83              if REQUEST.has_key('oneKeyValueSoInstanceIsntEmptyAndEvalToFalse'):
     84                  return REQUEST['message']
     85              else:
     86                  return self.callZenScreen(REQUEST)
     87
     88 -    def rrdPath(self):
     89          return 'Daemons/%s' % self.id
     90
     91 -    def getRRDContextData(self, context):
     92          context['here'] = self
     93          context['name'] = self.id
     94          return context
     95
     96 -    def getGraphDefUrl(self, graph, drange=None, template=None):
     97          """resolve template and graph names to objects
     98          and pass to graph performance"""
     99          if not drange: drange = self.defaultDateRange
    100          templates = self.getRRDTemplates()
    101          if template:
    102              templates = [template]
    103          if isinstance(graph, basestring):
    104              for t in templates:
    105                  if hasattr(t.graphDefs, graph):
    106                      template = t
    107                      graph = getattr(t.graphDefs, graph)
    108                      break
    109          targetpath = self.rrdPath()
    110          objpaq = self.primaryAq()
    111          return self.performanceGraphUrl(objpaq, targetpath, template, graph, drange)
    112
    113
    114  InitializeClass(Monitor)
    115