KB Article #179239
REST API: Obtaining statistical data from SecureTransport on a daily/monthly/* basis
Problem
This article describes the way to obtain statistical data for the number of transfers that went through SecureTransport for a given time frame or protocol with the help of the SecureTransport's REST API.
Table of contents
- Preparations
- Number of transfers per day
- Number of transfers per month
- Number of transfers per day for HTTPS protocol
- Number of transfers per day for FTP protocol
- Number of transfers per day for PeSIT protocol
- Number of transfers per day for SSH protocol
- Number of failed transfers per day
Preparations
To send queries to the ST API, you'd need a REST client application. The examples below are created with cURL
on Linux.
Accessing the API
The variable placeholders used in the commands are described in the below table and have to be replaced with the real values for your server before executing the commands.
Name | Description |
---|---|
<ST Admin User>:<ST Admin Password> |
Master administrator credentials for the SecureTransport server, i.e. admin:admin |
<ST Server IP/FQDN>:<ST Admin Port> |
IP and admin Port of the SecureTransport server. By default, on root installations the admin port is 444, and 8444 on non-root instances. Example: 10.10.10.10:444 |
limit
|
Sets the limit of listed rows. ST's API returns 100 records if the parameter is not specified. To overwrite the default limit ot 100, use a sufficiently large value for the limit .In the examples below, the value of 100000 is used, which can be increased if you expect to have more than 100K transfers for the given time frame. |
status
|
A list of transfer statuses. Possible values are:
In Progress Processed Failed Aborted Pending receipt Failed Subtransmission Paused Failed Transfer Resubmit |
protocol |
A list of transfer protocols. Possible values are:
as2 ftp http ssh pesit folder adhoc sharepoint smb http-generic amazonS3 |
v1.2 |
Any version between 1.1 and 1.4 would work for the requests below. However, since the API version is related to actual ST version in use, refer to the ST Admin Guide for your ST to verify which API version is supported. NOTE: In case that you have ST 5.3.6 or later you can use the v1.4 documentation and generate the API query strings with the help of the Swagger, available at https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.4/docs/index.html . The query string can then be used in your script or tool. |
Date formatting
To get the records for specific time frame (day, week, month, etc.), you will need to specify the start time and the end time of the time frame in the API call. The date is required in RFC2822 string format:
EEE, d MMM yyyy HH:mm:ss Z
An example string would be:
Thu, 14 Dec 2017 16:00:00 +0000
The date string must be URL encoded in order to be accepted by the API. You can use an online encoder like URLEncode, or convert the string in Bash with the following command:
date -R | sed "s/ /%20/g" | sed "s/+/%2b/g"| sed "s/:/%3A/g" | sed "s/,/%2C/g"
NOTE: The last two instances of the sed
can be omitted, although it's recommended to encode all characters with the full command.
The example date from above - Thu, 14 Dec 2017 16:00:00 +0000
- will become:
Thu%2C%2014%20Dec%202017%2016%3A00%3A00%20%2B0000
The resulting string can be now used in the API call syntax.
Filtering the output
The results from the API will contain each transfer as a separate JSON or XML object, so methods like counting the lines in the result will not return correct values. One possible approach is to pipe the results to a grep
for a unique word contained in each result object and then to count the output of the grep
with wc -l
, which will give the total number of objects in the main result, i.e. the number of transfers. More examples are shown below.
Number of transfers per day ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&startTimeAfter=Thu%2C%2014%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Thu%2C%2014%20Dec%202017%2023%3A59%3A59%20%2B0000' | grep "<filesize>" | wc -l
The above query should return a number, which would be the number of transfers between 14/12/2017 00:00:01 and 14/12/2017 23:59:59. You would just need to change the values for the startTimeAfter
and endTimeBefore
attributes with ones that would cover the day of interest and use the date converting methods mentioned above. You can get the values for several days and calculate their median. This can be automated with a bash script.
Number of transfers per month ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&startTimeAfter=Fri%2C%201%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Sun%2C%2031%20Dec%202017%2023%3A59%3A59%20%2B0000' | grep "<filesize>" | wc -l
The above query should return a number, which would be the number of transfers between 01/12/2017 00:00:01 and 31/12/2017 23:59:59. You would just need to change the values for the startTimeAfter
and endTimeBefore
attributes with ones that would cover the month/moths of interest and use the date converting methods mentioned above.
Number of transfers per day for HTTPS protocol ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&startTimeAfter=Fri%2C%201%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Sun%2C%2031%20Dec%202017%2023%3A59%3A59%20%2B0000&protocol=http' | grep "<filesize>" | wc -l
The above query should return a number, which would be the number of transfers between 14/12/2017 00:00:01 and 14/12/2017 23:59:59 which use the https protocol.
Number of transfers per day for FTP protocol ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&startTimeAfter=Fri%2C%201%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Sun%2C%2031%20Dec%202017%2023%3A59%3A59%20%2B0000&protocol=ftp' | grep "<filesize>" | wc -l
Same query as for http, but the parameter protocol
was set to ftp.
Number of transfers per day for PeSIT protocol ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&startTimeAfter=Fri%2C%201%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Sun%2C%2031%20Dec%202017%2023%3A59%3A59%20%2B0000&protocol=pesit' | grep "<filesize>" | wc -l
Same query as for http, but the parameter protocol
was set to pesit.
Number of transfers per day for SSH protocol ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&startTimeAfter=Fri%2C%201%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Sun%2C%2031%20Dec%202017%2023%3A59%3A59%20%2B0000&protocol=ssh' | grep "<filesize>" | wc -l
Same query as for http, but the parameter protocol
was set to ssh.
Number of failed transfers per day ↑
API call:
curl -k -u <ST Admin User>:<ST Admin Password> -X GET --header 'Accept: application/xml' 'https://<ST Server IP/FQDN>:<ST Admin Port>/api/v1.2/transfers?limit=100000&offset=0&status=Failed&startTimeAfter=Fri%2C%201%20Dec%202017%2000%3A00%3A01%20%2B0000&endTimeBefore=Sun%2C%2031%20Dec%202017%2023%3A59%3A59%20%2B0000' | grep "<filesize>" | wc -l
Setting the query string status=Failed
will return only transfers, which ended in error for all protocols. The status
can be set to the various values from the table above. Any of those can be combined with a protocol
parameter to narrow down the transfers with this status for the specific protocol.