Thursday 29 January 2015

PowerShell script for starting AX Perfmon event trace remotely

In my previous post I talked about starting AX Perfmon trace remotely. Attached to this post is the PowerShell script that does the same. The stop step also copies the trace generated to a network folder. Instead of starting the script in PowerShell and specifying parameters, I have created a shortcut for each operation on an AOS server. So from a remote machine, trace can be generated and can be loaded from the network folder for analysis.

The script folder have following files
StartStopTrace.ps1: This is where the actual PoweShell code resides.

Parameters.txt: Parameters file to specify the data collector set name, destination folder to copy trace and the source path of trace as shown below 
AXTraceTemplate.xml: This is the template to create data collector set on new AOS servers. This already have the recommendations suggested in original MS blog.

AOS 1 Start Trace shortcut: Use to start trace on AOS 1. The value of "Target" property of the short cut contains
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File .\StartStopTrace.ps1  -Operation Start -Server AXPROD-AO1
AOS 1 Stop Trace shortcut: This is similar to start shortcut except the operation is stop.

More shortcuts can be created for additional AOS as required.

This posting is provided "AS IS" with no warranties. Use code at your own risk.

Tuesday 27 January 2015

Start AX Perfmon event trace remotely

There are several ways to create traces in AX2012 for performance monitoring/optimization. One of these is by using Windows Performance Monitor. Details of how to do this can be found here.

As this trace is configured on the AOS, so to start the trace you'll have to log in to the AOS. Use the following command to do this remotely.

Start Trace
logman.exe Start "<DATA_COLLECTOR_SET_NAME>" -S <SERVER_NAME>
Stop Trace
logman.exe Stop "<DATA_COLLECTOR_SET_NAME>" -S <SERVER_NAME>
Double quotes around data collector set name are required only if the it have a space.

This posting is provided "AS IS" with no warranties. Use code at your own risk.

Tuesday 13 January 2015

Bug in DynamicsPerf views

If you have used DynamicsPerf, you may have come across views to analyse Dynamics AX database for performance issues. Two of these views are
  • MISSING_INDEXES_CURR_VW 
  • QUERY_STATS_CURR_VW. 
As the name implies, these views gives insight into the missing indexes or query stat for the last run of the capture stat job (hence the word CURR in the name). There are similar views without the CURR word which shows data for all runs of capture stat job.

In the latest version (1.2) there is a bug in the views resulting in these showing all data instead of the last run of capture stat job. To fix the bug change the views and add the highlighted lines
           INNER JOIN STATS_COLLECTION_SUMMARY S2 WITH (NOLOCK)  
         ON QS2.STATS_TIME = S2.STATS_TIME  
          AND QS2.DATABASE_NAME = S2.DATABASE_NAME AND S2.RUN_NAME NOT LIKE 'BASE%'  
                      AND QS2.STATS_TIME = (SELECT MAX(STATS_TIME)  
                  FROM  STATS_COLLECTION_SUMMARY)  
     GROUP BY QS2.DATABASE_NAME,  

Note: Similar changes may be required in other views as I haven't had a chance to use all of these.

This posting is provided "AS IS" with no warranties. Use code at your own risk.