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

# Source Code for Module Products.ZenModel.Monitor

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