K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / lib / python2.7 / dist-packages / landscape / monitor /
server ip : 104.21.89.46

your ip : 172.69.59.155

H O M E


Filename/usr/lib/python2.7/dist-packages/landscape/monitor/service.py
Size2.22 kb
Permissionrw-r--r--
Ownerroot : root
Create time27-Apr-2025 09:56
Last modified20-Feb-2014 23:01
Last accessed06-Jul-2025 20:04
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
"""Deployment code for the monitor."""

import os

from twisted.python.reflect import namedClass

from landscape.service import LandscapeService, run_landscape_service
from landscape.monitor.config import MonitorConfiguration
from landscape.monitor.monitor import Monitor
from landscape.broker.amp import RemoteBrokerConnector
from landscape.amp import ComponentPublisher


class MonitorService(LandscapeService):
"""
The core Twisted Service which creates and runs all necessary monitoring
components when started.
"""

service_name = Monitor.name

def __init__(self, config):
self.persist_filename = os.path.join(
config.data_path, "%s.bpickle" % self.service_name)
super(MonitorService, self).__init__(config)
self.plugins = self.get_plugins()
self.monitor = Monitor(self.reactor, self.config, self.persist,
persist_filename=self.persist_filename)
self.publisher = ComponentPublisher(self.monitor, self.reactor,
self.config)

def get_plugins(self):
return [namedClass("landscape.monitor.%s.%s"
% (plugin_name.lower(), plugin_name))()
for plugin_name in self.config.plugin_factories]

def startService(self):
"""Start the monitor."""
super(MonitorService, self).startService()
self.publisher.start()

def start_plugins(broker):
self.broker = broker
self.monitor.broker = broker
for plugin in self.plugins:
self.monitor.add(plugin)
return self.broker.register_client(self.service_name)

self.connector = RemoteBrokerConnector(self.reactor, self.config)
connected = self.connector.connect()
return connected.addCallback(start_plugins)

def stopService(self):
"""Stop the monitor.

The monitor is flushed to ensure that things like persist databases
get saved to disk.
"""
self.publisher.stop()
self.monitor.flush()
self.connector.disconnect()
super(MonitorService, self).stopService()


def run(args):
run_landscape_service(MonitorConfiguration, MonitorService, args)