麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 開發 > PowerShell > 正文

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

2020-05-30 20:21:52
字體:
來源:轉載
供稿:網友

由于監控及報告需要,要統計性能計數器每天數值情況,確認數據庫服務器的運行狀況。若打開計數器填寫,比較麻煩,現在統計用 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 = "http://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 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产九九九九 | 国产色爱综合网 | 在线日韩av电影 | 羞羞答答视频 | 精品国产一级毛片 | 日本高清com | 欧美18一19sex性护士农村 | 男女羞羞视频在线观看免费 | 在线播放视频一区二区 | 制服丝袜成人动漫 | 欧美日韩亚洲不卡 | 羞羞网站在线观看入口免费 | 一区二区免费看 | 国产成人高清成人av片在线看 | 性生活视频软件 | 91精品一区二区综合在线 | chinese 军人 gay xx 呻吟 | 看a级毛片| 欧美 国产 亚洲 卡通 综合 | 久久精品亚洲欧美日韩精品中文字幕 | 羞羞网站视频 | 国产精品久久久久久久久久iiiii | 爽爽淫人综合网网站 | 国产亚洲精品成人 | 亚洲影视在线观看 | 国产久草视频在线 | 黄色网址进入 | 久久国产综合视频 | 人人舔人人插 | 久久国产精品小视频 | 中国hdxxxx护士爽在线观看 | 国产精品成人一区二区三区电影毛片 | 99国内精品视频 | 国产精品九九久久一区hh | 一本色道久久99精品综合蜜臀 | 午夜久久久精品一区二区三区 | 精品亚洲一区二区三区 | 一级做a爱片性色毛片 | 毛片在线视频观看 | 久草在线视频看看 | 中文字幕欧美一区二区三区 |