[英]it is possbile to get the cpu usage of azurevm Throught powershell like metrics
[英]how to get cpu usage of azure vm throught powershell
我們可以通過電源外殼查看CPU使用率的指標以及VM的其他詳細信息嗎? 我試圖編寫一個Power Shell腳本來獲取Azure虛擬機的所有詳細信息,但它顯示出一些錯誤,任何人都無法知道如何編寫腳本來獲取詳細信息。
我能夠獲取虛擬機詳細信息Get-AzureRmVM -ResourceGroupName“ RG”-名稱“ VM”-狀態,但是我沒有獲得CPU使用率,因此嘗試了一些表內容“ WADPerformanceCountersTable”規則:-“ \\ Processor(_Total)\\ %處理器時間“
也許我們可以使用此Azure PowerShell命令Get-AzureRmMetric
來獲取CPU使用率。
我們可以使用Get-AzureRmMetricDefinition
獲取支持的指標,以下是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
有關Azure VM的支持指標的更多信息,請參考此鏈接 。
然后,我們可以使用該值獲取指標:
Get-AzureRmMetric -ResourceId $id -TimeGrain 00:01:00 -DetailedOutput -MetricNames "Network in"
這是PowerShell的輸出:
如果您的Azure PowerShell版本是3.4.0,我們可以使用以下命令獲取訪客指標:
希望能幫助到你:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.