VMware

cpqarray

cpqarray's Profile

  • Name: John Tuffin 
  • Email: jtuffin@vmware.com
  • Member Since: Nov 24, 2005
  • Last Logged In: Aug 17, 2009 7:05 AM
  • Status Level: Expert Expert (1,364 points)
  • VMware Employee: VMware Yes
  • Location: Houston, TX
  • Occupation: Trainer

cpqarray's Latest Content

Get-stat in John Tuffin's Blog

Posted by cpqarray VMware Jul 21, 2008 0 Comments

I've been playing around with the get-stat command. Thanks a bunch to Brian Denicola at http://www.bjd145.org/labels/vmware%20powershell.html for posting the example.

To grab memory stats from an ESX host type the command get-stat $esx -Memory -maxsamples 3 -realtime this will grab 3 memory samples from the server $esx.

For example

$vc = get-viserver myvcserver -username admin -password vmware
$esx = get-vmhost MyEsxServer
$get-stat $esx -Memory -maxsamples 3 -realtime
The -common switch gives averages for all major hardware subsystems cpu,memory, disk, and networking.

$get-stat $esx -common -maxsamples 1 -realtime
There is also a way to pull individual counters provided that you know the counter name

get-stat $esx -stat cpu.usagemhz.average
This returns the average cpu usage in MHZ over the interval of collection. The list of all counters can be found here:

http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/visdk25programmingguide.pdf

0 Comments Permalink


This is cool becasue so often I've wanted to modify the boot order of a virtual machine and this little bit of code allows you to do it. I can't remember where I found it now so I can't give credit but thanks to the poster that put this up in the forums.

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.extraConfig += New-Object VMware.Vim.OptionValue $spec.extraConfig[0].key = "bios.bootDeviceClasses" $spec.extraConfig[0].value = "allow:cd,hd" (get-view (Get-VM -Name <VM-name>).ID).ReconfigVM_Task($spec)

0 Comments Permalink

If you're not reading the forum for the VMware VI Toolkit Beta you are missing out on just a goldmine of useful information. Take this post from LUCD. This will allow you to query the ESX host for it's current time. This another one of those instances where there is no applet in the toolkit to do this so you hook into the API to get the information.

Get-VIServer -Server <Replace with yourServer Name>

http://Reflection.Assembly::LoadWithPartialName("vmware.vim")

$svcRef = new-object VMware.Vim.ManagedObjectReference

$svcRef.Type = "ServiceInstance"

$svcRef.Value = "ServiceInstance"

$serviceInstance = get-view $svcRef

$datetime = $serviceInstance.ServerClock

*
Write-Host $datetime

*

0 Comments Permalink

Write your own drafts, invite selected collaborators, or leave it open for all to pitch in.

Communities