From 36cc7ea3fea1ca61f8bd3ad321c455ff399bb4bb Mon Sep 17 00:00:00 2001 From: Scott Schneider Date: Fri, 20 Dec 2013 11:41:44 -0800 Subject: [PATCH] Don't fail if graphite stats found for unconfigured pools --- vmware-host-pooler-api | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/vmware-host-pooler-api b/vmware-host-pooler-api index 200f84b..78aa2f0 100755 --- a/vmware-host-pooler-api +++ b/vmware-host-pooler-api @@ -68,16 +68,19 @@ get '/dashboard/stats/vcloud/pool' do history.each do |pool| if pool['target'] =~ /.*\.(.*)$/ pool['name'] = $1 - pool['last'] = result[pool['name']]['size'] - result[pool['name']]['history'] ||= Array.new - pool['datapoints'].each do |metric| - 8.times do |n| - if ( metric[0] ) - pool['last'] = metric[0].to_i - result[pool['name']]['history'].push( metric[0].to_i ) - else - result[pool['name']]['history'].push( pool['last'] ) + if ( result[pool['name']] ) + pool['last'] = result[pool['name']]['size'] + result[pool['name']]['history'] ||= Array.new + + pool['datapoints'].each do |metric| + 8.times do |n| + if ( metric[0] ) + pool['last'] = metric[0].to_i + result[pool['name']]['history'].push( metric[0].to_i ) + else + result[pool['name']]['history'].push( pool['last'] ) + end end end end