2017-10-10 78 views
-2

我們是否可以通過Power Shell查看虛擬機的CPU使用情況和其他詳細信息。 我想寫一個電源shell腳本來獲取所有的天藍色虛擬機的細節,它顯示一些錯誤,任何人都可以有關於如何編寫腳本來獲取細節的想法。如何通過Power Shell獲取天藍色虛擬機的CPU使用情況


我能夠得到VM細節GET-AzureRmVM -ResourceGroupName「RG」雜牌「VM」 - 狀態,但我沒有得到CPU使用率,我嘗試了一些表格內容「WADPerformanceCountersTable」法則: - 「\ Processor(_Total)\%Processor Time」

+1

你有什麼試過?展示你的努力。 SO不適用於腳本交付,它用於幫助人們,如果他們被困在某個地方。 –

+1

@luckygirl編輯問題並將代碼放在那裏。這樣我們可以清楚地看看它。 –

回答

0

也許我們可以使用此Azure PowerShell命令Get-AzureRmMetric來獲取CPU使用率。

我們可以使用Get-AzureRmMetricDefinition獲得支持的指標,在​​這裏有天青VM的指標:關於Azure的VM的支持指標

PS D:\testdata> (Get-AzureRmMetricDefinition -ResourceId $id).name 

Value      LocalizedValue 
-----      -------------- 
Percentage CPU   Percentage CPU 
Network In    Network In 
Network Out    Network Out 
Disk Read Bytes   Disk Read Bytes 
Disk Write Bytes   Disk Write Bytes 
Disk Read Operations/Sec Disk Read Operations/Sec 
Disk Write Operations/Sec Disk Write Operations/Sec 
CPU Credits Remaining  CPU Credits Remaining 
CPU Credits Consumed  CPU Credits Consumed 

的更多信息,請參閱本link

然後我們就可以使用該值來獲得指標:

Get-AzureRmMetric -ResourceId $id -TimeGrain 00:01:00 -DetailedOutput -MetricNames "Network in" 

下面是PowerShell的輸出:

enter image description here

如果您Azure的PowerShell的版本是3.4.0,我們可以利用這個命令來獲得來賓指標:

enter image description here

希望它有幫助:)

+0

非常感謝 – luckygiri

相關問題