VMware Cloud Community
william450
Contributor
Contributor
Jump to solution

script to check my current CPU and Memory reservations on service console

hi there,

im looking for a script to check what the reservation is currently, we are running into problems with Vranger, just need to check that we have set all the cpu and memory to the right value,

found a couple of scripts to change it, which one do you guys use?

thank you

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The script requires PowerShell v2.

Try this if you're using PowerShell v1.

filter Get-ConsoleResource{
	param(
		$entity
	)
	
	begin{
		$result = $null
	}
	process{
		if($_.Key -eq "host/vim/console"){
			$_
		}
		if($_.Child){
			$_.Child | Get-ConsoleResource
		}
	}
	end{
	}
}

Get-View -ViewType HostSystem | %{
	$esx = $_
	$_.SystemResources.Child | Get-ConsoleResource | Select @{N="Name";E={$esx.Name}},
		@{N="Console Reservation CPU MHz";E={$_.Config.CpuAllocation.reservation}},
		@{N="Console Reservation Memory MB";E={$_.Config.MemoryAllocation.reservation}}	
}

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Not sure what you mean with CPU reservation on the console, but the console memory reservation can be found like this

PowerCLI 4.1

Get-VMHost | Select Name, @{N="ConsoleMemReservation";E={$_.ExtensionData.Config.ConsoleReservation.ServiceConsoleReserved}}

PowerCLI 4u1

Get-VMHost | Select Name, @{N="ConsoleMemReservation";E={($_ | Get-View).Config.ConsoleReservation.ServiceConsoleReserved}}

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
william450
Contributor
Contributor
Jump to solution

hi im refering to this post

http://communities.vmware.com/thread/174234

trying to check what the cpu reservation is for the console,

for now i just need to check what it is, not change it yet??

thanks

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, go it. Those are the values for the system resources.

Get-VMHost | Get-View | Select Name,
	@{N="SystemResource CPU";E={$_.SystemResources.Config.CpuAllocation.reservation}},
	@{N="SystemResource Memory";E={$_.SystemResources.Config.MemoryAllocation.reservation}}	

Or in PowerCLI 4.1

Get-VMHost | Select Name,
	@{N="SystemResource CPU";E={$_.ExtensionData.SystemResources.Config.CpuAllocation.reservation}},
	@{N="SystemResource Memory";E={$_.ExtensionData.SystemResources.Config.MemoryAllocation.reservation}}	

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
william450
Contributor
Contributor
Jump to solution

im trying to get the console reservation on memory and cpu?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Third time , good time.

Think I finally got it.

Try this

function Get-ConsoleResource{
	param(
	[parameter(ValueFromPipeline = $true,Position=1,Mandatory = $true)]$entity
	)
	
	begin{
		$result = $null
	}
	process{
		if($_.Key -eq "host/vim/console"){
			$_
		}
		if($_.Child){
			$_.Child | Get-ConsoleResource
		}
	}
	end{
	}
}

Get-View -ViewType HostSystem | %{
	$esx = $_
	$_.SystemResources.Child | Get-ConsoleResource | Select @{N="Name";E={$esx.Name}},
		@{N="Console Reservation CPU MHz";E={$_.Config.CpuAllocation.reservation}},
		@{N="Console Reservation Memory MB";E={$_.Config.MemoryAllocation.reservation}}	
}

If you want a specific host or a set of hosts, use the -Filter parameter on the Get-View cmdlet.

For example:

Get-View -ViewType HostSystem -Filter @{"Name"="esxname"}

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
william450
Contributor
Contributor
Jump to solution

thanks for the help, but im getting an error, what am i doing wrong

Unable to find type [parameter(ValueFromPipeline = $true,Position=1,Mandatory =

$true)]: make sure that the assembly containing this type is loaded.

At C:\DOCUME1\SA17441\LOCALS~1\Temp\1\2e80f08f-0641-4adc-b7c7-d352f7583844.ps

1:5 char:103

+ function Get-ConsoleResource{param([parameter(ValueFromPipeline = $true,Posit

ion=1,Mandatory = $true)]$ <<<< entity

PS C:\Documents and Settings\sa17448001\Desktop\Logs\Script>

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The script requires PowerShell v2.

Try this if you're using PowerShell v1.

filter Get-ConsoleResource{
	param(
		$entity
	)
	
	begin{
		$result = $null
	}
	process{
		if($_.Key -eq "host/vim/console"){
			$_
		}
		if($_.Child){
			$_.Child | Get-ConsoleResource
		}
	}
	end{
	}
}

Get-View -ViewType HostSystem | %{
	$esx = $_
	$_.SystemResources.Child | Get-ConsoleResource | Select @{N="Name";E={$esx.Name}},
		@{N="Console Reservation CPU MHz";E={$_.Config.CpuAllocation.reservation}},
		@{N="Console Reservation Memory MB";E={$_.Config.MemoryAllocation.reservation}}	
}

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
william450
Contributor
Contributor
Jump to solution

thanks both work and saved me hours of searching,

where can i get hold of info on those type of variables??

0 Kudos
LucD
Leadership
Leadership
Jump to solution

For those properties you need to consult the VMware vSphere API Reference Documentation.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos