Révision 33cff547
Add autoconf and enhance graphs
| plugins/keystone/keystone_stats | ||
|---|---|---|
| 8 | 8 |
# |
| 9 | 9 |
# Magic markers |
| 10 | 10 |
#%# capabilities=autoconf |
| 11 |
#%# family=keystone
|
|
| 11 |
#%# family=auto
|
|
| 12 | 12 |
|
| 13 | 13 |
import sys |
| 14 |
import traceback |
|
| 15 |
|
|
| 16 |
try: |
|
| 17 |
from keystone.common import utils |
|
| 18 |
from keystone import config |
|
| 19 |
from keystone import exception |
|
| 20 |
from keystone import identity |
|
| 21 |
except ImportError: |
|
| 22 |
succesful_import = False |
|
| 23 |
else: |
|
| 24 |
succesful_import = True |
|
| 14 | 25 |
|
| 15 |
from keystone.common import utils |
|
| 16 |
from keystone import config |
|
| 17 |
from keystone import exception |
|
| 18 |
from keystone import identity |
|
| 19 | 26 |
|
| 20 | 27 |
CONF = config.CONF |
| 21 | 28 |
|
| ... | ... | |
| 78 | 85 |
for (field, value) in stats[state].iteritems(): |
| 79 | 86 |
print "%s_%s.value %s" % (field, state, value) |
| 80 | 87 |
|
| 88 |
def load_conf(): |
|
| 89 |
CONF(config_files=[utils.find_config('keystone.conf')])
|
|
| 81 | 90 |
|
| 82 | 91 |
if __name__ == '__main__': |
| 83 | 92 |
if len(sys.argv) > 1: |
| 84 | 93 |
if sys.argv[1] == "config": |
| 85 | 94 |
print_config() |
| 86 | 95 |
elif sys.argv[1] == "autoconf": |
| 87 |
print "yes" |
|
| 88 |
else: |
|
| 89 |
CONF(config_files=[utils.find_config('keystone.conf')])
|
|
| 96 |
if not succesful_import: |
|
| 97 |
print 'no (failed import keystone module)' |
|
| 98 |
sys.exit(0) |
|
| 99 |
try: |
|
| 100 |
load_conf() |
|
| 101 |
identity.Manager() |
|
| 102 |
except: |
|
| 103 |
print 'no (failed to connect keystone backend: %s'%traceback.format_exc() |
|
| 104 |
sys.exit(0) |
|
| 105 |
print 'yes' |
|
| 106 |
|
|
| 107 |
elif succesful_import: |
|
| 108 |
load_conf() |
|
| 90 | 109 |
print_values() |
| 91 | 110 |
|
| plugins/nova/nova_floating_ips | ||
|---|---|---|
| 12 | 12 |
# |
| 13 | 13 |
# Magic markers |
| 14 | 14 |
#%# capabilities=autoconf |
| 15 |
#%# family=nova
|
|
| 15 |
#%# family=auto
|
|
| 16 | 16 |
|
| 17 |
from nova import context |
|
| 18 |
from nova import db |
|
| 19 |
from nova import flags |
|
| 20 |
from nova import utils |
|
| 21 | 17 |
import sys |
| 22 | 18 |
|
| 23 |
states = ['total', 'allocated', 'associated'] |
|
| 19 |
try: |
|
| 20 |
from nova import context |
|
| 21 |
from nova import db |
|
| 22 |
from nova import flags |
|
| 23 |
from nova import utils |
|
| 24 |
except ImportError: |
|
| 25 |
succesful_import = False |
|
| 26 |
else: |
|
| 27 |
succesful_import = True |
|
| 28 |
|
|
| 24 | 29 |
|
| 25 | 30 |
|
| 31 |
states = ['total', 'allocated', 'associated'] |
|
| 32 |
|
|
| 26 | 33 |
def print_config(): |
| 27 | 34 |
global states |
| 28 | 35 |
print 'graph_title Nova Floating IPs' |
| 29 |
print 'graph_vlabel %'
|
|
| 36 |
print 'graph_vlabel IPs'
|
|
| 30 | 37 |
print 'graph_args --base 1000 --lower-limit 0' |
| 31 | 38 |
print 'graph_category nova' |
| 32 | 39 |
print 'graph_scale no' |
| ... | ... | |
| 65 | 72 |
if sys.argv[1] == "config": |
| 66 | 73 |
print_config() |
| 67 | 74 |
elif sys.argv[1] == "autoconf": |
| 68 |
print "yes" |
|
| 69 |
else: |
|
| 75 |
if not succesful_import: |
|
| 76 |
print 'no (failed import nova module)' |
|
| 77 |
sys.exit(0) |
|
| 78 |
else: |
|
| 79 |
print 'yes' |
|
| 80 |
elif succesful_import: |
|
| 70 | 81 |
utils.default_flagfile() |
| 71 | 82 |
flags.FLAGS(sys.argv) |
| 72 | 83 |
print_values() |
| plugins/nova/nova_instance_ | ||
|---|---|---|
| 11 | 11 |
# user nova |
| 12 | 12 |
# |
| 13 | 13 |
# Magic markers |
| 14 |
#%# capabilities=autoconf |
|
| 15 |
#%# family=nova
|
|
| 14 |
#%# capabilities=autoconf suggest
|
|
| 15 |
#%# family=auto
|
|
| 16 | 16 |
|
| 17 |
from nova import context |
|
| 18 |
from nova import db |
|
| 19 |
from nova import flags |
|
| 20 |
from nova import utils |
|
| 21 | 17 |
import sys |
| 22 | 18 |
|
| 19 |
try: |
|
| 20 |
from nova import context |
|
| 21 |
from nova import db |
|
| 22 |
from nova import flags |
|
| 23 |
from nova import utils |
|
| 24 |
from nova.compute import power_state |
|
| 25 |
except ImportError: |
|
| 26 |
succesful_import = False |
|
| 27 |
else: |
|
| 28 |
succesful_import = True |
|
| 29 |
|
|
| 23 | 30 |
|
| 24 | 31 |
class InstanceState(object): |
| 25 | 32 |
instance_counts = None |
| ... | ... | |
| 33 | 40 |
instances = db.instance_get_all(ctxt) |
| 34 | 41 |
cls.instance_counts = {}
|
| 35 | 42 |
instance_types = {}
|
| 36 |
for it in db.instance_type_get_all(ctxt, True).values():
|
|
| 43 |
for it in db.instance_type_get_all(ctxt, True): |
|
| 37 | 44 |
instance_types[it['id']] = it['name'] |
| 38 | 45 |
|
| 39 |
if metric == 'state': |
|
| 40 |
metric = 'state_description' |
|
| 41 |
|
|
| 42 | 46 |
for instance in instances: |
| 43 | 47 |
i = dict(instance) |
| 44 | 48 |
i['instance_type'] = i['type'] = instance_types.get( |
| ... | ... | |
| 58 | 62 |
InstanceState.init(metric) |
| 59 | 63 |
return cls.instance_counts |
| 60 | 64 |
|
| 65 |
def get_name(metric, code): |
|
| 66 |
if metric == "power_state": |
|
| 67 |
return power_state.name(code) |
|
| 68 |
elif metric in ["root_gb", "ephemeral_gb"]: |
|
| 69 |
return "%d_gb", code |
|
| 70 |
else: |
|
| 71 |
return code |
|
| 61 | 72 |
|
| 62 | 73 |
def print_config(metric): |
| 63 | 74 |
states = InstanceState.get_states(metric) |
| 64 |
print 'graph_title Nova Instance States'
|
|
| 75 |
print 'graph_title Nova Instance %s' % metric
|
|
| 65 | 76 |
print 'graph_vlabel instances' |
| 66 | 77 |
print 'graph_args --base 1000 --lower-limit 0' |
| 67 | 78 |
print 'graph_category nova' |
| 68 | 79 |
print 'graph_scale no' |
| 69 |
print 'graph_info This graph shows the number of instances by state'
|
|
| 80 |
print 'graph_info This graph shows the number of instances by %s' % metric
|
|
| 70 | 81 |
for state in states: |
| 71 |
print '%s.label %s' % (state, state)
|
|
| 82 |
print '%s.label %s' % (state, get_name(state))
|
|
| 72 | 83 |
print '%s.draw LINE2' % state |
| 73 | 84 |
print '%s.info %s IPs' % (state, state) |
| 74 | 85 |
|
| ... | ... | |
| 78 | 89 |
for (state, value) in status.iteritems(): |
| 79 | 90 |
print '%s.value %s' % (state, value) |
| 80 | 91 |
|
| 92 |
def print_suggest(): |
|
| 93 |
suggest = [ "vm_state", |
|
| 94 |
"vcpus", |
|
| 95 |
"task_state", |
|
| 96 |
"root_gb", |
|
| 97 |
"ephemeral_gb", |
|
| 98 |
"power_state", |
|
| 99 |
"memory_mb", |
|
| 100 |
"instance_type_id", |
|
| 101 |
] |
|
| 102 |
print "\n".join(suggest) |
|
| 103 |
|
|
| 81 | 104 |
|
| 82 | 105 |
if __name__ == '__main__': |
| 83 | 106 |
argv = sys.argv[:] |
| 84 | 107 |
utils.default_flagfile() |
| 85 | 108 |
flags.FLAGS(sys.argv) |
| 86 |
metric = argv[0].split('nova_instance_').pop() or 'state'
|
|
| 109 |
metric = argv[0].split('nova_instance_').pop() or 'vm_state'
|
|
| 87 | 110 |
|
| 88 | 111 |
if len(argv) > 1: |
| 89 | 112 |
if argv[1] == 'config': |
| 90 | 113 |
print_config(metric) |
| 114 |
elif argv[1] == 'suggest': |
|
| 115 |
print_suggest() |
|
| 91 | 116 |
elif argv[1] == 'autoconf': |
| 92 |
print 'yes' |
|
| 93 |
else: |
|
| 117 |
if not succesful_import: |
|
| 118 |
print 'no (failed import nova module)' |
|
| 119 |
sys.exit(0) |
|
| 120 |
else: |
|
| 121 |
print 'yes' |
|
| 122 |
elif succesful_import: |
|
| 94 | 123 |
print_values(metric) |
| plugins/nova/nova_instance_launched | ||
|---|---|---|
| 12 | 12 |
# |
| 13 | 13 |
# Magic markers |
| 14 | 14 |
#%# capabilities=autoconf |
| 15 |
#%# family=nova
|
|
| 15 |
#%# family=auto
|
|
| 16 | 16 |
|
| 17 |
from nova import context |
|
| 18 |
from nova import db |
|
| 19 |
from nova import flags |
|
| 20 |
from nova import utils |
|
| 21 |
from nova.db.sqlalchemy.session import get_session |
|
| 22 | 17 |
import sys |
| 23 | 18 |
|
| 19 |
try: |
|
| 20 |
from nova import context |
|
| 21 |
from nova import db |
|
| 22 |
from nova import flags |
|
| 23 |
from nova import utils |
|
| 24 |
from nova.db.sqlalchemy.session import get_session |
|
| 25 |
except ImportError: |
|
| 26 |
succesful_import = False |
|
| 27 |
else: |
|
| 28 |
succesful_import = True |
|
| 29 |
|
|
| 24 | 30 |
def print_config(): |
| 25 | 31 |
global states |
| 26 | 32 |
print 'graph_title Nova Instances Launched' |
| ... | ... | |
| 46 | 52 |
if sys.argv[1] == "config": |
| 47 | 53 |
print_config() |
| 48 | 54 |
elif sys.argv[1]=="autoconf" : |
| 49 |
print "yes" |
|
| 50 |
else: |
|
| 55 |
if not succesful_import: |
|
| 56 |
print 'no (failed import nova module)' |
|
| 57 |
sys.exit(0) |
|
| 58 |
else: |
|
| 59 |
print 'yes' |
|
| 60 |
elif succesful_import: |
|
| 51 | 61 |
utils.default_flagfile() |
| 52 | 62 |
flags.FLAGS(sys.argv) |
| 53 | 63 |
print_values() |
| plugins/nova/nova_instance_timing | ||
|---|---|---|
| 12 | 12 |
# |
| 13 | 13 |
# Magic markers |
| 14 | 14 |
#%# capabilities=autoconf |
| 15 |
#%# family=nova
|
|
| 15 |
#%# family=auto
|
|
| 16 | 16 |
|
| 17 |
from nova import context |
|
| 18 |
from nova import db |
|
| 19 |
from nova import flags |
|
| 20 |
from nova import utils |
|
| 21 |
from nova.db.sqlalchemy.session import get_session |
|
| 22 | 17 |
import sys |
| 23 | 18 |
|
| 19 |
try: |
|
| 20 |
from nova import context |
|
| 21 |
from nova import db |
|
| 22 |
from nova import flags |
|
| 23 |
from nova import utils |
|
| 24 |
from nova.db.sqlalchemy.session import get_session |
|
| 25 |
except ImportError: |
|
| 26 |
succesful_import = False |
|
| 27 |
else: |
|
| 28 |
succesful_import = True |
|
| 29 |
|
|
| 24 | 30 |
|
| 25 | 31 |
def print_config(): |
| 26 | 32 |
global states |
| ... | ... | |
| 58 | 64 |
if sys.argv[1] == "config": |
| 59 | 65 |
print_config() |
| 60 | 66 |
elif sys.argv[1] == "autoconf": |
| 61 |
print "yes" |
|
| 62 |
else: |
|
| 67 |
if not succesful_import: |
|
| 68 |
print 'no (failed import nova module)' |
|
| 69 |
sys.exit(0) |
|
| 70 |
else: |
|
| 71 |
print 'yes' |
|
| 72 |
elif succesful_import: |
|
| 63 | 73 |
utils.default_flagfile() |
| 64 | 74 |
flags.FLAGS(sys.argv) |
| 65 | 75 |
print_values() |
| plugins/nova/nova_services | ||
|---|---|---|
| 8 | 8 |
# |
| 9 | 9 |
# Magic markers |
| 10 | 10 |
#%# capabilities=autoconf |
| 11 |
#%# family=nova
|
|
| 11 |
#%# family=auto
|
|
| 12 | 12 |
|
| 13 |
from nova import context |
|
| 14 |
from nova import db |
|
| 15 |
from nova import flags |
|
| 16 |
from nova import utils |
|
| 17 | 13 |
import sys |
| 18 | 14 |
|
| 15 |
try: |
|
| 16 |
from nova import context |
|
| 17 |
from nova import db |
|
| 18 |
from nova import flags |
|
| 19 |
from nova import utils |
|
| 20 |
except ImportError: |
|
| 21 |
succesful_import = False |
|
| 22 |
else: |
|
| 23 |
succesful_import = True |
|
| 24 |
|
|
| 19 | 25 |
services = ['nova-compute', 'nova-volume', 'nova-scheduler', 'nova-vncproxy', 'nova-network', 'nova-cert', 'nova-console', 'nova-consoleauth'] |
| 20 | 26 |
|
| 21 | 27 |
|
| ... | ... | |
| 70 | 76 |
if sys.argv[1] == "config": |
| 71 | 77 |
print_config() |
| 72 | 78 |
elif sys.argv[1] == "autoconf": |
| 73 |
print "yes" |
|
| 74 |
else: |
|
| 79 |
if not succesful_import: |
|
| 80 |
print 'no (failed import nova module]' |
|
| 81 |
else: |
|
| 82 |
print 'yes' |
|
| 83 |
elif succesful_import: |
|
| 75 | 84 |
utils.default_flagfile() |
| 76 | 85 |
flags.FLAGS(sys.argv) |
| 77 | 86 |
print_values() |
Formats disponibles : Unified diff