Related PowerShell Functionality
As discussed, Resource Monitor provides lists
and graphical representations of various counters. Here are some ways
to go about similar tasks with PowerShell:
Get-Counter
The Get-Counter cmdlet returns performance counter data from a specified computer (local or remote).
Description
The cmdlet returns real-time performance
counter data directly from the operating system’s performance
monitoring components. It can be used to get performance data from any
computer as long as access and credentials are available. The command
can specify the sample interval and can therefore be used to create a
rudimentary monitoring tool for troubleshooting purposes.
Without parameters, the Get-Counter cmdlet
returns counter data for a default set of system counters. The
parameters can be used not only to direct the command to a specific
computer but also to specify the required counters.
Examples
Get-Counter
What it does: Returns the values of a set of default counters on the local computer.
Get-Counter '\Memory\Available MBytes'
What it does: Returns the specified counter - current available memory in MB on the local computer.
Get-Counter "\\ABCDC1\Processor(_Total)\% Processor Time" –SampleInterval 10 –
MaxSamples 5
What it does: Returns the CPU utilization
counter on the specified computer (local or remote) every 10 seconds
until it has 5 returned values.
$diskreads = "\LogicalDisk(C:)\Disk Writes/sec"
$diskreads | get-counter -computer abcdc1, abcdc2 -maxsamples 10
What it does: Returns 10 samples of the Disk Writes/sec counter from the two listed servers.
Server Manager
Having looked at Task Manager, Event Viewer,
Performance Monitor, command-line debugging tools, and various aspects
of each, we have noted that it is 1) feasible to connect remotely with
most tools, and 2) it is preferred to do so in the interest of reducing
overhead. With this in mind, let’s look at the new Dashboard-like
Server Manager, which not only serves as a central repository to call
many of our logging and debugging tools, but also allows us to do so
remotely and collectively.
Server Manager can be installed on an administrator’s desktop and utilized in the same manner as when used locally on a server:
• Add servers or custom groups
• Get status of servers, groups or roles
• Manage groups of servers simultaneously (adding/removing roles and features)
Server Manager opens up at logon (by default), can be called by typing Server Manager in the Metro start screen, or by entering servermanager.exe from the Run prompt or command prompt.
On opening, Server Manager loads to the
Dashboard screen where you can see red item counts on manageability,
events, service, performance, and BPA results for local servers or
server group.
To best make use of the Dashboard, server
groups should be composed of the servers you monitor, in groupings that
make sense for your role.
To create a server group, click Manage in the
top menu, and choose Create Server Group from the drop-down menu. The
Create Server Group screen pops up. First, simply enter a name for the
server group. Then, choose a server from the list already present under
the Server Pool tab, by browsing Active Directory, by entering a name
or IP address under the DNS tab, or by using a list of servers in a
text file under the Import tab (or a combination of all four). In Figure 10,
we’re importing a text file of server names. Select any servers on the
frame on the left that you want to add to the server group, and then
click the arrow to bring them to the right frame. When you have a
complete list of selected computers on the frame on the right, just
click OK.
Figure 10. The new Server Manager in Windows Server 2012.
Note
The Import Wizard is intelligent enough to
skip duplicate servers. Even though we listed NYCDM01 twice in our text
file, only one was added to the selected computer list.
As shown on the frame on the left in Figure 10, we’ve created three examples: SQL Servers 2012 (based on role and functionality), Walnut Creek Servers (based on location and security), and YSA Servers (consisting of a couple of servers that serve as a back end to our YSA application).
Clicking any of our server groups provides a
centralized view, capturing Events, Services, Best Practices Analyzer
results, Performance Alerts, and Roles & Features for the selected
server in the group, as shown in Figure 11.
Figure 11. Server Manager, All Servers View.
Tip
Right-clicking a server provides you several
interactive options, including the ability to call Computer Manager,
call PowerShell, or restart the server.
Clicking the Tasks drop-down menu above each
section provides some configuration options. For example, the
Performance Tasks menu shows Configure Performance Alerts, bringing the
option to define performance alert thresholds.
The YSA Servers (consisting of a couple of
servers that serve as a back end to our YSA application): The YSA
application is CPU-use intensive, so while we leave the default
alerting on both CPU and memory in place, we increased the alert level
for CPU from the default 85% to 95%, as shown in Figure 12.
Figure 12. Configure performance alerts.