From 2bcd7181e333fa99d840d2b93f494ff5c7b44777 Mon Sep 17 00:00:00 2001 From: sergiojvg Date: Fri, 22 Mar 2019 03:27:51 -0600 Subject: [PATCH] F #2968: Monitor cluster health (#3089) * F #2968: Monitor cluster health Signed-off-by: Sergio Vega * F #2968: Set cluster to error if vcenter health is red Signed-off-by: Sergio Vega (cherry picked from commit c1ce6bb5f94a636f9b32c1b575c77353fb688e49) --- src/im_mad/remotes/vcenter.d/poll | 5 ++++- src/vmm_mad/remotes/lib/vcenter_driver/host.rb | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/im_mad/remotes/vcenter.d/poll b/src/im_mad/remotes/vcenter.d/poll index b19ee97810..8d676d3bb7 100755 --- a/src/im_mad/remotes/vcenter.d/poll +++ b/src/im_mad/remotes/vcenter.d/poll @@ -49,7 +49,10 @@ begin cluster = VCenterDriver::ClusterComputeResource.new_from_ref(ccr_ref, vi_client) # Print monitoring info - puts cluster.monitor + cluster_info = cluster.monitor + puts cluster_info + raise "vCenter cluster health is on red, check issues on vCenter" if cluster_info.include?("STATUS=red") + puts cluster.monitor_host_systems # Print VM monitor info diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/host.rb b/src/vmm_mad/remotes/lib/vcenter_driver/host.rb index afba5df09c..7ce13e92b2 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/host.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/host.rb @@ -101,13 +101,15 @@ class ClusterComputeResource total_memory, effective_mem, num_hosts, - num_eff_hosts = @item.collect("summary.totalCpu", + num_eff_hosts, + overall_status = @item.collect("summary.totalCpu", "summary.numCpuCores", "summary.effectiveCpu", "summary.totalMemory", "summary.effectiveMemory", "summary.numHosts", - "summary.numEffectiveHosts" + "summary.numEffectiveHosts", + "summary.overallStatus" ) mhz_core = total_cpu.to_f / num_cpu_cores.to_f @@ -129,6 +131,7 @@ class ClusterComputeResource str_info << "HYPERVISOR=vcenter\n" str_info << "TOTALHOST=" << num_hosts.to_s << "\n" str_info << "AVAILHOST=" << num_eff_hosts.to_s << "\n" + str_info << "STATUS=" << overall_status << "\n" # CPU str_info << "CPUSPEED=" << mhz_core.to_s << "\n"