VMware Cloud Community
scottD65
Contributor
Contributor

Setting VsanOperationReservationState and HostRebuildReservationState and customizing alert levels

So I am working on a script to set VsanOperationReservationState and HostRebuildReservationState to enforced and also set the customized alert levels.  I have the code for setting the enforcement:

get-cluster clusternamehere | Set-VsanClusterConfiguration -VsanOperationReservationState:Enforced -HostRebuildReservationState:Enforced

But I haven't found how to set the customized alert levels for Warning and Error.  We don't want to take the default values.  

Any help would be great. 😀

 

 

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership

Are you talking about the VSAN Alarm Definitions?


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

Reply
0 Kudos
scottD65
Contributor
Contributor

I don't think so.  I've screenshot what I am looking for.  If you 'Edit' and then turn on both Operations and Host Build reserve, you can mark a 'customize alerts' and adjust the alert levels.  I'm looking for how to set those levels.  You know how folks are, 'Can't take the defaults'. Could it be there is a corresponding Alarm Definition that can be adjusted?

scottD65_0-1652444994238.png

scottD65_1-1652445146459.png

 

 

Reply
0 Kudos
scottD65
Contributor
Contributor

ok after digging a bit more I think it's gonna be somewhere in the vsan health checks under capacity or storage space.  I'm still digging around. 

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, got it.

Afaik, there is no direct cmdlet for that, but you can use the API.
Update the cluster name and the yellow and red values to your requirements.

$clusterName = 'cluster'
$cluster = Get-CLuster -Name $clusterName

$vsanConfig = Get-VsanView -Id 'VsanVcClusterConfigSystem-vsan-cluster-config-system'
$spec = New-Object -TypeName 'VMware.Vsan.Views.VimVsanReconfigSpec'
$health = New-Object -TypeName 'VMware.Vsan.Views.VsanHealthConfigSpec'
$threshold = New-Object -TypeName 'VMware.Vsan.Views.VsanHealthThreshold'
$threshold.Enabled = $true
$threshold.Target = 'diskspace_vsan_datastore'
$threshold.YellowValue = 70
$threshold.RedValue = 90
$health.HealthCheckThresholdSpec += $threshold
$spec.VsanHealthConfig = $health
$vsanConfig.VsanClusterReconfig($cluster.ExtensionData.MoRef,$spec)

 


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

Reply
0 Kudos
scottD65
Contributor
Contributor

Very nice.  I am ok using an api call to make the adjustment.  We do the same already with some of our stuff (hot add shared disks to vms).  Thank you again for finding this. 

Reply
0 Kudos
scottD65
Contributor
Contributor

Do you happen to know if there is a way to 'get' the current settings to compare them to what I would want and only set them if required?

Reply
0 Kudos
LucD
Leadership
Leadership

With $vsanConfig you can do

$config = $vsanConfig.VsanClusterGetConfig($cluster.ExtensionData.MoRef)
$config.VsanHealthConfig.HealthCheckThresholdSpec


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

Reply
0 Kudos
scottD65
Contributor
Contributor

Great - thank you again. 

Reply
0 Kudos