03 December 2012

Quick key performance couter view with PowerShell

Windows Server 2012 makes managing a group of servers remotely much simpler.  PowerShell gives easy access to the performance counters.  Here are a few handy commands to help you check out the basics.
Get-Counter
This give you a list of the local counters for the following

  • Network bytes per second
  • % CPU Time
  • % RAM Used
  • Cache Fault per second
  • % Disk Time
  • Current Disk Queue Length

You will notice that the counters are named and  are referenced by the server's name.  You can use these to further define the command.



You can narrow this down to say on % CPU and % RAM used with the following:
 Get-Counter -Counter "\processor(_total)\% processor time", "\memory\% committed bytes in use"
You can get this continuously per second with the following:
Get-Counter -Counter "\processor(_total)\% processor time", "\memory\% committed bytes in use" -Continuous 
You can do the same but the the updates ever 5 seconds
Get-Counter -Counter "\processor(_total)\% processor time", "\memory\% committed bytes in use" -Continuous -SampleInterval 5
Alternatively you can set how many counts you want to measure
Get-Counter -Counter "\processor(_total)\% processor time", "\memory\% committed bytes in use" -SampleInterval 2 -MaxSamples 4
This forms a nice basis for expanding this to monitoring servers remotely
Get-Counter -Counter "\processor(_total)\% processor time", "\memory\% committed bytes in use" -SampleInterval 2 -MaxSamples 4 -ComputerName "et-lab-hv01"
You can also use variables to clean things up a bit. First define and set the vairables
$counters = "\processor(_total)\% processor time", "\memory\% committed bytes in use"$servers = "et-lab-hv01","et-lab-hv02"
Then execute the command using the variables
Get-Counter -Counter $counters -ComputerName $servers -Continuous

For more information about this check out: http://technet.microsoft.com/library/hh849685.aspx

No comments:

Post a Comment