Package Products :: Package ZenHub :: Package services :: Module ProcessConfig |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenHub.services.ProcessConfig

     1  ###########################################################################
     2  #
     3  # This program is part of Zenoss Core, an open source monitoring platform.
     4  # Copyright (C) 2009, 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  from Products.ZenCollector.services.config import CollectorConfigService
    15  from Products.ZenUtils.Utils import unused
    16  from Products.ZenCollector.services.config import DeviceProxy
    17  from Products.ZenEvents import Event
    18  from Products.ZenModel.OSProcessClass import OSProcessClass
    19  from Products.ZenModel.OSProcessOrganizer import OSProcessOrganizer
    20  unused(DeviceProxy)
    21
    22  from twisted.spread import pb
    23
    24 -class ProcessProxy(pb.Copyable, pb.RemoteCopy):
    25      """
    26      Track process-specific configuration data
    27      """
    28      name = None
    29      originalName = None
    30      ignoreParameters = False
    31      restart = None
    32      severity = Event.Warning
    33      cycleTime = None
    34      processClass = None
    35
    36 -    def __init__(self):
    37          pass
    38
    39 -    def __str__(self):
    40          """
    41          Override the Python default to represent ourselves as a string
    42          """
    43          return str(self.name)
    44      __repr__ = __str__
    45
    46
    47  pb.setUnjellyableForClass(ProcessProxy, ProcessProxy)
    48
    49
    50 -class ProcessConfig(CollectorConfigService):
    51
    52 -    def __init__(self, dmd, instance):
    53          deviceProxyAttributes = ('zMaxOIDPerRequest',)
    54          CollectorConfigService.__init__(self, dmd, instance, deviceProxyAttributes)
    55
    56 -    def _filterDevice(self, device):
    57          include = CollectorConfigService._filterDevice(self, device)
    58          include = include and device.snmpMonitorDevice()
    59
    60          return include
    61
    62 -    def _createDeviceProxy(self, device):
    63          procs = device.getMonitoredComponents(collector='zenprocess')
    64          if not procs:
    65              return None
    66
    67          proxy = CollectorConfigService._createDeviceProxy(self, device)
    68          proxy.configCycleInterval = self._prefs.processCycleInterval
    69
    70          proxy.name = device.id
    71          proxy.thresholds = []
    72          proxy.processes = {}
    73          proxy.snmpConnInfo = device.getSnmpConnInfo()
    74          for p in procs:
    75              proxy.thresholds.extend(p.getThresholdInstances('SNMP'))
    76              proc = ProcessProxy()
    77              proc.name = p.id
    78              proc.originalName = p.name()
    79              proc.ignoreParameters = (
    80                  getattr(p.osProcessClass(), 'ignoreParameters', False))
    81              proc.restart = p.alertOnRestart()
    82              proc.severity = p.getFailSeverity()
    83              proc.processClass = p.getOSProcessClass()
    84              proxy.processes[p.id] = proc
    85
    86          return proxy
    87
    88 -    def _getNotifiableClasses(self):
    89          return (OSProcessClass, OSProcessOrganizer)
    90