# -- User Defined Constants --------------------------- $LOG_PATH = "C:\Scripts\HDS-SNM2\pfmlog" # -- Modify controller and core options as needed ----- $Controllers = @(0,1) $cores = @("X","Y") # -- Modifications below this line should not be required --------------------------------------- # -- Setup environment ------------------------------ $testsnapin = $null $testsnapin = get-pssnapin | where { $_.Name -eq "PowerGadgets"} if(-not $testsnapin){add-pssnapin -Name PowerGadgets} . ./start-session.ps1 Set-Location $env:STONAVM_HOME # -- Object to hold processor data ------------------------ $allprocusagedata = @() # -- Processing flags ------------------------------------- $PROCUsageDataRead = $FALSE # -- Specify whether to run new collection if not existing files are used -- Write-Host ”Collect Data Y or N...” $modekey = $Host.UI.RawUI.ReadKey(”NoEcho,IncludeKeyDown”) if($modekey.Character.ToString().ToLower() -eq "y"){ $collectiontime = Read-Host "Collection Time/Count in minutes" Write-Host "Collecting Data..." ./auperform.exe -unit $DEFAULTARRAY -auto 1 -count $collectiontime -path $LOG_PATH -pfmstatis } # -- Get data from files -------------------------------------------- Write-Host "Analyzing Data..." $perffiles = Get-ChildItem $LOG_PATH foreach($perffile in $perffiles){ $filedata = Get-Content $LOG_PATH\$perffile foreach($line in $filedata){ # Get collection times if($line -match '^(\d{4}\/(?:0[1-9]|1[0-2]?)\/(?:0[1-9]|[12][0-9]|3[01]?)\s(?:0[0-9]|1[0-9]|2[0-3]?)\:(?:0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]?)\:(?:0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]?))\s-\s(\d{4}\/(?:0[1-9]|1[0-2]?)\/(?:0[1-9]|[12][0-9]|3[01]?)\s(?:0[0-9]|1[0-9]|2[0-3]?)\:(?:0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]?)\:(?:0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]?))$'){ $collectfrom = $matches[1] $collectto = $matches[2] } # Get Proc Usage Data if ($line -match 'CTL\s+Core\s+Usage'){ $PROCUsageDataRead = $TRUE }elseif($PROCUsageDataRead){ $line -match '([0,1]{1})\s+([X,Y]{1})\s+(\d+)' | Out-Null $procusagedata = "" | Select ctl,core,usage,datetime $procusagedata.ctl = $matches[1] $procusagedata.core = $matches[2] $procusagedata.usage = $matches[3] $procusagedata.datetime = $collectto $allprocusagedata += $procusagedata if(($procusagedata.ctl -eq 1) -and ($procusagedata.core -eq "Y")){$PROCUsageDataRead = $FALSE} } } } # -- List Data --------------------------------- Write-Host ”List Processor Data Y or N...” $modekey = $Host.UI.RawUI.ReadKey(”NoEcho,IncludeKeyDown”) if($modekey.Character.ToString().ToLower() -eq "y"){ $allprocusagedata | ft -prop * } # -- Create Processor Usage Chart Group ---------------------- Write-Host ”Show Processor Usage Charts Y or N...” $modekey = $Host.UI.RawUI.ReadKey(”NoEcho,IncludeKeyDown”) if($modekey.Character.ToString().ToLower() -eq "y"){ Write-Host "Generating Charts..." foreach($Controller in $Controllers){ foreach($core in $cores){ $ChartTitle = "Processor Usage Controller:$Controller Core:$core" $allprocusagedata | where {($_.core -eq $core)-and ($_.ctl -eq $Controller)} | sort datetime | Select core,usage,datetime | ` Out-Chart -Values usage -Series_0_Text "Processor Usage %" -Label datetime ` -Title $ChartTitle -Gallery Lines -Group "PROCUSAGE" -Name $ChartTitle -Caption "Processor Usage" } } } Set-Location $SCRIPTHOME