Tuesday, November 27, 2007

Two Perfmon tips

Here are two tips for using Perfmon in Windows



Perfmon Tip #1 (Basic): Identify a counter associated with a specific line in a busy graph.



When a perfmon graph is opened with many counters added, it can be quite difficult to match up the counters with the lines on the graph. There are two methods to deal with this, outside of reducing the number of counters displayed - the obvious one, which is to use the highlight button (CTRL+H) to highlight a counter in the list, then scroll up and down and select the counter by name. The other option is to double-click (carefully) on the lines in the graph, and it will highlight that line and jump to the associated counter. This comes in handy when one of the lines stands out and you want to investigate it, like the red line in the image below.





Perfmon Tip #2 (Advanced): Pulling summary data (Ave, Min, Max) from perfmon log files for an initial review.


Once you have a captured Perfmon log file, the next question is how to analyze it. This can be a cumbersome and time consuming process, especially if there are a large number of counters in the log and if it is very large. One way to start the analysis at a high level is to review the min, max and average values of all of the counters stored in the log. To do this, open the log in Perfmon (in the System Monitor view), view as a Report, and then right click on the graph or report on the right, select Properties, click the General tab and under Report and Histogram data choose Minimum, Average or Maximum and click OK. The report view will now show, for example, the maximum of all counters. Now, right click the report and Save As.. and choose type Report (*.tsv). Repeat this for the other Average and Minimum. I usually save the reports as something like this:


Perflog1_Min.tsv
Perflog1_Ave.tsv
Perlog1_Max.tsv


Now, these TSV files can simply be opened and pasted into Excel, where they will import fairly well into rows of counters and columns of instances. I usually create three tabs in an Excel spreadsheet for each set, Min, Ave and Max. You can do a multi-page select and then adjust the column sizes and formatting for all of the sheets at once. This is a very convenient method to sort out counters that need further investigation. For example, if % Idle Time on disk C: has an average of 10%, then that would need investigation. Likewise, if Disk Queue length on D: has a maximum of 10, this needs a closer look too. This is good for a quick overall review of the performance logs.

If you're interested in a more advanced automated tool, check out the Performance Analysis of Logs (PAL) Tool here:


http://www.codeplex.com/PAL

Monday, November 19, 2007

Active Directory: Piping data between DSGET and DSQUERY

There are some interesting ways to combine output from some of the active directory command line tools such on Windows 2003 servers such as dsquery and dsget. These commands lend themselves well to piping output from one to another. For example, a list of users from DSQUERY can be piped to DSGET to display the username, group membership, or any number of user attributes. You can even combine more than one pipe. For example, suppose you wanted to find the display name and home directory for all of the members of a set of groups, Marketing Managers, Marketing Users, Marketing HR, Marketing Executives, and any other groups that start with the word "Marketing."

dsquery group -name "Marketing *" dsget group -members dsget user -display -hmdir

This command will take the output from the first dsquery command which will be something like this: "CN=Marketing Managers, OU=Marketing,DC=Contoso,DC=com"
"CN=Marketing Users, OU=Marketing,DC=Contoso,DC=com"
..etc..

This output is piped as input to the next query, which will execute as:

dsget group -members "CN=Marketing Managers, OU=Marketing,DC=Contoso,DC=com
dsget group -members "CN=Marketing Users, OU=Marketing,DC=Contoso,DC=com"
..etc..

Finally, the list of usernames will be piped to the dsget query as something like this:

dsget user "CN=mjones,OU=Marketing,DC=Contoso,DC=com" -display -hmdir
...etc..

There are lots of different ways this type of piping between Active Directory commands can be used in creative ways. Sometimes a script is a better choice depending on what type of query is needed, but if you want to grab some information from active directory quickly, just using these commands and piping between them can be a good alternative. For more information on the DSQUERY, DSGET and other active directory command line tools, check out Technet:

Directory service command-line tools
http://technet2.microsoft.com/WindowsServer/en/library/46ba1426-43fd-4985-b429-cd53d3046f011033.mspx?mfr=true