TheVMinator
Expert
Expert

Using vCO (vCenter Orchestrator) to monitor cluster utilization

Jump to solution

I am using Distributed Power Management (DPM).  Suppose a host is in standby mode and has been powered down by DPM because there is low utlization on the cluster.

Then, utilization picks up again.  DPM should eventually power the host back on when there is enough demand for cluster resources.

However, using VCO, I want to check every 5 minutes, and when utilization gets above x percent, make sure no ESXi hosts are still powered down.

That way if a host is powered down, and demand spikes quickly, and DPM isn't fast enough, or if a host fails to power back on when it should for whatever reason, I can use VCO to check that.

Has anyone done something like this or have a recommendation for how to impliment it?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
ChristianWehner
VMware Employee
VMware Employee

Of course there is. Here a sample:

var mailMessage = new EmailMessage();

mailMessage.smtpHost = "smtp.domain.com";

mailMessage.fromAddress = "noreply@domain.com";

mailMessage.toAddress = "customer@domain.com";

mailMessage.ccAddress = "admin@domain.com";

mailMessage.subject = "Mail Subject";

var mailText = "<html><center>This is an automated mail don't reply.</center><br /><br />";

mailText += "Here could you place your advertising ;-)<br /><br />";

mailText += "Regards,<br />";

mailText += "Your vCO Admin<br />";

mailText += "<a href='vco.domain.com'>VMware vCenter Orchestrator @ Domain.com</a></html>";

mailMessage.addMimePart(mailText,"text/html");

mailMessage.sendMessage();

You can build a scriptable task with it, but it to the code I recentry posted or built a function with it. You're free to choose Smiley Wink

Regards,

Chris

View solution in original post

0 Kudos
5 Replies
ChristianWehner
VMware Employee
VMware Employee

Hi TheVMinator,

we had very good experience with DPM and never needed a monitoring workflow.

But cause you asked for, something like this could be possible:

var myClusterOverallCpuUsage = 0;

var myClusterOverallMemoryUsage = 0;

var myVcClusterComputeResource = inputCluster // your Cluster as input or general value?!

for each ( var myVcHostSystem in myVcClusterComputeResource )

{

  if ( myVcHostSystem.runtime.powerState == "poweredOn" &&

  myVcHostSystem.runtime.inMaintenanceMode == false )

  {

  myClusterOverallCpuUsage += myVcHostSystem.summary.quickStats.overallCpuUsage;

  myClusterOverallMemoryUsage += myVcHostSystem.summary.quickStats.overallMemoryUsage;

  }

}

if ( ( myClusterOverallCpuUsage / myVcClusterComputeResource.summary.totalCpu * 100 ) >= 75 ||

     ( myClusterOverallMemoryUsage / myVcClusterComputeResource.summary.totalMemory * 100 ) >= 75 )

// if memory or cpu usage is more than 75%

{

  for each ( var myVcHostSystem in myVcClusterComputeResource )

  {

  if ( myVcHostSystem.runtime.powerState == "standBy" )

  {

  try {

  myVcHostSystem.powerUpHostFromStandBy_Task( 600 ) //Simply power up host

  } catch ( ex ) {

  throw "unable to power up host from stand by within 10 minutes";

  } finally {

  System.log( "HostSystem " + myVcHostSystem.name + " succesfully powered up from stand by" );

  }

  }

  }

}

We aren't using DPM at this time, so I wasn't able to test this.

Regards,

Chris

TheVMinator
Expert
Expert

OK great.  Is there a way to also make it send an alert email out?

0 Kudos
ChristianWehner
VMware Employee
VMware Employee

Of course there is. Here a sample:

var mailMessage = new EmailMessage();

mailMessage.smtpHost = "smtp.domain.com";

mailMessage.fromAddress = "noreply@domain.com";

mailMessage.toAddress = "customer@domain.com";

mailMessage.ccAddress = "admin@domain.com";

mailMessage.subject = "Mail Subject";

var mailText = "<html><center>This is an automated mail don't reply.</center><br /><br />";

mailText += "Here could you place your advertising ;-)<br /><br />";

mailText += "Regards,<br />";

mailText += "Your vCO Admin<br />";

mailText += "<a href='vco.domain.com'>VMware vCenter Orchestrator @ Domain.com</a></html>";

mailMessage.addMimePart(mailText,"text/html");

mailMessage.sendMessage();

You can build a scriptable task with it, but it to the code I recentry posted or built a function with it. You're free to choose Smiley Wink

Regards,

Chris

0 Kudos
TheVMinator
Expert
Expert

Great thanks again

0 Kudos
AntLeguy
Enthusiast
Enthusiast

I know it's quite late to reply, but i do have a question, and i already posted it here Monitor VMs load with Orchestrator

Like you, i want to check the load every 5 minutes, the problem is that quickStats information do not refresh that fast so i wondered if there was a way to refresh those information ?

Thanks !

0 Kudos