VMware {code} Community
Mflood
Contributor
Contributor

Java SDK ~ How to get last powered on date of VM

I've been searching the MOB to get info on the last time a VM has been powered on, without much luck. I've tried finding the last modified date to the VMDK through the MOB, and other ways, but I'm at a loss. Can anyone point me in the right direction?

 

Thanks!

0 Kudos
1 Reply
doskiran
Enthusiast
Enthusiast

Data Object - VirtualMachineRuntimeInfo(vim.vm.RuntimeInfo) 
The RuntimeInfo data object type provides information about the execution state and history of a virtual machine.

Properties:

bootTime*xsd:dateTime

 

The timestamp when the virtual machine was most recently powered on.

This property is updated when the virtual machine is powered on from the poweredOff state, and is cleared when the virtual machine is powered off. This property is not updated when a virtual machine is resumed from a suspended state.

 

Sample code:
-----------------

 

VirtualMachine vm = (VirtualMachine) new InventoryNavigator(si.getRootFolder())
.searchManagedEntity("VirtualMachine", "<VM_Name>");
System.out.println("Recently poweredOn Date::" + vm.getRuntime().getBootTime().getTime());

 

 

Another option is to get from the Even history.

0 Kudos