Exemple #1
0
#!/usr/bin/env python
# encode=utf-8
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Created on 2013-8-17
# Copyright 2013 nuoqingyun xuqifeng

import sys

from glance import log as logging

LOG = logging.getLogger(__name__)

# Somes libs depends of OS
is_BSD = sys.platform.find("bsd") != -1
is_Linux = sys.platform.startswith("linux")
is_Mac = sys.platform.startswith("darwin")
is_Windows = sys.platform.startswith("win")


try:
    # psutil is the main library used to grab stats
    import psutil
except ImportError:
    LOG.warning("PsUtil module not found. Glances cannot start.")
    sys.exit(1)

psutil_version = tuple([int(num) for num in psutil.__version__.split(".")])
# this is not a mistake: psutil 0.5.1 is detected as 0.5.0
if psutil_version < (0, 5, 0):
    LOG.warning("PsUtil version %s detected." % psutil.__version__)
Exemple #2
0
               default=60,
               help='check system per 1 minute'),
    cfg.StrOpt('server_key',
               default='0.0.0.0',
               help='The passport for glance.'),
    cfg.ListOpt('GlanceSystemList',
                default=['cpu', 'network', 'memory', 'disk', 'loadavg'],
                help='The lsit  for glance.'),
]

CONF = cfg.CONF
CONF.register_opts(glanceagent_opts)
#CONF(project = 'glance')

logging.setup("glance")
LOG = logging.getLogger("glance")
PIDFILE = '/var/run/glance.pid'


class GlanceAgentDaemon(Daemon):
    def __init__(self):
        self.server_key = CONF.server_key
        super(GlanceAgentDaemon, self).__init__(PIDFILE)
        self.glanceagentapi = GlanceAgentAPI()

    def start(self):
        try:
            self.glanceagentapi.getServer(self.server_key)
        except:
            LOG.exception("Get server  info failed")
        super(GlanceAgentDaemon, self).start()
Exemple #3
0
#!/usr/bin/env python
#encode=utf-8
#vim: tabstop=4 shiftwidth=4 softtabstop=4

#Created on 2013-8-17
#Copyright 2013 nuoqingyun xuqifeng

import sys
import time
from  datetime import datetime, timedelta
from glance import log as logging

LOG = logging.getLogger(__name__)

# Somes libs depends of OS
is_BSD = sys.platform.find('bsd') != -1
is_Linux = sys.platform.startswith('linux')
is_Mac = sys.platform.startswith('darwin')
is_Windows = sys.platform.startswith('win')

try:
    # psutil is the main library used to grab stats
    import psutil
except ImportError:
    LOG.warning('PsUtil module not found. Glances cannot start.')
    sys.exit(1)

psutil_version = tuple([int(num) for num in psutil.__version__.split('.')])
# this is not a mistake: psutil 0.5.1 is detected as 0.5.0
if psutil_version < (0, 5, 0):
    LOG.warning('PsUtil version %s detected.' % psutil.__version__)
Exemple #4
0
        cfg.StrOpt('server_key',
                    default = '0.0.0.0',
                    help = 'The passport for glance.'),
        cfg.ListOpt('GlanceSystemList',
                    default = ['cpu', 'network', 'memory', 'disk', 'loadavg'],
                    help = 'The lsit  for glance.'),
]


CONF =  cfg.CONF
CONF.register_opts(glanceagent_opts)
#CONF(project = 'glance')


logging.setup("glance")
LOG = logging.getLogger("glance")
PIDFILE = '/var/run/glance.pid'


class GlanceAgentDaemon(Daemon):

    def __init__(self):
        self.server_key = CONF.server_key
        super(GlanceAgentDaemon, self).__init__(PIDFILE)
        self.glanceagentapi = GlanceAgentAPI()
	
    def start(self):
        try:
            self.glanceagentapi.getServer(self.server_key)
        except:
            LOG.exception("Get server  info failed")