It gets difficult at times when we need to capture CDF traces for a specific period of time. We have different tools like CDF Control, Scout and CDF Monitor, however it requires manual intervention to start and stop the traces and yet there are chances that the traces might get over-written if you use CDF Monitor or blow up your storage space by using CDF Control/Scout to collect multiple sequential logs. And it also becomes difficult if we need to capture traces at wee hours.
To avoid situations like this, we can use Task Scheduler to start and stop CDF monitor using batch files. In my use case, I am configuring task scheduler to capture CDF traces for a reboot schedule starting at 2:00 AM this Sunday which will run for a couple of hours and then stop with the help of CDF Monitor.
Instructions
2. First, uninstall the CDF Monitor service from the Delivery Controllers (if it was installed previously). To do this, open command prompt and browse to the location which contains the CDFmonitor.exe file. Run the following command:
CDFmonitor.exe /uninstallservice
3. To validate that the service is uninstalled completely, open services.msc console and check for CDF Monitor service. If you do not find any, then the service is uninstalled completely. Also delete the following folder (if present) - C:\Windows\CDFMonitor from all the Delivery Controllers.
4. Now configure the config file of CDF Monitor as per the below settings:
a. Change the value to ‘15’ for ‘logfilemaxcount’
b. Change the value to ‘100’ for ‘logfilemaxsize’
c. Change the value to <add key="logtoetl" value="True" />
d. Change the value to <add key="tracefile" value="cdftrace.etl" />
5. Once we have the config file saved, you will need to create two .bat files for starting and stopping the CDF Monitor service. In my sample script, I have placed the CDFMonitor.exe and CDFMonitor.exe.config files in the C: directory. I have attached the batch files in this article for your reference.
a. To start the service:
cd C:\ cdfmonitor.exe /installservice
b. To stop the service:
cd C:\ cdfmonitor.exe /stopservice
6. Now, we will use “Task Scheduler” to create a task for starting and stopping the service at a specific time. As an example, we set the start time to 1:45 AM and stop time to 6:00 AM. So below are the steps to configure “Task Scheduler”.
a. On one of the Delivery Controllers, open Task Scheduler.
b. Create a new folder and name it as CDF Monitor:
c. Right-click on the folder that you created and select the option “Create Task”.
d. Name it as CDFstart and configure the Security Options accordingly. Make sure you check the option “Run with highest privileges” and “Run whether user is logged on or not”
e. Browse to the “Triggers” tab and click on “New”. A window will pop-up to configure the trigger. You can configure the options depending on the use case.
Make sure that you have the “Expire” date and time set as well.
f. Now browse to the “Actions” tab and create a new Action. A new window will pop up where you will need to select the Action type. Set it to “Start a program” and in the Settings, browse to the CDFstart.bat file and click on Open.
g. In the conditions tab, select the values mentioned in the below screenshot.
h. Also configure the Settings tab as in the below screenshot:
i. Once all the properties are configured, click on OK to save it.
j. Repeat the steps from “c” through “i” to create and configure the task to stop CDF Monitor. Here, the only changes will be in the name of the task, Trigger start and stop time, batch file in the Actions tab. Below are the screenshots for each of these sections:
k. The values in “Conditions” and “Settings” will be the same as CDFstart task.
7. Once you have both the tasks, configured, the summary will look something like the below screenshot:
8. For testing, you can probably set the values for the triggers accordingly and check if the .etl files are getting created in the C:\Windows\CDFMonitor folder. Alternatively, after the Start trigger, you can find CDF Monitor service in a “Running” state and after the second trigger, the CDF Monitor service will be in a stopped state in the Services console. Once you validate that the task scheduler is configured properly, uninstall the CDF Monitor service by following Step 1. We need to have it uninstalled because the command that we are using in the script is to install the service. This will not start the service if CDF Monitor is already installed.
9. Once the tasks are created on a DDC, you will find an option to export each task. Export both the tasks, create a new Folder in the Task Scheduler of all the other DDC/VDA where you want to configure CDF tracing and import it to that folder.
To import:
10. Once they are configured correctly with the above settings, CDF Monitor will start collecting the traces at 1:45 AM and will stop the collection on 5:00 AM 03/12/2017.