How to schedule a report to run via a Cron job and save it in AppsWatch?

In AppsWatch, there are several ways to create reports of your monitoring data:

  1. You can use the Reports section included in Dashboard page to create exhaustive reports for all monitoring data. Please see this article regarding the reports.
  2. To get a report for one object or mixed ones (monitors, sub-scenarios, transactions), you can use "Export to CSV" button which allows you to generate reports for selected object(s). You can access it on the monitor's stats page in the Monitors section.
  3. There is also a method that allows you to export data in CSV format using command line or a cron job. You can set up the task and schedule it to run on a daily basis, so as to always get current data files.

This article will walk you through the steps for option 3: to set up a cron task and run it in AppsWatch.

Export data by scheduling a daily task to run using Cron Job

1. To schedule a report to run daily at specific time, download export_data file from this link and copy it into "...\AppsWatch\bin" folder if it doesn't exist.

2. Go to "..\AppsWatch\webserv\bin" folder and open cerun.conf file using a Text Editor app (Notepad or Notepad++).

3. Add the below command after the last cron.task line.

cron.task = 0;0;06;*;*;*;0;180; clvrtsk -c bin ../../bin/export_data "your_desired_timezone" "full_path_where_to_export_the_report" "monitor_name" "from" "to"

The first 3 digits (0;0;06) represent seconds, minutes, and hours which is based on the system time of the machine where AppsWatch Base is installed. By default, it is set to run at 06:00:00 (daily at 6 am). 

You can set the schedule to run at a specific time by updating the digits. For example:

cron.task = 50;37;14;*;*;*;0;180; clvrtsk -c bin ../../bin/export_data "your_desired_timezone" "full_path_where_to_export_the_report" "monitor_name" "from" "to"

This means that the cron task will run at 14:37:50.

Parameters:

1. "your_desired_timezone": Use user's timezone that is set in AppsWatch Base. i.e. "America/New_York"

Here is a link of supported timezones that you can use instead of "your_desired_timezone".

2. "full_path_where_to_export_the_report": This is the location where the report will be saved. 

If it is set to empty (""), it will be saved under ".../AppsWatch/temp" folder.

3. "monitor_name": This is the application monitor name.

If it is set to empty (""), AppsWatch will get all scenarios and transactions.

4. "from": This is the start date of the report. The format is as "mm/dd/yyyy".
If it is set to empty (""), the default will be the start of yesterday.

5. "to": This is the end date of the report. The format is as "mm/dd/yyyy".

If it is set to empty (""), the default will be the end of yesterday.

Once you are done setting up options for your scheduled task, save the cerun.conf file and restart AppsWatch services.

AW Services

This can be a one-time setup which will then generate the report based on the defined cron task and automatically save it under the specified location. 

Example:

cron.task = 0;30;20;*;*;*;0;180; clvrtsk -c bin ../../bin/export_data "America/Los_Angeles" "C:\AW Reports" "Citrix_app" "4/30/2020" "5/1/2020"
- If you schedule to run the cron task everyday for all monitors, use can use the following:
cron.task = 0;0;06;*;*;*;0;180; clvrtsk -c bin ../../bin/export_data "your_desired_timezone" "full_path_where_to_export_the_report"

- If you schedule to run the cron task everyday for a specific monitor, you can use the following:

cron.task = 0;0;06;*;*;*;0;180; clvrtsk -c bin ../../bin/export_data "your_desired_timezone" "full_path_where_to_export_the_report" "monitor_name"

Keep in mind that you should restart AppsWatch Services every time you update cerun.conf file.

Export data using Command Prompt

You can also run the task using Command Prompt:
1. Open the command line and navigate to "...\AppsWatch\webserv\bin" folder.

i.e. cd C:\Program Files (x86)\Automai\AppsWatch\webserv\bin
2. Run the following command with desired parameters.

cron.task = 0;0;06;*;*;*;0;180; clvrtsk -c bin ../../bin/export_data "your_desired_timezone" "full_path_where_to_export_the_report" "monitor_name" "from" "to"