PowerShell 성능 카운터 바 이 너 리 파일(.blg)기록 읽 기 및 집계 계산
2956 단어 PowerShell성능 카운터바 이 너 리 파일
첫 번 째 단계:Powershell 은 계수기 파일 을 읽 고 계수기 의 값 을 통계 합 니 다.
$startDate = (Get-Date).AddDays(-1).Date
$endDate = (Get-Date).Date
$perfPath = "D:\DataFiles\PERFMON\MSSQL_PERFMON_08240904.blg"
#
$counterList = Import-Counter -Path $perfPath
$countersNameList = $counterList[0].countersamples | % {$_.path}
# PS
$counter = $countersNameList -like '*Processor Time*'
$counterData = Import-Counter -Path $perfPath -Counter $counter | Where-Object -FilterScript {($_.Timestamp -ge $startDate) -and ($_.Timestamp -lt $endDate)}
#
$counterInfo = $counterData | Foreach-Object {$_.CounterSamples} | Measure-Object -property CookedValue -Average -Maximum
#
$resultTable=@{}
$resultTable."CPU ―― " = $counterInfo.Average
$resultTable."CPU ―― " = $counterInfo.Maximum
$resultTable
두 번 째 단계:파일 에 있 는 모든 계수 기 를 일괄 통계 하여 파일 로 내 보 냅 니 다.
$startDate = (Get-Date).AddDays(-1).Date
$endDate = (Get-Date).Date
$perfPath = "D:\360Downloads\*.blg"
#
$resultTable=@{}
#
$counterData = Import-Counter -Path $perfPath | Where-Object -FilterScript {($_.Timestamp -ge $startDate) -and ($_.Timestamp -lt $endDate)}
#
$countersNameList = $counterData[0].countersamples | % {$_.Path}
# ,
foreach($counterName in $countersNameList)
{
#$counterName = "\\hzc\system\threads"
$counterDataOne = $counterData | Foreach-Object {$_.CounterSamples} | Where {$_.Path -like $counterName}
$counterInfo = $counterDataOne | Measure-Object CookedValue -Average -Minimum -Maximum
$resultTable.$($counterName+" : ") = $counterInfo.Average
$resultTable.$($counterName+" : ") = $counterInfo.Minimum
$resultTable.$($counterName+" : ") = $counterInfo.Maximum
}
#$resultTable.GetEnumerator() | sort Name | Format-Table -Auto
#
$resultTable.GetEnumerator() | sort Name | Format-Table -Auto | Out-File "D:\360Downloads\PerfmonCounter.txt"
$resultTable.GetEnumerator() | sort Name | Export-Csv -Path "D:\360Downloads\PerfmonCounter.txt" -Encoding "unicode" -Force
$resultTable.GetEnumerator() | sort Name | Format-List | Export-Csv -Path "D:\360Downloads\PerfmonCounter.xlsx" -Encoding "unicode" -Force
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
PowerShell 프롬프트에 Kubernetes의 현재 컨텍스트 출력다음과 같은 스크립트를 profile.ps1이라는 파일 이름으로 저장하고C:\Users\<ユーザー名>\Documents\WindowsPowerShell\ 에 배치한다. (PowerShell Core의 경우 설치 디렉...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.