Getting Traffic Usage Information
The get_traffic is used to retrieve information about the traffic spent by a site between two dates. The resulting information got for each sites lists all days between the specified dates and shows the daily traffic spent within a site during this day.
Request Packet Structure
A request XML packet getting traffic information for the specified sites includes the get_traffic operation node:
<packet>
<site>
<get_traffic>
...
</get_traffic>
</site>
</packet>
The get_traffic node does not have a separate data type, it is
nested within the complex type (site.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.9.1/agent_input.svg.
-
filter, required
It specifies sites whose traffic information will be got from Plesk. Data type: siteFilterType (
site.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 site 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.9.1/agent_output.svg.
-
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
). -
status, required
It returns the execution status of the get_traffic operation. Data type: string. Allowed values: ok | error.
-
errcode, optional
It is used to return an error code if the get_traffic operation fails. Data type: unsignedInt.
-
errtext, optional
Can be used to return an error message if the get_traffic operation fails. Data type: string.
-
filter-id, optional
It is always present and used to return the parameter by which the site was filtered by in the request packet. Data type: anySimple.
-
id, optional
Returns the identifier of the site whose traffic is requested. It is missing if the request packet fails before the validation on the server side. Data type: integer.
-
traffic, optional
It contains a collection of traffic data obtained from Plesk server (see below). Data type: trafficType (
plesk_domain.xsd
).
The traffic node is defined by type trafficType
(plesk_domain.xsd
). It is structured as follows:
-
The date, required
It specifies the date for which the traffic is shown. Data type: date. Format: YYYY-MM-DD.
-
The http_in, required
It shows the incoming traffic (in bytes) got via HTTP protocol. Data type: integer.
-
The http_out, required
It shows the outgoing HTTP traffic (in bytes). Data type: integer.
-
The ftp_in, required
It shows the incoming traffic (in bytes) got via FTP protocol. Data type: integer.
-
The ftp_out, required
It shows the outgoing FTP traffic (in bytes). Data type: integer.
-
The smtp_in, required
It shows the incoming traffic (in bytes) got via SMTP protocol. Data type: integer.
-
The smtp_out, required
It shows the outgoing SMTP traffic (in bytes). Data type: integer.
-
The pop3_imap_in, required
It shows the incoming traffic (in bytes) got via POP3 and IMAP protocols. Data type: integer.
-
The pop3_imap_out, required
It shows the outgoing POP3/IMAP traffic (in bytes). Data type: integer.
Note
Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.9.1/agent_input.svg.
Samples
A packet that requests traffic on sites with IDs 1234 and 1235 looks as follows:
<packet>
<site>
<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>
</site>
</packet>
Response:
<packet>
<site>
<get_traffic>
<result>
<status>ok</status>
<filter-id>19</filter-id>
<id>19</id>
<traffic>
<date>2005-12-12</date>
<http_in>4371212365846</http_in>
<http_out>1234111122</http_out>
<ftp_in>4121253</ftp_in>
<ftp_out>163553</ftp_out>
<smtp_in>123535</smtp_in>
<smtp_out>341156</smtp_out>
<pop3_imap_in>1545682</pop3_imap_in>
<pop3_imap_out>15434674</pop3_imap_out>
</traffic>
</result>
</get_traffic>
</site>
</packet>