dawoo
Enthusiast
Enthusiast

PowerCLI cmdlet New-Cluster, how do I set VM Monitoring?

Jump to solution

Hi.

I'm creating Clusters using script and need to Enable the VM Monitoring with a Monitoring sensitivity of Medium. The cmdlet doesn't offer this syntax.

Anyone have any suggestions how this can be achieved?

Many thanks

Darren.

(@dawoo)

10 Print "It's all about the Nerdknobs" , 20 GOTO http://blog.vmote.net/
Tags (2)
1 Solution

Accepted Solutions
ykalchev
VMware Employee
VMware Employee

Hi,

You need to updated Cluster VmToolsMonitoringSettings. This can be done using Get-View cmdlet or ExtensionData property of the newly created Cluster object.

Here is the function that modifies Cluster HA VM Monitoring Settings to medium:

function Set-ClusterDasVmMonitoring ($cluster){
    $spec = New-Object VMware.Vim.ClusterConfigSpecEx
    $spec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
    $spec.dasConfig.vmMonitoring = "enabled"
    $spec.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.enabled = $true
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.failureInterval = 60
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.minUpTime = 240
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailures = 3
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailureWindow = 86400
    
    $cluster.ExtensionData.ReconfigureComputeResource($spec, $true)
}

Now you can execute the script against the cluster you've just created:

$newcluster = New-Cluster .....

Set-ClusterDasVmMonitoring $newCluster

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team

View solution in original post

7 Replies
ykalchev
VMware Employee
VMware Employee

Hi,

You need to updated Cluster VmToolsMonitoringSettings. This can be done using Get-View cmdlet or ExtensionData property of the newly created Cluster object.

Here is the function that modifies Cluster HA VM Monitoring Settings to medium:

function Set-ClusterDasVmMonitoring ($cluster){
    $spec = New-Object VMware.Vim.ClusterConfigSpecEx
    $spec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
    $spec.dasConfig.vmMonitoring = "enabled"
    $spec.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.enabled = $true
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.failureInterval = 60
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.minUpTime = 240
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailures = 3
    $spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailureWindow = 86400
    
    $cluster.ExtensionData.ReconfigureComputeResource($spec, $true)
}

Now you can execute the script against the cluster you've just created:

$newcluster = New-Cluster .....

Set-ClusterDasVmMonitoring $newCluster

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team

View solution in original post

dawoo
Enthusiast
Enthusiast

Wow, thank you.

Out of interest should the reference to $cluster at the function declaration be $newcluster for your example?

Many thanks,

Darren.

(still struggling to get my head around the Get-View and how to use the API)

10 Print "It's all about the Nerdknobs" , 20 GOTO http://blog.vmote.net/
0 Kudos
dawoo
Enthusiast
Enthusiast

Right, this script now works but doesn't Enable the monitoring.

-


Connect-VIServer win2k3vc -User administrator -Password password

$newdcname = "NEWYORK"

$newcluster = "PROD"

function Set-ClusterDasVmMonitoring ($newclusterconfig)

{

$spec = New-Object VMware.Vim.ClusterConfigSpecEx

$spec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo

$spec.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings

$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings

$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.enabled = $true

$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.failureInterval = 60

$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.minUpTime = 240

$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailures = 3

$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailureWindow = 86400

$newclusterconfig.ExtensionData.ReconfigureComputeResource($spec, $true)

}

Get-Datacenter -Name $newdcname

$newclusterconfig = New-Cluster -Location $newdcname -Name $newcluster -HAEnabled:$true -HAAdmissionControlEnabled:$false -HAIsolationResponse PowerOff -DrsEnabled:$true

Set-ClusterDasVmMonitoring $newclusterconfig

-


Any thoughts as to why?

Thanks,

Darren.

Message was edited by: dawoo

10 Print "It's all about the Nerdknobs" , 20 GOTO http://blog.vmote.net/
0 Kudos
ykalchev
VMware Employee
VMware Employee

$cluster is the parameter of the function so you shouldn't reference to $newclusterconfig. All you need is to create the cluster using Get-cluster cmdlet and pass the result to the function.

But let make it one script without functions in order to isolate the error:

$newdcname = "NewYork"
$newcluster = "PROD"

# Create new cluster
$newclusterconfig = New-Cluster -Location $newdcname -Name $newcluster -HAEnabled:$true -HAAdmissionControlEnabled:$false -HAIsolationResponse PowerOff -DrsEnabled:$true

# Create update cluster specification object

$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$spec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
$spec.dasConfig.vmMonitoring = "enabled"
$spec.dasConfig.defaultVmSettings = New-Object VMware.Vim.ClusterDasVmSettings
$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings = New-Object VMware.Vim.ClusterVmToolsMonitoringSettings
$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.enabled = $true
$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.failureInterval = 60
$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.minUpTime = 240
$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailures = 3
$spec.dasConfig.defaultVmSettings.vmToolsMonitoringSettings.maxFailureWindow = 86400

# Update cluster 

$newclusterconfig.ExtensionData.ReconfigureComputeResource($spec, $true)

Let me know if you still get any error

Regards,

Yasen Kalchev

PowerCLI Dev Team

Message was edited by: ykalchev

Yasen Kalchev, vSM Dev Team
dawoo
Enthusiast
Enthusiast

Thank you.

Marvellous, runs without error but doesn't place a 'tick' in the Enable box. Odd, the value is $true.

All other settings are configured successfully though.

Regards,

Darren.

10 Print "It's all about the Nerdknobs" , 20 GOTO http://blog.vmote.net/
0 Kudos
ykalchev
VMware Employee
VMware Employee

Sorry, I've also mislead by the vmToolsMonitoringSettings.enabled property.

You must set dasConfig.vmMonitoring to enabled also.


    $spec.dasConfig.vmMonitoring = "enabled"

I've updated my previous posts with the missing line also

Also note that if you're running this script against vCenter Server 4.1 the value should be one of the values listed in VmMonitoringState enumeration

Regards,

Yasen Kalchev

PowerCLI Dev Team

Message was edited by: ykalchev

Yasen Kalchev, vSM Dev Team
dawoo
Enthusiast
Enthusiast

That did it!

Thank you very much for your time and especially your patience.

Cheers,

Darren.

(@dawoo).

10 Print "It's all about the Nerdknobs" , 20 GOTO http://blog.vmote.net/
0 Kudos