From 4faeb6a9ba9d4bfcd55616a450bcace1f48de53d Mon Sep 17 00:00:00 2001 From: "kirby@puppetlabs.com" Date: Tue, 22 Nov 2016 15:02:19 -0800 Subject: [PATCH] (POOLER-44) Fix vmpooler.migrate reference This commit updates vmpooler.migrate metric to send the pool name. Without this change the VM name is sent. Additionally, counts are added for migrate_from_#host and migrate_to_#host in order to allow tracking host migrations, and correlating them with CPU ready time changes. --- lib/vmpooler/pool_manager.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/vmpooler/pool_manager.rb b/lib/vmpooler/pool_manager.rb index 939d7bc..bc49952 100644 --- a/lib/vmpooler/pool_manager.rb +++ b/lib/vmpooler/pool_manager.rb @@ -506,7 +506,7 @@ module Vmpooler if host == parent_host $logger.log('s', "[ ] [#{pool}] No migration required for '#{vm}' running on #{parent_host_name}") else - finish = migrate_vm_and_record_timing(vm_object, vm, host, vsphere) + finish = migrate_vm_and_record_timing(vm_object, vm, pool, host, parent_host_name, host_name, vsphere) $logger.log('s', "[>] [#{pool}] '#{vm}' migrated from #{parent_host_name} to #{host_name} in #{finish} seconds") end remove_vmpooler_migration_vm(pool, vm) @@ -531,11 +531,13 @@ module Vmpooler end end - def migrate_vm_and_record_timing(vm_object, vm_name, host, vsphere) + def migrate_vm_and_record_timing(vm_object, vm_name, pool, host, source_host_name, dest_host_name, vsphere) start = Time.now vsphere.migrate_vm_host(vm_object, host) finish = '%.2f' % (Time.now - start) - $metrics.timing("migrate.#{vm_name}", finish) + $metrics.timing("migrate.#{pool}", finish) + $metrics.increment("migrate_from.#{source_host_name}") + $metrics.increment("migrate_to.#{dest_host_name}") checkout_to_migration = '%.2f' % (Time.now - Time.parse($redis.hget("vmpooler__vm__#{vm_name}", 'checkout'))) $redis.hset("vmpooler__vm__#{vm_name}", 'migration_time', finish) $redis.hset("vmpooler__vm__#{vm_name}", 'checkout_to_migration', checkout_to_migration)