2012-12-04 39 views
0

是否有PowerCLI腳本 - 或一系列命令 - 可用於確定VMs資源池是否有足夠的可用資源來啓動VM,而不會觸發vSphere錯誤?VMware PowerCLI命令/腳本查看虛擬機是否可以在資源池中運行?

由於性能測試的原因,我們使用RAM和CPU最大值的資源池。池中的每個VM都具有爲CPU和RAM預留的設置。測試自動化將嘗試在池中啓動儘可能多的虛擬機。啓動虛擬機時,CLI將返回錯誤將超出允許的資源數量。發生這種情況時,vSphere控制檯上顯示錯誤「資源不足」。不是經常啓動虛擬機,失敗,併產生錯誤 - 有沒有辦法檢查是否有足夠的空間?

回答

0

不確定CPU使用情況,但您可以在內存中使用PowercLI get-stat並在其周圍添加一些邏輯。簡單的例子:

connect-viserver my_vc 

$active = (get-stat -entity (get-cluster cluster_name | get-resourcepool Low) -stat mem.active.average -maxsamples 1 -realtime).Value 
$granted = (get-stat -entity (get-cluster cluster_name | get-resourcepool Low) -stat mem.granted.average -maxsamples 1 -realtime).Value 

$active 
$granted 

$pctused = ($active/$granted)*100 
$pctused 

# 4445929 
# 31797248 
# 13.9821188299063 

我想你可以建立運行之前這一點,並使用$在條件語句中的pctused例如if($ pctused -lt 98){#build} else {#stop gracefully}

相關問題