register_odpm_perfmon_counters.ps1 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $categoryName = "ODP.NET, Managed Driver"
  2. try{
  3. $categoryHelp = "$categoryName Performance Counter"
  4. $categoryType = [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance
  5. $categoryExists_reg = [System.Diagnostics.PerformanceCounterCategory]::Exists($categoryName)
  6. if($categoryExists_reg)
  7. {
  8. [System.Diagnostics.PerformanceCounterCategory]::Delete($categoryName)
  9. }
  10. $counterCreationDataList = New-Object -TypeName System.Diagnostics.CounterCreationDataCollection
  11. $counterCreationDataList.Clear()
  12. $RateOfCountsPerSecond64 = [System.Diagnostics.PerformanceCounterType]::RateOfCountsPerSecond64
  13. $NumberOfItems64 = [System.Diagnostics.PerformanceCounterType]::NumberOfItems64
  14. $counterCreationData1 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'HardConnectsPerSecond', [string]::Empty, $RateOfCountsPerSecond64
  15. $counterCreationData2 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'HardDisconnectsPerSecond', [string]::Empty, $RateOfCountsPerSecond64
  16. $counterCreationData3 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'SoftConnectsPerSecond', [string]::Empty, $RateOfCountsPerSecond64
  17. $counterCreationData4 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'SoftDisconnectsPerSecond', [string]::Empty, $RateOfCountsPerSecond64
  18. $counterCreationData5 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfActiveConnectionPools', [string]::Empty, $NumberOfItems64
  19. $counterCreationData6 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfInactiveConnectionPools',[string]::Empty, $NumberOfItems64
  20. $counterCreationData7 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfActiveConnections', [string]::Empty, $NumberOfItems64
  21. $counterCreationData8 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfFreeConnections', [string]::Empty, $NumberOfItems64
  22. $counterCreationData9 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfPooledConnections', [string]::Empty, $NumberOfItems64
  23. $counterCreationData10 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfNonPooledConnections', [string]::Empty, $NumberOfItems64
  24. $counterCreationData11 = New-Object -TypeName System.Diagnostics.CounterCreationData -ArgumentList 'NumberOfReclaimedConnections', [string]::Empty, $NumberOfItems64
  25. $counterCreationDataList.Add($counterCreationData1) | out-null
  26. $counterCreationDataList.Add($counterCreationData2) | out-null
  27. $counterCreationDataList.Add($counterCreationData3) | out-null
  28. $counterCreationDataList.Add($counterCreationData4) | out-null
  29. $counterCreationDataList.Add($counterCreationData5) | out-null
  30. $counterCreationDataList.Add($counterCreationData6) | out-null
  31. $counterCreationDataList.Add($counterCreationData7) | out-null
  32. $counterCreationDataList.Add($counterCreationData8) | out-null
  33. $counterCreationDataList.Add($counterCreationData9) | out-null
  34. $counterCreationDataList.Add($counterCreationData10) | out-null
  35. $counterCreationDataList.Add($counterCreationData11) | out-null
  36. [System.Diagnostics.PerformanceCounterCategory]::Create($categoryName, $categoryHelp, $categoryType, $counterCreationDataList) | out-null
  37. write-host("$categoryHelp was registered successfullly.")
  38. }
  39. catch{
  40. write-host("ERROR: $categoryHelp registration failed.")
  41. }