Exemplo n.º 1
0
def action_legacy():
    projects_count = kc.get_project_count('dataporten')
    users_count = kc.get_user_count('dataporten')

    stats = dict()
    stats['users'] = {}
    stats['projects'] = {}
    stats['instances'] = {}
    stats['instances']['total'] = {'count': 0, 'error': 0}

    for region in regions:
        logger.debug('=> count region %s' % region)

        # Projects and users (this will be the same for all regions)
        stats['projects'][region] = {}
        stats['projects']['total'] = {}
        stats['projects'][region]['count'] = projects_count
        stats['projects']['total']['count'] = projects_count
        stats['users'][region] = {}
        stats['users']['total'] = {}
        stats['users'][region]['count'] = users_count
        stats['users']['total']['count'] = users_count

        # Instances
        novaclient = Nova(options.config, debug=options.debug, region=region, log=logger)
        novastats = novaclient.get_stats()
        stats['instances'][region] = {}
        stats['instances'][region]['count'] = novastats['count']
        stats['instances'][region]['error'] = novastats['error']
        stats['instances']['total']['count'] += novastats['count']
        stats['instances']['total']['error'] += novastats['error']

    for t, s in stats.iteritems():
        for r, d in s.iteritems():
            name = '%s.%s' % (r, t)
            count = d['count']
            if not options.quiet:
                print '%s = %s' % (name, count)
            statsd.gauge(name, count)
            if 'error' in d:
                name = '%s.instance_errors' % (r)
                if not options.quiet:
                    print '%s = %s' % (name, d['error'])
                statsd.gauge(name, d['error'])
Exemplo n.º 2
0
def action_legacy():
    projects_count = kc.get_project_count('dataporten')
    users_count = kc.get_user_count('dataporten')

    stats = dict()
    stats['users'] = {}
    stats['projects'] = {}
    stats['instances'] = {}
    stats['instances']['total'] = {'count': 0, 'error': 0}

    for region in regions:
        logger.debug('=> count region %s' % region)

        # Projects and users (this will be the same for all regions)
        stats['projects'][region] = {}
        stats['projects']['total'] = {}
        stats['projects'][region]['count'] = projects_count
        stats['projects']['total']['count'] = projects_count
        stats['users'][region] = {}
        stats['users']['total'] = {}
        stats['users'][region]['count'] = users_count
        stats['users']['total']['count'] = users_count

        # Instances
        novaclient = Nova(options.config, debug=options.debug, region=region, log=logger)
        novastats = novaclient.get_stats()
        stats['instances'][region] = {}
        stats['instances'][region]['count'] = novastats['count']
        stats['instances'][region]['error'] = novastats['error']
        stats['instances']['total']['count'] += novastats['count']
        stats['instances']['total']['error'] += novastats['error']

    for t, s in stats.iteritems():
        for r, d in s.iteritems():
            name = '%s.%s' % (r, t)
            count = d['count']
            if not options.quiet:
                print '%s = %s' % (name, count)
            statsd.gauge(name, count)
            if 'error' in d:
                name = '%s.instance_errors' % (r)
                if not options.quiet:
                    print '%s = %s' % (name, d['error'])
                statsd.gauge(name, d['error'])
Exemplo n.º 3
0
stats['users'][keystoneclient.region] = {}
stats['users'][keystoneclient.region]['count'] = users_count

server = keystoneclient.get_config('statsd', 'server')
port = keystoneclient.get_config('statsd', 'port')

# Regions
regions = himutils.load_region_config('config/stats',
                                      region=keystoneclient.region,
                                      log=logger)

# Instances
for name, info in sorted(regions['regions'].iteritems()):
    logger.debug('=> count region %s' % name)
    novaclient = Nova(options.config, debug=options.debug, region=name)
    novastats = novaclient.get_stats()
    stats['instances'][name] = {}
    stats['instances'][name]['count'] = novastats['count']
    stats['instances'][name]['error'] = novastats['error']
    stats['instances']['total']['count'] += novastats['count']
    stats['instances']['total']['error'] += novastats['error']

prefix = 'uh-iaas'
c = statsd.StatsClient(server, port, prefix=prefix)
for t, s in stats.iteritems():
    for r, d in s.iteritems():
        name = '%s.%s' % (r, t)
        count = d['count']
        print '%s = %s' % (name, count)
        c.gauge(name, count)
        if 'error' in d: