how to get cpu usage of azure vm throught powershell

冷暖自知 提交于 2019-12-02 13:06:13

Maybe we can use this Azure PowerShell command Get-AzureRmMetric to get CPU usage.

We can use Get-AzureRmMetricDefinition to get the supported metrics, here are the metrics of 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

More information about supported metrics of Azure VM, please refer to this link.

Then we can use the value to get metrics:

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

Here is the PowerShell output:

If your Azure PowerShell version is 3.4.0, we can use this command to get guest metrics:

Hope it helps:)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!