Beispiel #1
0
def main():
    """Main entry point for Glances.

    Select the mode (standalone, client or server)
    Run it...
    """
    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Log Glances and psutil version
    logger.info('Start Glances {}'.format(__version__))
    logger.info('{} {} and psutil {} detected'.format(
        platform.python_implementation(), platform.python_version(),
        psutil_version))

    # Share global var
    global core

    # Create the Glances main instance
    core = GlancesMain()
    config = core.get_config()
    args = core.get_args()

    # Glances can be ran in standalone, client or server mode
    start(config=config, args=args)
Beispiel #2
0
def main():
    """Main entry point for Glances.

    Select the mode (standalone, client or server)
    Run it...
    """
    # Log Glances and PSutil version
    logger.info('Start Glances {}'.format(__version__))
    logger.info('{} {} and PSutil {} detected'.format(
        platform.python_implementation(),
        platform.python_version(),
        psutil_version))

    # Share global var
    global core

    # Create the Glances main instance
    core = GlancesMain()
    config = core.get_config()
    args = core.get_args()

    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Glances can be ran in standalone, client or server mode
    start(config=config, args=args)
Beispiel #3
0
def main():
    """Main entry point for Glances.

    Select the mode (standalone, client or server)
    Run it...
    """
    # Log Glances and PSutil version
    logger.info('Start Glances {}'.format(__version__))
    logger.info('{} {} and PSutil {} detected'.format(
        platform.python_implementation(),
        platform.python_version(),
        psutil_version))

    # Share global var
    global core

    # Create the Glances main instance
    core = GlancesMain()
    config = core.get_config()
    args = core.get_args()

    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Glances can be ran in standalone, client or server mode
    if core.is_standalone() and not WINDOWS:
        start_standalone(config=config, args=args)
    elif core.is_client() and not WINDOWS:
        if core.is_client_browser():
            start_clientbrowser(config=config, args=args)
        else:
            start_client(config=config, args=args)
    elif core.is_server():
        start_server(config=config, args=args)
    elif core.is_webserver() or (core.is_standalone() and WINDOWS):
        # Web server mode replace the standalone mode on Windows OS
        # In this case, try to start the web browser mode automaticaly
        if core.is_standalone() and WINDOWS:
            args.open_web_browser = True
        start_webserver(config=config, args=args)
Beispiel #4
0
def main():
    """Main entry point for Glances.

    Select the mode (standalone, client or server)
    Run it...
    """
    # Log Glances and PSutil version
    logger.info('Start Glances {0}'.format(__version__))
    logger.info('{0} {1} and PSutil {2} detected'.format(
        platform.python_implementation(), platform.python_version(),
        __psutil_version))

    # Share global var
    global core, standalone, client, server, webserver

    # Create the Glances main instance
    core = GlancesMain()

    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Glances can be ran in standalone, client or server mode
    if core.is_standalone():
        logger.info("Start standalone mode")

        # Import the Glances standalone module
        from glances.standalone import GlancesStandalone

        # Init the standalone mode
        standalone = GlancesStandalone(config=core.get_config(),
                                       args=core.get_args())

        # Start the standalone (CLI) loop
        standalone.serve_forever()

    elif core.is_client():
        if core.is_client_browser():
            logger.info("Start client mode (browser)")

            # Import the Glances client browser module
            from glances.client_browser import GlancesClientBrowser

            # Init the client
            client = GlancesClientBrowser(config=core.get_config(),
                                          args=core.get_args())

        else:
            logger.info("Start client mode")

            # Import the Glances client module
            from glances.client import GlancesClient

            # Init the client
            client = GlancesClient(config=core.get_config(),
                                   args=core.get_args())

            # Test if client and server are in the same major version
            if not client.login():
                logger.critical(
                    "The server version is not compatible with the client")
                sys.exit(2)

        # Start the client loop
        client.serve_forever()

        # Shutdown the client
        client.end()

    elif core.is_server():
        logger.info("Start server mode")

        # Import the Glances server module
        from glances.server import GlancesServer

        args = core.get_args()

        server = GlancesServer(cached_time=core.cached_time,
                               config=core.get_config(),
                               args=args)
        print('Glances server is running on {0}:{1}'.format(
            args.bind_address, args.port))

        # Set the server login/password (if -P/--password tag)
        if args.password != "":
            server.add_user(args.username, args.password)

        # Start the server loop
        server.serve_forever()

        # Shutdown the server?
        server.server_close()

    elif core.is_webserver():
        logger.info("Start web server mode")

        # Import the Glances web server module
        from glances.webserver import GlancesWebServer

        # Init the web server mode
        webserver = GlancesWebServer(config=core.get_config(),
                                     args=core.get_args())

        # Start the web server loop
        webserver.serve_forever()
