2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Merge pull request #121 from sileht/master

Change to nova and keystone plugins
This commit is contained in:
Kenyon Ralph 2012-05-22 10:05:22 -07:00
commit 0930bf58a7
2 changed files with 39 additions and 10 deletions

View File

@ -10,26 +10,55 @@
# [glance_*] # [glance_*]
# user glance # user glance
# #
# To show tenant name plugin must run as root
#
# Magic markers # Magic markers
#%# capabilities=autoconf suggest #%# capabilities=autoconf suggest
#%# family=auto #%# family=auto
import sys import sys
import os import os
try: try:
from sqlalchemy.orm import exc, joinedload from sqlalchemy.orm import joinedload
import sqlalchemy.exc
from glance.common.cfg import CommonConfigOpts from glance.common.cfg import CommonConfigOpts
from glance.registry.db import models from glance.registry.db import models
from glance.registry.db.api import get_session, configure_db from glance.registry.db.api import get_session, configure_db
from keystone.common import utils
from keystone import config
from keystone import exception
from keystone import identity
except ImportError: except ImportError:
succesful_import = False succesful_import = False
else: else:
succesful_import = True succesful_import = True
def get_name_from_tenant(tenant):
try:
KEYSTONE_CONF = config.CONF(config_files=[utils.find_config('keystone.conf')])
except:
# keystone configuration can not be loaded, use id as name"
return tenant
identity_api = identity.Manager()
try:
tenant_info = identity_api.get_tenant(None, tenant)
except sqlalchemy.exc.OperationalError:
# keystone database can not be connected, use id as name"
return tenant
if not tenant_info:
return tenant
else:
return tenant_info["name"]
def load_conf(): def load_conf():
CONF = CommonConfigOpts(project="glance", prog="glance-registry") CONF = CommonConfigOpts(project="glance", prog="glance-registry")
CONF() CONF()
@ -41,12 +70,16 @@ def load_conf():
def print_config(tenant): def print_config(tenant):
print 'graph_title Glance used size for tenant %s' % tenant if tenant == "Global":
print 'graph_title Glance used size for all tenants'
print 'graph_info This graph shows the used size in glance for all tenants'
else:
print 'graph_title Glance used size for tenant %s' % get_name_from_tenant(tenant)
print 'graph_info This graph shows the used size in glance for tenant %s' % tenant
print 'graph_vlabel Bytes' print 'graph_vlabel Bytes'
print 'graph_args --base 1024 --lower-limit 0' print 'graph_args --base 1024 --lower-limit 0'
print 'graph_category glance' print 'graph_category glance'
print 'graph_info This graph shows the used size in glance for tenant %s' % tenant print '%s.label %s' % (tenant, get_name_from_tenant(tenant))
print '%s.label %s' % (tenant, tenant)
print '%s.draw LINE2' % tenant print '%s.draw LINE2' % tenant
print '%s.info %s MBytes' % (tenant, tenant) print '%s.info %s MBytes' % (tenant, tenant)

View File

@ -23,12 +23,8 @@ except ImportError:
else: else:
succesful_import = True succesful_import = True
CONF = config.CONF
stats = ['users', 'tenants'] stats = ['users', 'tenants']
def print_config(): def print_config():
global states global states
print 'graph_title Keystone Stats' print 'graph_title Keystone Stats'
@ -86,7 +82,7 @@ def print_values():
print "%s_%s.value %s" % (field, state, value) print "%s_%s.value %s" % (field, state, value)
def load_conf(): def load_conf():
CONF(config_files=[utils.find_config('keystone.conf')]) config.CONF(config_files=[utils.find_config('keystone.conf')])
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) > 1: if len(sys.argv) > 1: