VMware Cloud Community
RaBalder
Enthusiast
Enthusiast
Jump to solution

host performance, no updated values returned to orchestrator script...

Hope somebody can tell what I am doing wrong.

I'm still on 5.5 and tries to get load-data for ESXi-hosts (via vcenter connected to orchestrator-server) to decide on which host is best target for vmotion-action.

Since I couldn't find any builtin workflow or actions to get load-data I tried to dig it out myself via a script.

  • find all hosts
  • for each host read out the value host.summary.quickStats.overallCpuUsage

I get values, but they are static and does not get updated.

If I use perl-sdk and do the same actions towards vcenter I get updated values for each esxi-host.

Browsing the objects via web on the vcenter-server also shows these values get updated.

So only my orchestrator-workflow seems to be wrong.

I do suspect the workflow in orchestrator is only querying the Inventory and not the live objects. It is alot faster than doing the same with perl-sdk.

My small script (that could be run in a single Scriptable-task with no input/output only Log-printing). Problem can be seen by the log-printout. Total MHz used does not change in my environment.

--------------------------------CUT

var hosts = System.getModule("com.vmware.library.vc.host").getAllHostSystems() ;

var tothz = 0;

for (i in hosts){

var cpu_used = hosts[i].summary.quickStats.overallCpuUsage;

tothz = tothz+cpu_used;

}


System.log( "tothz: "+tothz);

--------------------------------CUT

Q1: Am I doing something stupid in my script?

Q2: Do I have to do some additional steps to get updated values?

Q3: Is there a better way to find performance/load-data for the ESXi-hosts?

0 Kudos
1 Solution

Accepted Solutions
RaBalder
Enthusiast
Enthusiast
Jump to solution

Pretty stupid to write the sollution myself :smileyblush:

It is possible to force an update of the inventory-values for the objects that are important to your script/workflow.

It can be done by the following function in a script.

VcPlugin.refreshObjects( object-to-update-in-inventory)

So for my specific problem, I could solve it with a simple extra line.

--------------------------------CUT

var hosts = System.getModule("com.vmware.library.vc.host").getAllHostSystems() ;

var tothz = 0;

for (i in hosts){

  VcPlugin.refreshObjects( hosts[i] )                                                   /* <<<<<< my new line */

var cpu_used = hosts[i].summary.quickStats.overallCpuUsage;

tothz = tothz+cpu_used;

}


System.log( "tothz: "+tothz);

--------------------------------CUT

This seems to force an update of the inventory values before I use them.

It will of course slow down my script a bit, but that is part of the game.

View solution in original post

0 Kudos
2 Replies
dvatov
VMware Employee
VMware Employee
Jump to solution

You can use the script from here Re: Reading configured memory of resourcepool.

0 Kudos
RaBalder
Enthusiast
Enthusiast
Jump to solution

Pretty stupid to write the sollution myself :smileyblush:

It is possible to force an update of the inventory-values for the objects that are important to your script/workflow.

It can be done by the following function in a script.

VcPlugin.refreshObjects( object-to-update-in-inventory)

So for my specific problem, I could solve it with a simple extra line.

--------------------------------CUT

var hosts = System.getModule("com.vmware.library.vc.host").getAllHostSystems() ;

var tothz = 0;

for (i in hosts){

  VcPlugin.refreshObjects( hosts[i] )                                                   /* <<<<<< my new line */

var cpu_used = hosts[i].summary.quickStats.overallCpuUsage;

tothz = tothz+cpu_used;

}


System.log( "tothz: "+tothz);

--------------------------------CUT

This seems to force an update of the inventory values before I use them.

It will of course slow down my script a bit, but that is part of the game.

0 Kudos