In this topic:
Also see:
A Windows PowerShell script file named Export-DcsDataUsageReport.ps1 is included in the SANsymphony installation folder (default path C:\Program Files\DataCore\SANsymphony) to facilitate exporting data usage statistics for host groups in order to charge back the costs of storage-related expenses to customers. The script can be run in an automated task to create and export data usage and detailed data usage reports for scheduled times when the statistics are needed for billing. The script can also be run from a PowerShell command line. The script uses the PowerShell cmdlet Export-DcsReport, which is included in the suite of DataCore Cmdlets, see Getting Started with DataCore Cmdlets.
The script connects to the local server and passes the specified parameters (below) to create and export either a Data Usage or Detailed Data Usage report. The task is run on locally on the DataCore Server from where it is run. The report will be saved on the same DataCore Server.
In order to run the script in a task, a task must be created:
o The trigger can be of any type, but to create the reports based on a scheduled date and time, the trigger type should be a Scheduled Time trigger.
o The action should be configured to Run a PowerShell Script. See the Task Parameters section below for descriptions, syntax, and examples.
Charge back must be enabled for host groups and data must exist in the database in order to receive data in the reports.
The parameters used in the script have been modified for ease of use and are slightly different than the parameters used to create and export reports using the Export-DcsReport cmdlet in PowerShell.
The parameter set to create the Data Usage or Detailed Data Usage report:
Export-DcsReport -ReportName <String> [ -Description <String> ] -ExportType <String> -Path <String> -HostGroup <String[]> -DaysBack <Int32> [ -SortBy <String> ] [-Detailed] [ -DescendingOrder] [ -AddDateToFileName]
Do not select the Append the associated Task Trigger Data objects check box when creating the action, trigger states are not used with this script.
Parameter Descriptions:
ReportName |
The name of the report. |
Description |
Description of report. |
ExportType |
The format of the report. Possible parameter values include "Csv", "Html", "Mht", "Pdf", "Rtf", "Text", "Xls", "Xlsx", "Bmp", "Gif", "Jpeg" or "Png". |
Path |
The path where the report should be saved. The report will be saved on the computer that invokes this cmdlet. Specify the path to an existing folder. For example, to save the report to an existing folder on the C: drive named Reports, the path would be "C:\Reports\". To save the report directly to the C: drive, the path would be "C:\". |
HostGroup |
Filtering parameter used to specify host group names, supplied in an array of strings separated by commas. The Data Usage report can be exported with one or more host group names. For example, "Host Group 1", "Host Group 2", "Host Group 3". If this parameter is specified for the Data Usage report, only data for those host groups will be included in the report. If the parameter is not specified, data for all host groups in the local server group will be included in the report. The Detailed Data Usage report provides data for one host group and that name must be specified. More than one host group is not supported for this report. |
DaysBack |
The number of days proceeding the current day that the report data should begin. This would represent the start date of the report. The end date would be the day before the report is run (EndDate = Today-1). StartDate = EndDate - DaysBack. For example, if the report is run on October 14, 2014 and the DaysBack value is 30, then the report would have data from September 13 through October 13 because September has 30 days in the month. |
SortBy |
Sort order criteria. Specify this parameter to sort the report by the designated value. For Data Usage report, possible values include "HostGroupName", "TotalBytesTransferred", "TotalBytesWritten", "TotalBytesRead", "TotalOperations", "TotalWrites", or "TotalReads". The Detailed Data Usage cannot be sorted. |
Detailed |
Specify this parameter to create a Detailed Data Usage Report. If this parameter is not included in the invocation, the Data Usage report will be created. |
DescendingOrder |
Specify this parameter to sort the report in descending order. If this parameter is not included in the invocation, the report will be sorted in ascending order. |
AddDateToFileName |
Specify this parameter to append the creation date of the report to the beginning of the report name. The date is in the format year.month.day, for example "2014.10.31 Data Usage for All Groups.csv". |
To create a Data Usage report for all host groups:
-ReportName "Data Usage for All Host Groups" -Description "Charge back statistics for all host groups for the month" -ExportType csv -Path "C:\Reports\" -DaysBack 30 -SortBy "HostGroupName" -DescendingOrder -AddDateToFileName
At the configured scheduled time, the report named "Data Usage for All Host Groups" will be created in comma separated value format and saved to the path "C:\Reports\Data Usage for All Host Groups 10/31/14.csv". The creation date (10/31/14) of the report in appended to the name. Since the HostGroups parameter is not included, data for all host groups for the last 30 days will be included. The report is sorted in descending order by the host group name.
To create a Data Usage report for more than one host group:
-ReportName "Data Usage for Area 1" -Description "Monthly charge back statistics for all host groups in Area 1" -ExportType text -Path "C:\Reports\" -HostGroup "Host Group 1", "Host Group 2", "Host Group 3" -DaysBack 30 -SortBy "HostGroupName"
At the configured scheduled time, the report named "Data Usage for Area 1" will be created in a text file and saved to the path "C:\Reports\Data Usage for Area 1.txt". Data for the host groups named "Host Group 1", "Host Group 2", and "Host Group 3" for the last 30 days will be included in the report. Since the parameter DescendingOrder is not included, the report will be sorted in ascending order by the host group name.
To create a Detailed Usage report for a specified host group:
-ReportName "Detailed Data Usage for Host Group 1" -Description "Detailed charge back statistics for Host Group 1 for the month" -ExportType xls -Path "C:\Reports\" -HostGroup "Host Group 1" -DaysBack 14 -SortBy "HostGroupName"
At the configured scheduled time, the report named "Detailed Data Usage for Host Group 1" will be created in an Excel spreadsheet format and saved to the path "C:\Reports\Detailed Data Usage for Host Group 1.xls". Detailed data for the host group named "Host Group 1" for the last seven days will be included in the report. Since the parameter DescendingOrder is not included, the report will be sorted in ascending order by the host group name.