最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PowerShell 讀取性能計數(shù)器二進制文件(.blg)記錄并匯總計算

 更新時間:2016年11月28日 23:11:56   投稿:mdxy-dxy  
由于監(jiān)控及報告需要,要統(tǒng)計性能計數(shù)器每天數(shù)值情況,確認數(shù)據(jù)庫服務器的運行狀況。若打開計數(shù)器填寫,比較麻煩,現(xiàn)在統(tǒng)計用 powershell 來讀取計數(shù)器的值

由于監(jiān)控及報告需要,要統(tǒng)計性能計數(shù)器每天數(shù)值情況,確認數(shù)據(jù)庫服務器的運行狀況。若打開計數(shù)器填寫,比較麻煩,現(xiàn)在統(tǒng)計用 powershell 來讀取計數(shù)器的值。

第一階段:Powershell 讀取計數(shù)器文件并統(tǒng)計其中一個計數(shù)器的值

$startDate = (Get-Date).AddDays(-1).Date 
$endDate = (Get-Date).Date 
$perfPath = "D:\DataFiles\PERFMON\MSSQL_PERFMON_08240904.blg" 
 
#讀取文件中的計數(shù)器名稱 
$counterList = Import-Counter -Path $perfPath 
$countersNameList = $counterList[0].countersamples | % {$_.path} 
 
#篩選指定計數(shù)器和時間重新導入PS 
$counter = $countersNameList -like '*Processor Time*' 
$counterData = Import-Counter -Path $perfPath -Counter $counter | Where-Object -FilterScript {($_.Timestamp -ge $startDate) -and ($_.Timestamp -lt $endDate)}  
 
#計算日期范圍內的數(shù)值統(tǒng)計 
$counterInfo = $counterData | Foreach-Object {$_.CounterSamples} | Measure-Object -property CookedValue -Average -Maximum 
 
#哈希表存儲結果數(shù)據(jù) 
$resultTable=@{} 
$resultTable."CPU 利用率——平均" = $counterInfo.Average 
$resultTable."CPU 利用率——最大" = $counterInfo.Maximum 
 
$resultTable 

第二階段:批量統(tǒng)計文件中的所有計數(shù)器并導出到文件中

$startDate = (Get-Date).AddDays(-1).Date  
$endDate = (Get-Date).Date  
$perfPath = "D:\360Downloads\*.blg" 
 
#哈希表存儲結果數(shù)據(jù)  
$resultTable=@{} 
 
#導入指定時間的所有計數(shù)器信息 
$counterData = Import-Counter -Path $perfPath | Where-Object -FilterScript {($_.Timestamp -ge $startDate) -and ($_.Timestamp -lt $endDate)} 
 
#所有的計數(shù)器名字 
$countersNameList = $counterData[0].countersamples | % {$_.Path} 
 
#遍歷每個計數(shù)器,將計算結果存儲到哈希表中 
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 

相關文章

最新評論

新田县| 大名县| 金沙县| 武功县| 普洱| 股票| 永清县| 务川| 报价| 开阳县| 神农架林区| 紫云| 从江县| 广水市| 万州区| 丹江口市| 尉氏县| 梨树县| 岫岩| 江津市| 鄂伦春自治旗| 怀宁县| 清新县| 平山县| 商水县| 南宫市| 正定县| 武川县| 永嘉县| 襄樊市| 名山县| 定边县| 垣曲县| 霍州市| 江城| 元氏县| 景东| 宣化县| 富蕴县| 蓝田县| 诸城市|