![](/img/trans.png)
[英]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.