【发布时间】:2021-06-08 13:13:40
【问题描述】:
我找到了一个amazing script online,它可以让我们每个人在迁移之前确定我们在 Azure 上需要多少果汁:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
$ErrorActionPreference = "Stop"
$VerbosePreference = "Continue"
cls
Write-Output "Collecting counters..."
Write-Output "Press Ctrl+C to exit."
$counters = @("\Processor(_Total)\% Processor Time",
"\LogicalDisk(_Total)\Disk Reads/sec",
"\LogicalDisk(_Total)\Disk Writes/sec",
"\SQLServer:Databases(_Total)\Log Bytes Flushed/sec")
Get-Counter -Counter $counters -SampleInterval 1 -MaxSamples 3600 |
Export-Counter -FileFormat csv -Path "C:\sql-perfmon-log.csv" -Force
问题是这个脚本针对的是整个服务器,而不是特定的数据库。
是否可以通过 PowerShell 或通过 PowerShell 运行 T-SQL 查询并每秒检索这 4 个指标:
- 处理器 - 处理器时间百分比
- 逻辑磁盘 - 磁盘读取/秒
- 逻辑磁盘 - 磁盘写入/秒
- 数据库 - 刷新的日志字节数/秒
目标是仅为 1 个数据库收集这 4 个指标。
【问题讨论】:
标签: azure powershell tsql scripting azure-sql-database