Periodically fetch for disk io stats
Change-Id: Id48337a598e8941d9e1793ad552251369ef3954f Signed-off-by: Julien Danjou <julien.danjou@enovance.com>
This commit is contained in:
parent
6393825cf6
commit
11a8416190
39
bin/ceilometer-nova-compute
Executable file
39
bin/ceilometer-nova-compute
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright © 2012 eNovance <licensing@enovance.com>
|
||||
#
|
||||
# Author: Julien Danjou <julien@danjou.info>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
import sys
|
||||
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import service
|
||||
from nova import utils
|
||||
|
||||
if __name__ == '__main__':
|
||||
utils.default_flagfile()
|
||||
flags.FLAGS(sys.argv)
|
||||
logging.setup()
|
||||
utils.monkey_patch()
|
||||
server = service.Service.create(binary='ceilometer-nova-compute',
|
||||
topic='ceilometer',
|
||||
manager='ceilometer.nova.manager.ComputeManager')
|
||||
service.serve(server)
|
||||
service.wait()
|
@ -16,9 +16,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from nova import log as logging
|
||||
from nova import manager
|
||||
from nova import flags
|
||||
import nova.virt.connection
|
||||
|
||||
# Import rabbit_notifier to register notification_topics flag
|
||||
import nova.notifier.rabbit_notifier
|
||||
@ -40,3 +43,25 @@ class InstanceManager(manager.Manager):
|
||||
def _on_notification(self, body):
|
||||
event_type = body.get('event_type')
|
||||
LOG.info('NOTIFICATION: %s', event_type)
|
||||
|
||||
|
||||
class ComputeManager(manager.Manager):
|
||||
def _get_disks(self, conn, instance):
|
||||
"""Get disks of an instance, only used to bypass bug#998089."""
|
||||
domain = conn._conn.lookupByName(instance)
|
||||
tree = etree.fromstring(domain.XMLDesc(0))
|
||||
return filter(bool,
|
||||
[target.get('dev') \
|
||||
for target in tree.findall('devices/disk/target')])
|
||||
|
||||
@manager.periodic_task
|
||||
def _fetch_diskio(self, context):
|
||||
if FLAGS.connection_type == 'libvirt':
|
||||
conn = nova.virt.connection.get_connection(read_only=True)
|
||||
for instance in self.db.instance_get_all_by_host(context,
|
||||
self.host):
|
||||
# TODO(jd) This does not work see bug#998089
|
||||
# for disk in conn.get_disks(instance.name):
|
||||
for disk in self._get_disks(conn, instance.name):
|
||||
stats = conn.block_stats(instance.name, disk)
|
||||
LOG.info("DISKIO USAGE: %s %s: read-requests=%d read-bytes=%d write-requests=%d write-bytes=%d errors=%d" % (instance, disk, stats[0], stats[1], stats[2], stats[3], stats[4]))
|
||||
|
Loading…
Reference in New Issue
Block a user