Package Products :: Package ZenHub :: Module zenhub :: Class ZenHub |
[hide private]
[frames] | no frames]

# Class ZenHub

source code

                  object --+
                           |
    ZenUtils.CmdBase.CmdBase --+
                               |
    ZenUtils.ZenDaemon.ZenDaemon --+
                                   |
          ZenUtils.ZCmdBase.ZCmdBase --+
                                       |
                                      ZenHub

    Listen for changes to objects in the Zeo database and update the
    collectors' configuration.

    The remote collectors connect the ZenHub and request configuration
    information and stay connected.  When changes are detected in the
    Zeo database, configuration updates are sent out to collectors
    asynchronously.  In this way, changes made in the web GUI can
    affect collection immediately, instead of waiting for a
    configuration cycle.

    Each collector uses a different, pluggable service within ZenHub
    to translate objects into configuration and data.  ZenPacks can
    add services for their collectors.  Collectors communicate using
    Twisted's Perspective Broker, which provides authenticated,
    asynchronous, bidirectional method invocation.

    ZenHub also provides an XmlRPC interface to some common services
    to support collectors written in other languages.

    ZenHub does very little work in its own process, but instead dispatches
    the work to a pool of zenhubworkers, running zenhubworker.py. zenhub
    manages these workers with 3 data structures:
    - workers - a list of remote PB instances
    - worker_processes - a set of WorkerRunningProtocol instances
    - workerprocessmap - a dict mapping pid to process instance created
        by reactor.spawnprocess
    Callbacks and handlers that detect worker shutdown update these
    structures automatically. ONLY ONE HANDLER must take care of restarting
    new workers, to avoid accidentally spawning too many workers. This
    handler also verifies that zenhub is not in the process of shutting
    down, so that callbacks triggered during daemon shutdown don't keep
    starting new workers.

    TODO: document invalidation workers

Instance Methods | [hide private]
__init__(self) Hook ourselves up to the Zeo database and wait for collectors to connect. | source code
sighandler_USR2(self, signum, frame) | source code
stop(self) | source code
_getConf(self) | source code
getRRDStats(self) Return the most recent RRD statistic information. | source code
processQueue(self) Periodically (once a second) process database changes | source code
_initialize_invalidation_filters(self) | source code
_filter_oids(self, oids) | source code
_transformOid(self, oid, obj) | source code
doProcessQueue(self) Perform one cycle of update notifications. | source code
sendEvent(self, **kw) Useful method for posting events to the EventManager. | source code
loadChecker(self) Load the password file | source code
getService(self, name, instance) Helper method to load services dynamically for a collector. | source code
deferToWorker(self, args) Take a remote request and queue it for worker processes. | source code
updateStatusAtStart(self, wId, job) | source code
updateStatusAtFinish(self, wId, error=None) | source code
giveWorkToWorkers(self, requeue=False) Parcel out a method invocation to an available worker process | source code
_workerStats(self) | source code
_createWorkerConf(self) | source code
createWorker(self) Start a worker subprocess | source code
heartbeat(self) Since we don't do anything on a regular basis, just push heartbeats regularly. | source code
saveCounters(self) | source code
loadCounters(self) | source code
main(self) Start the main event loop. | source code
buildOptions(self) Adds our command line options to ZCmdBase command line options. | source code
Inherited from `ZenUtils.ZCmdBase.ZCmdBase`: `closeAll`, `closedb`, `findDevice`, `getConnection`, `getContext`, `getDataRoot`, `getDmdObj`, `login`, `logout`, `opendb`, `sigTerm`, `syncdb`, `zodbConnect` Inherited from `ZenUtils.ZenDaemon.ZenDaemon`: `audit`, `becomeDaemon`, `becomeWatchdog`, `changeUser`, `convertSocketOption`, `logname`, `niceDoggie`, `openPrivilegedPort`, `setupLogging`, `sighandler_USR1`, `watchdogCycleTime`, `watchdogMaxRestartTime`, `watchdogStartTimeout`, `writePidFile` Inherited from `ZenUtils.ZenDaemon.ZenDaemon` (private): `_sigUSR1_called` Inherited from `ZenUtils.CmdBase.CmdBase`: `buildParser`, `checkLogpath`, `generate_configs`, `generate_xml_configs`, `generate_xml_table`, `getConfigFileDefaults`, `getGlobalConfigFileDefaults`, `getParamatersFromConfig`, `loadConfigFile`, `parseOptions`, `pretty_print_config_comment`, `validateConfigFile`

Class Variables | [hide private]
| totalTime = `0.`
| totalEvents = `0`
| totalCallTime = `0.`
| name = `'zenhub'`
Inherited from `ZenUtils.ZenDaemon.ZenDaemon`: `pidfile` Inherited from `ZenUtils.CmdBase.CmdBase`: `doesLogging`

Method Details | [hide private]

### __init__(self) (Constructor) | source code
Hook ourselves up to the Zeo database and wait for collectors to connect. Overrides: ZenUtils.CmdBase.CmdBase.__init__

### processQueue(self) | source code
Periodically (once a second) process database changes Returns: None

### doProcessQueue(self) | source code
Perform one cycle of update notifications. Returns: None

### sendEvent(self, **kw) | source code
Useful method for posting events to the EventManager. Parameters: `kw` (keywords (dict)) - the values for an event: device, summary, etc. Returns: None

### loadChecker(self) | source code
Load the password file Returns: an object satisfying the ICredentialsChecker interface using a password file or an empty list if the file is not available. Uses the file specified in the --passwd command line option.

### getService(self, name, instance) | source code
Helper method to load services dynamically for a collector. Returned instances are cached: reconnecting collectors will get the same service object. Parameters: `name` (string) - the dotted-name of the module to load (uses @Products.ZenUtils.Utils.importClass) `instance` - string `instance` - each service serves only one specific collector instances (like 'localhost'). instance defines the collector's instance name. Returns: a service loaded from ZenHub/services or one of the zenpacks.

### deferToWorker(self, args) | source code
Take a remote request and queue it for worker processes. Parameters: `args` (tuple) - the arguments to the remote_execute() method in the worker Returns: a Deferred for the eventual results of the method call

### createWorker(self) | source code
Start a worker subprocess Returns: None

### heartbeat(self) | source code
Since we don't do anything on a regular basis, just push heartbeats regularly. Returns: None

### buildOptions(self) | source code
Adds our command line options to ZCmdBase command line options. Overrides: ZenUtils.CmdBase.CmdBase.buildOptions