Beispiel #5
0
from glances.thresholds import GlancesThresholdOk
from glances.thresholds import GlancesThresholdCareful
from glances.thresholds import GlancesThresholdWarning
from glances.thresholds import GlancesThresholdCritical
from glances.thresholds import GlancesThresholds
from glances.plugins.glances_plugin import GlancesPlugin
from glances.compat import subsample, range

# Global variables
# =================

# Init Glances core
core = GlancesMain()

# Init Glances stats
stats = GlancesStats(config=core.get_config(), args=core.get_args())

# Unitest class
# ==============
print('Unitary tests for Glances %s' % __version__)


class TestGlances(unittest.TestCase):
    """Test Glances class."""
    def setUp(self):
        """The function is called *every time* before test_*."""
        print('\n' + '=' * 78)

    def test_000_update(self):
        """Update stats (mandatory step for all the stats).
Beispiel #6
0
def main():
    """Main entry point for Glances.

    Select the mode (standalone, client or server)
    Run it...
    """
    # Log Glances and PSutil version
    logger.info('Start Glances {0}'.format(__version__))
    logger.info('{0} {1} and PSutil {2} detected'.format(
        platform.python_implementation(),
        platform.python_version(),
        psutil_version))

    # Share global var
    global core, standalone, client, server, webserver

    # Create the Glances main instance
    core = GlancesMain()

    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Glances can be ran in standalone, client or server mode
    if core.is_standalone():
        logger.info("Start standalone mode")

        # Import the Glances standalone module
        from glances.standalone import GlancesStandalone

        # Init the standalone mode
        standalone = GlancesStandalone(config=core.get_config(),
                                       args=core.get_args())

        # Start the standalone (CLI) loop
        standalone.serve_forever()

    elif core.is_client():
        if core.is_client_browser():
            logger.info("Start client mode (browser)")

            # Import the Glances client browser module
            from glances.client_browser import GlancesClientBrowser

            # Init the client
            client = GlancesClientBrowser(config=core.get_config(),
                                          args=core.get_args())

        else:
            logger.info("Start client mode")

            # Import the Glances client module
            from glances.client import GlancesClient

            # Init the client
            client = GlancesClient(config=core.get_config(),
                                   args=core.get_args())

            # Test if client and server are in the same major version
            if not client.login():
                logger.critical("The server version is not compatible with the client")
                sys.exit(2)

        # Start the client loop
        client.serve_forever()

        # Shutdown the client
        client.end()

    elif core.is_server():
        logger.info("Start server mode")

        # Import the Glances server module
        from glances.server import GlancesServer

        args = core.get_args()

        server = GlancesServer(cached_time=core.cached_time,
                               config=core.get_config(),
                               args=args)
        print('Glances server is running on {0}:{1}'.format(args.bind_address, args.port))

        # Set the server login/password (if -P/--password tag)
        if args.password != "":
            server.add_user(args.username, args.password)

        # Start the server loop
        server.serve_forever()

        # Shutdown the server?
        server.server_close()

    elif core.is_webserver():
        logger.info("Start web server mode")

        # Import the Glances web server module
        from glances.webserver import GlancesWebServer

        # Init the web server mode
        webserver = GlancesWebServer(config=core.get_config(),
                                     args=core.get_args())

        # Start the web server loop
        webserver.serve_forever()
Beispiel #7
0
from glances.thresholds import GlancesThresholdWarning
from glances.thresholds import GlancesThresholdCritical
from glances.thresholds import GlancesThresholds
from glances.plugins.glances_plugin import GlancesPlugin
from glances.compat import subsample, range

# Global variables
# =================


# Init Glances core
core = GlancesMain()

# Init Glances stats
stats = GlancesStats(config=core.get_config(),
                     args=core.get_args())

# Unitest class
# ==============
print('Unitary tests for Glances %s' % __version__)


class TestGlances(unittest.TestCase):
    """Test Glances class."""

    def setUp(self):
        """The function is called *every time* before test_*."""
        print('\n' + '=' * 78)

    def test_000_update(self):
        """Update stats (mandatory step for all the stats).