Getting Traffic Usage Information
The get_traffic is used to retrieve information about the traffic spent by a subscription between two dates. The resulting information got for each subscription lists all days between the specified dates and shows the daily traffic spent within a subscription during this day.
Request Packet Structure
A request XML packet getting traffic information for the specified subscriptions includes the get_traffic operation node:
<packet>
<webspace>
<get_traffic>
...
</get_traffic>
</webspace>
</packet>
The get_traffic node does not have a separate data type, it is
nested within the complex type (domain_input.xsd
). The
get_traffic node has the following graphics representation:
Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.
-
filter, required
It specifies subscriptions whose traffic information will be got from Plesk. Data type: DomainFilterType (
domain_input.xsd
). To see the structure of this node, proceed to topic Available Filters. -
since_date, optional
It specifies the starting date of the period. If the packet is missing this node, the analyzed days will not be limited below. Data type: date. Format: YYYY-MM-DD.
-
to_date, optional
It specifies the end date of the period. If the packet is missing this element, the period will be limited by the date of the request execution. Data type: date. Format: YYYY-MM-DD.
If the packet is missing both nodes since_date and to_date, the response packet will show the traffic of the specified subscription day by day since its creation and up to the date of the request execution.
Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.
Response Packet Structure
The get_traffic node of the response packet is structured as follows:
Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.
-
The result, optional
It wraps the result of the requested get_traffic operation. It can be missing if some error occurs before the validation starts. Data type: resultFilterType (
common.xsd
). -
The status, required
It returns the execution status of the get_traffic operation. Data type: string. Allowed values: ok | error.
-
The errcode, optional
It is used to return an error code if the get_traffic operation fails. Data type: unsignedInt.
-
The errtext, optional
Can be used to return an error message if the get_traffic operation fails. Data type: string.
-
The filter-id, optional
It is always present and used to return the parameter by which the subscription was filtered by in the request packet. Data type: anySimple.
-
The id, optional
Returns the identifier of the subscription whose traffic is requested. It is missing if the request packet fails before the validation on the server side. Data type: integer.
-
The traffic, optional
It contains a collection of traffic data obtained from Plesk server (see below). Data type: trafficType (
plesk_domain.xsd
).
The traffic, defined by type trafficType (plesk_domain.xsd
).
It is structured as follows:
-
date, required
It specifies the date for which the traffic is shown. Data type: date. Format: YYYY-MM-DD.
-
http_in, required
It shows the incoming traffic (in bytes) got via HTTP protocol. Data type: integer.
-
http_out, required
It shows the outgoing HTTP traffic (in bytes). Data type: integer.
-
ftp_in, required
It shows the incoming traffic (in bytes) got via FTP protocol. Data type: integer.
-
ftp_out, required
It shows the outgoing FTP traffic (in bytes). Data type: integer.
-
smtp_in, required
It shows the incoming traffic (in bytes) got via SMTP protocol. Data type: integer.
-
smtp_out, required
It shows the outgoing SMTP traffic (in bytes). Data type: integer.
-
pop3_imap_in, required
It shows the incoming traffic (in bytes) got via POP3 and IMAP protocols. Data type: integer.
-
pop3_imap_out, required
It shows the outgoing POP3/IMAP traffic (in bytes). Data type: integer.
Samples
This packet requests traffic on a single subscriptions:
<packet>
<webspace>
<get_traffic>
<filter>
<id>1</id>
</filter>
<since_date>2006-10-01</since_date>
</get_traffic>
</webspace>
</packet>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
<webspace>
<get_traffic>
<result>
<status>ok</status>
<filter-id>1</filter-id>
<id>1</id>
<traffic>
<date>2015-10-05</date>
<http_in>0</http_in>
<http_out>0</http_out>
<ftp_in>0</ftp_in>
<ftp_out>0</ftp_out>
<smtp_in>3055</smtp_in>
<smtp_out>0</smtp_out>
<pop3_imap_in>0</pop3_imap_in>
<pop3_imap_out>0</pop3_imap_out>
</traffic>
</result>
</get_traffic>
</webspace>
</packet>
A packet that requests traffic on subscriptions with IDs 1234 and 1235 looks as follows:
<packet>
<webspace>
<get_traffic>
<filter>
<id>1234</id>
<id>1235</id>
</filter>
<since_date>2006-10-01</since_date>
</get_traffic>
<get_traffic>
<filter>
<name>technolux.co.uk</name>
<name>softlux.com</name>
</filter>
<since_date>2006-10-01</since_date>
</get_traffic>
</webspace>
</packet>
To get traffic information for all subscriptions belonging to a certain customer, use group filtering (see topic Available Filters for details). Customers whose domains are filtered can be specified within one filter either by owner-id or by owner-login.
<packet>
<webspace>
<get_traffic>
<filter>
<owner-login>technolux</owner-login>
<owner-login>technologic</owner-login>
</filter>
<since_date>2006-10-01</since_date>
</get_traffic>
<get_traffic>
<filter>
<owner-login>1342</owner-login>
<owner-login>1452</owner-login>
</filter>
<since_date>2006-10-01</since_date>
</get_traffic>
</webspace>
</packet>
To get traffic information for all subscriptions available for XML API requester in Plesk, send the following packet:
<packet>
<webspace>
<get_traffic>
<filter/>
<since_date>2006-10-01</since_date>
</get_traffic>
</webspace>
</packet>