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. 😀
Are you talking about the VSAN Alarm Definitions?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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?
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.
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
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.
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?
With $vsanConfig you can do
$config = $vsanConfig.VsanClusterGetConfig($cluster.ExtensionData.MoRef)
$config.VsanHealthConfig.HealthCheckThresholdSpec
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great - thank you again.