Пример #1
0
 def __init__(self):
     self._host = config.get('telnet', 'host')
     self._port = config.getint('telnet', 'port')
     self._locals = None
     self._logger = get_logger()
     self._telnet_server = TelnetInteractiveConsoleServer(
         self._host, self._port, self._locals)
Пример #2
0
 def __init__(self):
     self._host = config.get("telnet", "host")
     self._port = config.getint("telnet", "port")
     self._locals = None
     self._logger = get_logger()
     self._telnet_server = TelnetInteractiveConsoleServer(self._host, self._port, self._locals)
Пример #3
0
class ConsoleManager(object):
    """
    Console Manager
    """

    #----------------------------------------------------------------------
    def __init__(self):
        self._host = config.get('telnet', 'host')
        self._port = config.getint('telnet', 'port')
        self._locals = None
        self._logger = get_logger()
        self._telnet_server = TelnetInteractiveConsoleServer(
            self._host, self._port, self._locals)

    #----------------------------------------------------------------------
    def set_locals(self, locals_):
        self._locals = locals_

    #----------------------------------------------------------------------
    def get_telnet_server(self):
        return self._telnet_server

    #----------------------------------------------------------------------
    @classmethod
    def get_system_status(cls):
        monitor = SystemMonitor()
        threads = monitor.get_running_threads()
        uptime = monitor.get_uptime()
        pool = monitor.get_connection_pool()
        load = monitor.get_load_avg()
        time_usr, time_sys = monitor.get_resource_usage()
        rss = monitor.get_memory_usage()

        print 'Uptime: %s days, %s' % (uptime['uptime_days'], uptime['uptime_rest'])
        print 'Time USR: %0.2f' % time_usr
        print 'Time SYS: %0.2f' % time_sys
        print 'Memory (RSS): %0.2f MB' % (rss)
        print 'Load: %0.2f %0.2f %0.2f' % load
        print 'DB Pool: %s' % pool
        print 'Running threads:'
        for running_thread in threads:
            print '   %s' % running_thread

    #----------------------------------------------------------------------
    def _start_telnet_server(self):
        self._logger.debug(u'Telnet Console Server started')
        self._telnet_server.set_locals(self._locals)
        self._telnet_server.accept_interactions()

    #----------------------------------------------------------------------
    def serve_forever(self):
        """
        Start the telnet server
        """
        try:
            self._start_telnet_server()
        except Exception:
            self._logger.error('An error occurred', exc_info=True)
            raise

    #----------------------------------------------------------------------
    def shutdown(self):
        """Initiate shutdown of the telnet server"""
        self._logger.debug(u'Telnet Console Server stopping')
        self._telnet_server.stop()
Пример #4
0
class ConsoleManager(object):
    """
    Console Manager
    """

    # ----------------------------------------------------------------------
    def __init__(self):
        self._host = config.get("telnet", "host")
        self._port = config.getint("telnet", "port")
        self._locals = None
        self._logger = get_logger()
        self._telnet_server = TelnetInteractiveConsoleServer(self._host, self._port, self._locals)

    # ----------------------------------------------------------------------
    def set_locals(self, locals_):
        self._locals = locals_

    # ----------------------------------------------------------------------
    def get_telnet_server(self):
        return self._telnet_server

    # ----------------------------------------------------------------------
    @classmethod
    def get_system_status(cls):
        monitor = SystemMonitor()
        threads = monitor.get_running_threads()
        uptime = monitor.get_uptime()
        pool = monitor.get_connection_pool()
        load = monitor.get_load_avg()
        time_usr, time_sys = monitor.get_resource_usage()
        rss = monitor.get_memory_usage()

        print "Uptime: %s days, %s" % (uptime["uptime_days"], uptime["uptime_rest"])
        print "Time USR: %0.2f" % time_usr
        print "Time SYS: %0.2f" % time_sys
        print "Memory (RSS): %0.2f MB" % (rss)
        print "Load: %0.2f %0.2f %0.2f" % load
        print "DB Pool: %s" % pool
        print "Running threads:"
        for running_thread in threads:
            print "   %s" % running_thread

    # ----------------------------------------------------------------------
    def _start_telnet_server(self):
        self._logger.debug(u"Telnet Console Server started")
        self._telnet_server.set_locals(self._locals)
        self._telnet_server.accept_interactions()

    # ----------------------------------------------------------------------
    def serve_forever(self):
        """
        Start the telnet server
        """
        try:
            self._start_telnet_server()
        except Exception:
            self._logger.error("An error occurred", exc_info=True)
            raise

    # ----------------------------------------------------------------------
    def shutdown(self):
        """Initiate shutdown of the telnet server"""
        self._logger.debug(u"Telnet Console Server stopping")
        self._telnet_server.stop()