Trees | Indices | Help |
|
---|
|
1 #! /usr/bin/env python 2 ########################################################################### 3 # 4 # This program is part of Zenoss Core, an open source monitoring platform. 5 # Copyright (C) 2007, Zenoss Inc. 6 # 7 # This program is free software; you can redistribute it and/or modify it 8 # under the terms of the GNU General Public License version 2 as published by 9 # the Free Software Foundation. 10 # 11 # For complete information please visit: http://www.zenoss.com/oss/ 12 # 13 ########################################################################### 14 15 __doc__='''RRDDaemon 16 17 Common performance monitoring daemon code for performance daemons. 18 19 $Id$ 20 ''' 21 22 __version__ = "$Revision$"[11:-2] 23 24 import socket 25 26 import Globals 27 from Products.ZenEvents import Event 28 from Products.ZenEvents.ZenEventClasses import Perf_Snmp, Heartbeat 29 from Products.ZenUtils.Driver import drive 30 31 from twisted.internet import reactor, defer 32 from twisted.python import failure 33 34 from Products.ZenHub.PBDaemon import FakeRemote, PBDaemon as Base 35 from Products.ZenRRD.Thresholds import Thresholds 36 37 38 BAD_SEVERITY=Event.Warning 39 40 BASE_URL = 'http://localhost:8080/zport/dmd' 41 DEFAULT_URL = BASE_URL + '/Monitors/Performance/localhost' 42 43 44 COMMON_EVENT_INFO = { 45 'manager': socket.getfqdn(), 46 } 47 4850 'Holds the code common to performance gathering daemons.' 51 52 heartbeatevt = {'eventClass':Heartbeat} 53 54 properties = ('configCycleInterval',) 55 heartBeatTimeout = 60*3 56 configCycleInterval = 20 # minutes 57 rrd = None 58 shutdown = False 59 thresholds = None 6014062 self.events = [] 63 self.name = name 64 Base.__init__(self) 65 evt = self.heartbeatevt.copy() 66 self.thresholds = Thresholds() 67 self.heartbeatevt.update(dict(component=name, 68 device=socket.getfqdn()))69 7274 from Products.ZenUtils.Utils import importClass 75 self.log.debug("Loading classes %s", classes) 76 for c in classes: 77 try: 78 importClass(c) 79 except ImportError: 80 self.log.exception("Unable to import class %s", c)81 85 8688 self.log.debug("Async update of device list")89 9092 'extract configuration elements used by this server' 93 table = dict(items) 94 for name in self.properties: 95 value = table.get(name, None) 96 if value is not None: 97 if getattr(self, name) != value: 98 self.log.debug('Updated %s config to %s' % (name, value)) 99 setattr(self, name, value)100 101 105 106108 'if cycling, send a heartbeat, else, shutdown' 109 if not self.options.cycle: 110 self.stop() 111 return 112 self.sendEvent(self.heartbeatevt, timeout=self.heartBeatTimeout)113 114116 Base.buildOptions(self) 117 self.parser.add_option('-d', '--device', 118 dest='device', 119 default='', 120 help="Specify a specific device to monitor")121123 if isinstance(error, failure.Failure): 124 self.log.exception(error) 125 else: 126 self.log.error('%s %s', msg, error)127129 'Log an error, including any traceback data for a failure Exception' 130 self.logError('Error', error) 131 if not self.options.cycle: 132 self.stop()133 137
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:25 2007 | http://epydoc.sourceforge.net |