-
-
Save 40a/11107366 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Author: Sunny Chakraborty. 2014 (@sunnyc7) | |
| # BasedOn: Matt Graeber's beautiful work with Powershell Lambda functions. | |
| # Powershell Magazine Source: http://www.powershellmagazine.com/2013/12/23/simplifying-data-manipulation-in-powershell-with-lambda-functions/ | |
| # Code: get-continiouscounterpoll.ps1 | |
| # Source: https://gist.github.com/9579625 | |
| <# | |
| You can copy list of counters in counter-paths.txt. | |
| Please avoid using * based counter paths. Instead use (_total) | |
| Content of counter-paths.txt | |
| \Processor(_Total)\% User Time | |
| \Processor(_Total)\% Privileged Time | |
| \Processor(_Total)\Interrupts/sec | |
| \Processor(_Total)\DPCs Queued/sec | |
| \Processor(_Total)\% Processor Time | |
| \Memory\Available MBytes | |
| \Memory\Pages/sec | |
| \Memory\Pool Nonpaged Bytes | |
| \Memory\% Committed Bytes In Use | |
| \Synchronization(_Total)\Spinlock Contentions/sec | |
| #> | |
| $counters = Get-Content .\counter-paths.txt | |
| Function Map-Counter { | |
| param ( | |
| [Parameter(Mandatory)] | |
| [ValidateScript({ $_.Ast.ParamBlock.Parameters.Count -eq 1 })] | |
| [Scriptblock] $Expression, | |
| [Parameter(Mandatory)] | |
| [ValidateNotNullOrEmpty()] | |
| [Object[]] $Sequence | |
| ) | |
| foreach ($member in $Sequence) { | |
| $hash = @{} | |
| $hash.Add("$member",(Invoke-Expression (&$Expression $member))) | |
| $hash | |
| } | |
| } | |
| $cookedValue = { | |
| param($x) | |
| (Get-Counter $x).CounterSamples.CookedValue | |
| } | |
| for (;;) { | |
| Map-Counter $cookedValue $counters | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment