@@ -100,7 +100,7 @@ if ($namedInstanceName) {
100
100
else {
101
101
$perfmonLogFile = ' opdb__perfMonLog' + ' __' + $operation + ' _' + $machinename + ' _MSSQLSERVER_' + $current_ts + ' .log'
102
102
if (! $perfmonOutFile ) {
103
- $perfmonOutFile = ' opdb__PerfMonData' + ' _' + $machinename + ' _MSSQLSERVER_' + $current_ts + ' .csv'
103
+ $perfmonOutFile = ' opdb__PerfMonData' + ' _' + $machinename + ' _MSSQLSERVER_' + $current_ts + ' .csv'
104
104
}
105
105
}
106
106
@@ -241,7 +241,7 @@ function CreateDMAPerfmonDataSet {
241
241
</EventsFileName>
242
242
</DataManager>
243
243
</DataCollectorSet>
244
- '@
244
+ '@
245
245
}
246
246
else {
247
247
$str = @'
@@ -401,12 +401,12 @@ function CreateDMAPerfmonDataSet {
401
401
Remove-Item - Path $env: TEMP \DMA- SQLServerPerfmonDataSet.xml
402
402
}
403
403
}
404
-
405
-
404
+
405
+
406
406
$newXML = $str.Replace (' $instance' , $metricInstanceName ).Replace(' $dataset' , $dataSet )
407
407
$newXML = $newXML.Replace (' $perfmonDuration' , $perfmonDuration ).Replace(' $perfmonSampleInterval' , $perfmonSampleInterval )
408
408
$newXML = $newXML.Replace (' $perfmonTotalDuration' , $perfmonTotalDuration )
409
-
409
+
410
410
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " " - logOperation " BOTH"
411
411
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " Writing XML File to be used for import to perfmon..." - logOperation " BOTH"
412
412
$newXML | Out-File - FilePath $xmlTempDir \DMA- SQLServerPerfmonDataSet.xml - encoding utf8
@@ -531,7 +531,7 @@ function CollectDMAPerfmonDataSet {
531
531
[string ]$dmaSourceId ,
532
532
[string ]$dmaManualId
533
533
)
534
-
534
+
535
535
$outputDir = $PSScriptRoot + " \" + $perfmonOutDir
536
536
$outputFileName = $perfmonOutFile
537
537
$maxFileDate = $null
@@ -561,9 +561,9 @@ function CollectDMAPerfmonDataSet {
561
561
$tempFileName = ' PKEY_' + (Split-Path $file - leaf)
562
562
Get-Content - Path $file | ForEach-Object {
563
563
# Old way of splitting file
564
- # $arr = $_.ToString() -split ','
564
+ # $arr = $_.ToString() -split ','
565
565
# $left = $arr[0..($arr.Length-3)] -join ','
566
- # $right = $arr[($arr.Length-2)..($arr.Length-1)] -join ','
566
+ # $right = $arr[($arr.Length-2)..($arr.Length-1)] -join ','
567
567
# '"' + $pkey + '",' + $left + ',"' + $dmaSourceId + '","' + $dmaManualId + '",' + $right
568
568
# New file split method
569
569
$perfmonCsv = $_.ToString () -split ' ,'
@@ -586,7 +586,7 @@ function CollectDMAPerfmonDataSet {
586
586
$tempContent = ' "PKEY"|"COLLECTION_TIME"|"AVAILABLE_MBYTES"|"PHYSICALDISK_AVG_DISK_BYTES_READ"|"PHYSICALDISK_AVG_DISK_BYTES_WRITE"|"PHYSICALDISK_AVG_DISK_BYTES_READ_SEC"|"PHYSICALDISK_AVG_DISK_BYTES_WRITE_SEC"|"PHYSICALDISK_DISK_READS_SEC"|"PHYSICALDISK_DISK_WRITES_SEC"|"PROCESSOR_IDLE_TIME_PCT"|"PROCESSOR_TOTAL_TIME_PCT"|"PROCESSOR_FREQUENCY"|"PROCESSOR_QUEUE_LENGTH"|"BUFFER_CACHE_HIT_RATIO"|"CHECKPOINT_PAGES_SEC"|"FREE_LIST_STALLS_SEC"|"PAGE_LIFE_EXPECTANCY"|"PAGE_LOOKUPS_SEC"|"PAGE_READS_SEC"|"PAGE_WRITES_SEC"|"USER_CONNECTION_COUNT"|"MEMORY_GRANTS_PENDING"|"TARGET_SERVER_MEMORY_KB"|"TOTAL_SERVER_MEMORY_KB"|"BATCH_REQUESTS_SEC"|"DMA_SOURCE_ID"|"DMA_MANUAL_ID"|"NUMA_TOTAL_MEMORY_MB"|"NUMA_AVAILABLE_MEMORY_MB"'
587
587
if ($fileExists ) {
588
588
Set-Content - Path $outputDir \$outputFileName - Value $tempContent - Encoding utf8
589
-
589
+
590
590
((Get-Content - Path $env: TEMP \PKEY_* $dataSet * .csv - Raw ) -replace ' ,' , ' |' ) | Add-Content - Encoding utf8 - Path $outputDir \$outputFileName
591
591
}
592
592
else {
@@ -603,7 +603,7 @@ function CollectDMAPerfmonDataSet {
603
603
$tempContent = ' "' + $pkey + ' "|"' + $tempDate + ' "|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"0"|"' + $dmaSourceId + ' "|"' + $dmaManualId + ' "|"0"|"0"'
604
604
Add-Content - Path $outputDir \$outputFileName - Value $tempContent - Encoding utf8
605
605
606
- }
606
+ }
607
607
if (Test-Path - Path $outputDir \$outputFileName ) {
608
608
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " Clean up Temp File area..." - logOperation " BOTH"
609
609
Remove-Item - Path $env: TEMP \* $dataSet * .csv
@@ -627,7 +627,7 @@ function CreateEmptyFile {
627
627
[string ]$dmaSourceId ,
628
628
[string ]$dmaManualId
629
629
)
630
-
630
+
631
631
$outputDir = $PSScriptRoot + " \" + $perfmonOutDir
632
632
$outputFileName = $perfmonOutFile
633
633
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " Creating an empty Google DMA SQL Server Perfmon Counter Data Set..." - logOperation " BOTH"
@@ -636,7 +636,7 @@ function CreateEmptyFile {
636
636
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " " - logOperation " FILE"
637
637
WriteLog - logLocation $foldername \$logFile - logMessage " DMA Manual Id: $dmaManualId " - logOperation " FILE"
638
638
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " " - logOperation " FILE"
639
-
639
+
640
640
if (! (Test-Path - PathType container $outputDir )) {
641
641
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " " - logOperation " BOTH"
642
642
WriteLog - logLocation $outputDir \$perfmonLogFile - logMessage " Creating Output Directory..." - logOperation " BOTH"
@@ -671,7 +671,7 @@ function CreateEmptyFile {
671
671
}
672
672
673
673
if (! $operation ) {
674
- $operation = read-host - Prompt " Enter an operation: create, stop, delete, collect, createemptyfile"
674
+ $operation = read-host - Prompt " Enter an operation: create, stop, delete, collect, createemptyfile"
675
675
}
676
676
if ($namedInstanceName ) {
677
677
$datasetName = " Google-DMA-SQLServerDataSet-$namedInstanceName "
@@ -709,4 +709,4 @@ elseif ($operation.ToLower() -eq "status") {
709
709
}
710
710
else {
711
711
Write-Output " Operation $operation specified is invalid"
712
- }
712
+ }
0 commit comments