Posts Tagged ‘esx’

VMware ESX Snapshot & State Function

Thursday, July 16th, 2009

This function uses the (legacy) VmCom API for VBScript to connect to one or more ESX servers, enumerate the VM’s currently owned by that ESX server and determine both the VM state and whether it has any current snapshots. The ‘SENDMAIL’ flag at the end is a boolean that was used to determine if the returned data was worthy of emailing out or not (i.e. if there were any current snapshots or any VM’s were powered off, suspended, etc).

Function CheckServer(strServer)
	On Error Resume Next
	bSendMailFlag = False
	Set ConnectParams = CreateObject("VmCOM.VmConnectParams")
	ConnectParams.username = "root"
	ConnectParams.password = "password"
	ConnectParams.hostname = strServer
	Set ESXServer = CreateObject("VmCOM.VmServerCtl")

	' ----- Connect to the server -----
	ESXServer.Connect ConnectParams
	If Err.number = 0 Then
		strVMConnect =  "Connected to: " & strServer & vbCrLf
	Else
		strVMConnect =  "Error occured connecting to " & strServer & ": " & Err.Description & " (" & Err.Number & ")"
		Err.Clear
		bSendMailFlag = True
		strVMConnect = "SENDMAIL&" & strVMConnect
		CheckServer = strVMConnect
	End If

	' ---- Get a list of all VMs from the server ----
	Set vmCollection = ESXServer.RegisteredVmNames
	strVMConnect = "VMware ESX Server: " & strServer & " (Total VM's: " & vmCollection.Count & ")" & vbCrLf
	j = 1
	For Each vmObject in vmCollection
	   ConfigPath = vmCollection.Item(j)
	   ' Connect to the VM
	   Set vm = CreateObject("VmCOM.VmCtl")
	   vm.Connect ConnectParams, ConfigPath
	   If Err.Number <> 0 Then
		strVMConnect = strVMConnect &  "Could not connect to VM " & vm.ConfigFileName & ": " & Err.Description & " (" & Err.Number & ")" & vbCrLf
		Err.Clear
	   Else
		' ----- Check state of the VM ----
		Select Case vm.ExecutionState
		    Case 1
		     fVMState = "ON"
		    Case 2
		     fVMState = "OFF"
		     bSendMailFlag = True
		    Case 3
		     fVMState = "SUSPENDED"
		     bSendMailFlag = True
		    Case 4
		     fVMState = "STUCK"
		     bSendMailFlag = True
		    Case Else
		     fVMState = "UNKNOWN"
		     bSendMailFlag = True
		End Select
		' ---- Check if the VM has snapshots or not ----
		If vm.HasSnapshot Then
			strVMConnect = strVMConnect & "VM " & j & ": " & vmObject & " - State: " & fVMState & ", Snapshot(s): YES" & vbCrLf
			bSendMailFlag = True
		Else
			strVMConnect = strVMConnect & "VM " & j & ": " & vmObject & " - State: " & fVMState & ", Snapshot(s): NO" & vbCrLf
		End If
	   End If
	   j = j+1
	Next
	Set vm = Nothing
	Set ESXServer = Nothing
	Set ConnectParams = Nothing
	If bSendMailFlag Then
		strVMConnect = "SENDMAIL&" & strVMConnect & vbCrLf
	Else
		strVMConnect = "&" & strVMConnect & vbCrLf
	End If
	CheckServer = strVMConnect
End Function

Popularity: 2% [?]

VMware ESXi 3.5 on HP ProLiant DL160 G5

Thursday, June 18th, 2009

Have been trying to get ESXi 3.5 (U3 or U4) installed on a HP ProLiant DL160 G5 with P400 storage controller. Read through this and some other information:

http://communities.vmware.com/message/1186946 [communities.vmware.com]

Following changes made to the server:

  • Enabled Intel Virtualization in the RBSU CPU setup
  • Set the SATA HDD mode to AHCI

Installation is fine (using the HP Installable version of ESXi 3.5 U4), the server boots, stays up for around 2 minutes then PSOD’s with error type 14. Confirmed that ESXi is able to monitor the health of the storage controller (P400) and the disks which is a good start.

Reinstalled using the generic ESXi 3.5 U4 installable version, works perfect. Seems the HP management agents don’t play nice with certain components of the DL160 hardware (same story here [communities.vmware.com]). Without the HP agents, VI Client can no longer monitor the health of the P400 storage controller or the disks attached to it. Server can be added to HP SIM v5.03 and the hardware model and ESXi version are detected correctly as are the virtual machines running on the host.

So, it is for good reason that the DL160 is not on VMware’s HCL [vmare.com]

Popularity: 13% [?]